Bill Allombert on Mon, 18 May 2020 09:37:27 +0200


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

Re: Efficient way to define and evaluate polynomial function


On Mon, May 18, 2020 at 04:49:57PM +1000, Kevin Ryde wrote:
> Bill Allombert <Bill.Allombert@math.u-bordeaux.fr> writes:
> >
> > my(P=(2*n^6 + 6*n^5 + 5*n^4 - n^2)); sumn_5(n)=subst(P,'n,n)/12
> 
> Is an inline polynomial literal like 2*'n^6 + ... recognised by gp as a
> constant?  

No. 

> Or usually better P to ensure the object created only once?

Yes.

> Oh, and the same for smallish vectors or matrices?

The same.

Cheers,
Bill