Bill Allombert on Tue, 11 Feb 2003 19:05:21 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: gp: subst(x^2+x+1,x^2+1,x) |
On Tue, Feb 11, 2003 at 06:47:40PM +0100, Karim BELABAS wrote: > On Mon, 10 Feb 2003, Michael Somos wrote: > > ? subst(x^2+x+1,x^2+1,x) > > %1 = 2*x > > > > Is it supposed to do that? > > Yes. The algorithm for subst(source,X,Y) is `replace as much as possible, and > let leftover powers alone (if source cannot be expanded in powers of X)' > > (18:43) gp > subst(x^2+x+1, x^2+1, Y) > %1 = x + Y > > [ the alternative would be an error message, which would not be that useful ] I believe we should come back to the plain subst(pol,'var,data) and add another GP function for polynomial substitution, this would be much saner than this. Or if we are for overloading, allow a vector of variable as second argument and a vector of data as third, all substitued using the current algorithm, in left-to-right order. Cheers, Bill.