Bill Allombert on Sat, 04 Jun 2011 12:04:50 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: leading_term and constant_term / lg in polynomials |
On Fri, Jun 03, 2011 at 07:33:26PM -0400, Charles Greathouse wrote: > These inline functions are almost too simple to be wrong, but I'm > finding bizarre behavior. Minimal test function: > > long > test(GEN f) > { > if (typ(f) != t_POL) > pari_err(typeer, "test"); > GEN LEAD = leading_term(f); > if (!isint1(LEAD)) { > pari_printf("%Ps: Leading term is %Ps; polynomial has length %d. > Constant term: %Ps.\n", f, LEAD, lg(f), constant_term(f)); > return 0; > } > return 1; > } > > Loading into gp via gp2c, I get > > >test(x^2-1) > -x + 1: Leading term is -1; polynomial has length 4. Constant term: 1. On the face of it this is correct: if f=-x + 1, then the rest follows. What is more puzzling is why f=-x + 1 while you expect it to be equal to x^2-1. Something is wrong somewhere but outside the sample you sent: here it works: ? install(test,lG,,"../test.so") ? test(x^2-1) %1 = 1 Cheers, Bill.