Karim BELABAS on Thu, 4 Oct 2001 14:42:07 +0200 (MEST)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: subst


On Tue, 2 Oct 2001, Jean-Marc Sac-Epée wrote:
> I would like to replace the variable x by x+1/x in a polynomial p.
> Under gp, I simply use something like
> p=x^5+x+1
> subst(p,x,x+1/x)
>
> but in library mode, what is the good synthax? p is a polynomial, but
> can I use gsubst even if x+1/x is not a polynomial?

  long  var = 0; /* for instance ! */
  GEN    X  = polx[var];
  gsubst(p, var, gadd(X, ginv(X)));

Here p is "arbitrary". If p is known to be a scalar/t_POL/t_RFRAC, _and_ you
want to substitute wrt the main variable of p, you can use

  poleval(p, gadd(X, ginv(X)));

Hope this helps,

    Karim.
-- 
Karim Belabas                    email: Karim.Belabas@math.u-psud.fr
Dep. de Mathematiques, Bat. 425
Universite Paris-Sud             Tel: (00 33) 1 69 15 57 48
F-91405 Orsay (France)           Fax: (00 33) 1 69 15 60 19
--
PARI/GP Home Page: http://www.parigp-home.de/