Page 1 sur 1

normalizing numeric polynomials

Publié : ven. févr. 08, 2019 12:18 pm
par jocaps
Consider the following code

Code : Tout sélectionner

from giacpy import giac

giac("printpow(1)")

f=giac("3.02565028105e+042*x^2+x")
print (f/f.lcoeff("x")).expand() 
The above returns 0, but it must return a normalized f (f divided by the coefficient of the monomial with highest degree). Any ideas how to resolve this?

Jose

Re: normalizing numeric polynomials

Publié : ven. févr. 15, 2019 6:02 pm
par frederic han
This is not giacpy related, I have a similar problem with n>=12:
whatever is epsilon or Digits.

Code : Tout sélectionner

n:=12:; expand((evalf(10**n,100)*x^2+x)/evalf(10**n,100))
(I put evalf with 100 digits to avoid global Digits or epsilon2zero limitations. Bernard, is there some epsilon2zero use in this division? or is it always done in floats instead of mpfr?

Frederic

Re: normalizing numeric polynomials

Publié : ven. févr. 15, 2019 7:19 pm
par parisse
Yes, there are eps->0 replacements. I have removed one in regroup in my source. But I won't make a lot of changes related to that, because I fear side effects.

Re: normalizing numeric polynomials

Publié : sam. févr. 16, 2019 11:04 pm
par jocaps
frederic han a écrit :
ven. févr. 15, 2019 6:02 pm
This is not giacpy related, I have a similar problem with n>=12:
whatever is epsilon or Digits.

Code : Tout sélectionner

n:=12:; expand((evalf(10**n,100)*x^2+x)/evalf(10**n,100))
(I put evalf with 100 digits to avoid global Digits or epsilon2zero limitations. Bernard, is there some epsilon2zero use in this division? or is it always done in floats instead of mpfr?

Frederic
Thanks for the explanation.

That's a pity. In your example n=12 is rather small and I think changing Digits will have no effect when using giacpy in this way. As you probably know, XCas has the correct result . So is it correct to assume that as soon as I have a division of this sort with python and giacpy I am using floats and not mpfr/gmp or is it that the global epsilon is set much lower? In my XCas epsilon is set to 1e-12 and giacpy claims the same (if I type giac("epsilon") I get 1e-12). I suspect the epsilon is higher in practice (when using giac outside XCas) because your example for instance is still within float precision (I think).

So I am guessing there is no workaround for this (even a hack). This is a pity since I am solving some system of equations for which I would need the numerical values.

Jose

Re: normalizing numeric polynomials

Publié : ven. févr. 22, 2019 10:05 pm
par frederic han
No my previous example gives 0 under Xcas also.

Digits is avaible with giacpy see:

Code : Tout sélectionner

import giacsettings
help(giacsettings)