| Bill Allombert on Fri, 23 May 2008 00:15:41 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: problem with polynomials |
On Fri, May 23, 2008 at 12:44:28AM +0300, Kostas Patsakis wrote:
> Hello,
>
> I'm trying to use pari in order to set the coefficients of a
> polynomials from a vector.
> eg if the vector is [1 0 3] then f(x)=1+x^2
> i tried something like this:
> poly(t)=0*t;
> for(cnt=1,len,{
> poly(t)=poly(t)+t^(cnt-1)*a[cnt];})
>
> but pari does not like it...
> i keep getting *** deep recursion: poly(t)
You must not add (t) after polynomial name: it is
f=1+x^2
and
poly=0*t
and
poly=poly+t^(cnt-1)*a[cnt];
Polynomial are not functions, you must use subst(f,x,...) to evaluate
them.
> any ideas on how I can do it?
Use the functions Pol or Polrev.
? Polrev([1,0,3])
%1 = 3*x^2 + 1
? Pol([1,0,3])
%2 = x^2 + 3
Cheers,
Bill.