normalizing numeric polynomials

jocaps
Messages : 118
Inscription : lun. avr. 17, 2017 4:32 pm

normalizing numeric polynomials

Message par jocaps » ven. févr. 08, 2019 12:18 pm

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

frederic han
Messages : 1113
Inscription : dim. mai 20, 2007 7:09 am
Localisation : Paris
Contact :

Re: normalizing numeric polynomials

Message par frederic han » 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

parisse
Messages : 5082
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: normalizing numeric polynomials

Message par parisse » ven. févr. 15, 2019 7:19 pm

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.

jocaps
Messages : 118
Inscription : lun. avr. 17, 2017 4:32 pm

Re: normalizing numeric polynomials

Message par jocaps » sam. févr. 16, 2019 11:04 pm

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

frederic han
Messages : 1113
Inscription : dim. mai 20, 2007 7:09 am
Localisation : Paris
Contact :

Re: normalizing numeric polynomials

Message par frederic han » ven. févr. 22, 2019 10:05 pm

No my previous example gives 0 under Xcas also.

Digits is avaible with giacpy see:

Code : Tout sélectionner

import giacsettings
help(giacsettings)

Répondre