Page 1 sur 1

Converting a float polynomial to integer polynomial

Publié : mer. sept. 19, 2018 7:56 am
par jocaps
Hi,

After some computations with algebraic numbers (as floats with high precision) I obtain a polynomial whose coefficients I know are integer but because the computations are done with floats, giac/xcas will show the coefficients with the decimals. I want to know what is the best way to convert this polynomial into an integral polynomial. As example:

I have the following polynomial:

Code : Tout sélectionner

0.30900000000000000000000000000000e3*x^6+0.11700000000000000000000000000000e4*x^5*y+0.47999999999999999999999999999999e2*x*y^2*z^3
This is a polynomial with integer coefficients. So from that I want to get

Code : Tout sélectionner

309*x^6+1170*x^5*y+48*x*y^2*z^3
any easy way of doing this in Xcas/giac?

Jose

Re: Converting a float polynomial to integer polynomial

Publié : mer. sept. 19, 2018 8:06 am
par lukamar
Hello Jose,
I think the simplest way is to use the "exact" command:

Code : Tout sélectionner

p:=0.30900000000000000000000000000000e3*x^6+0.11700000000000000000000000000000e4*x^5*y+0.47999999999999999999999999999999e2*x*y^2*z^3;
exact(p)
The sensitivity depends on the epsilon constant which can be changed in session settings.

Luka

Re: Converting a float polynomial to integer polynomial

Publié : mer. sept. 19, 2018 8:50 am
par jocaps
Hi Luka,

Wonderful, thanks a lot!

Apologies, I should have thought of that, I missed this command in the manual.

Jose