Karim BELABAS on Thu, 22 Oct 1998 18:17:03 +0200 (MET DST)


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

Re: Explain this behavior?


[Roland Dreier:]
> [Jeremy Teitelbaum:]
> > can anyone explain this to me?  The variable l1 is computed
> > in a function.   It contains a matrix with rational entries.
> > THe command mathnf(l1) fails; however, typing "l1" followed
> > by mathnf(%) works fine.
> 
> I have experienced similar behavior when values that looked like constants
> are actually stored by gp as polynomials of degree 0.  Displaying the
> value and then using % seems to change the type (I'm not sure why).

Because automatic simplification is in effect: before any result is stored in
the history, GP tries to simplify it (\y to toggle this off though I don't
see any good reason to do so).

> You could investigate this by looking at  "type(l1[1,1])" versus
> "type(%[1,1])".

Or in one step: m=matsize(l1); matrix(m[1],m[2], i,j, type(l1[i,j]))

> If this is indeed the problem, the way around it is simply to evaluate
> your constant polynomials.  Just use "subst(l1, variable, 0)" instead of
> l1, where "variable" is the variable gp thinks the entries are polynomials
> in.

simplify(l1) would be a better solution.

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://pari.home.ml.org