Giacpy and some symbolic+numerical computations
Publié : dim. déc. 17, 2017 5:06 am
Hi,
I have made a series of long computations. One computation is faster but requires me to solve the numerical root of a polynomial and another computation is slower but more exact and the computations are mostly symbolic. To compare these computation I subtract the result to see if it becomes zero. Giacpy seems to have trouble with it (Xcas has only trouble with it if I use the "simplify" command, but writing the whole subtracted expression will yield 0). You can reproduce the problem with the following short code
One easily checks that for instance the monomial term x0^6 should vanish (I also tried evalf or simply initiate the whole expression as a new giac pygen variable, but I get the same result). Trying simplify("x0^6-x0^6") will give me 0. But not with this long expression which has the monomials "x0^6" and "-x0^6".
In most situations I do only need symbolic computations but there are instances when I can only solve my problem numerically (through some roots of a high degree polynomial) and to assure myself that I have the correct result is important.
Edit: I just want to report that putting the expression in "expand" will work.
Jose
I have made a series of long computations. One computation is faster but requires me to solve the numerical root of a polynomial and another computation is slower but more exact and the computations are mostly symbolic. To compare these computation I subtract the result to see if it becomes zero. Giacpy seems to have trouble with it (Xcas has only trouble with it if I use the "simplify" command, but writing the whole subtracted expression will yield 0). You can reproduce the problem with the following short code
Code : Tout sélectionner
from giacpy import simplify
giac("printpow(1)") # trick to force the ^ printing with giac
print simplify("x0^6+2.0*x1^6+(4.0+3.5527136788e-015*i)*x2^6+(-1.0-1.42108547152e-014*i)*x0*x1^5+1.0*x0*x2^5+(-2.0-2.84217094304e-014*i)*x1*x2^5+(4.0-1.7763568394e-015*i)*x0^2*x2^4+(-4.0-7.1054273576e-015*i)*x0^3*x2^3+(1.0+1.42108547152e-014*i)*x0^4*x1^2+(1.0+1.42108547152e-014*i)*x0^4*x2^2-2.0*x0^5*x2+(2.0-2.84217094304e-014*i)*x1^4*x2^2-8.0*x0*x1^2*x2^3-1.0*x0*x1^3*x2^2+(-12.0-7.1054273576e-015*i)*x0*x1^4*x2+(3.0-4.97379915032e-014*i)*x0^2*x1*x2^3+(18.0+3.5527136788e-014*i)*x0^2*x1^2*x2^2+(5.0+3.5527136788e-014*i)*x0^2*x1^3*x2-5.0*x0^3*x1*x2^2-x0^6+2*x0^5*x2-x0^4*x2^2-x0^4*x1^2+4*x0^3*x2^3+5*x0^3*x2^2*x1-4*x0^2*x2^4-3*x0^2*x2^3*x1-18*x0^2*x2^2*x1^2-5*x0^2*x2*x1^3-x0*x2^5+8*x0*x2^3*x1^2+x0*x2^2*x1^3+12*x0*x2*x1^4+x0*x1^5-4*x2^6+2*x2^5*x1-2*x2^2*x1^4-2*x1^6")
In most situations I do only need symbolic computations but there are instances when I can only solve my problem numerically (through some roots of a high degree polynomial) and to assure myself that I have the correct result is important.
Edit: I just want to report that putting the expression in "expand" will work.
Jose