## fsolve and giacpy undef return

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

### fsolve and giacpy undef return

Consider the following code in python using giacpy:

Code : Tout sélectionner

``````from giacpy import giac, fsolve

giac("printpow(1)")

p1 = giac("-0.001*x2^3-0.09*x0*x2^2+0.317480210394*x2^3+0.251984209979*x0*x2^2-2.8*x0^2*x2-0.1*x2-4.2*x2^2-3.17480210394*x0^2*x2-12.6992084157*x0*x2^2-2.51984209979*x0^3-10.0793683992*x0^2*x2-28*x0^3+42*x0^2*x2-3*x0+42*x0*x2+296*x0*x2^2-126*x0*x2+2*x0+294*x2^2+700*x2^3+14*x2")

p2 = giac("2.51984209979*x2^3+x0*x2^2+3.17480210394*x0*x2^2+22.2236147276*x2^3-2.51984209979*x0^2*x2-2.51984209979*x0*x2^2+6*x0^2*x2-3.17480210394*x0^3-34.9228231433*x0^2*x2-88.8944589102*x0*x2^2-7.55952629937*x0^3-30.2381051975*x0^2*x2+10*x0^3-2*x0^2*x2+x0-28*x0*x2^2+42*x0*x2*0.1-42*x2^2-100*x2^3-2*x2*0.01")

print fsolve([p1,p2],"[x0,x2]")
``````
fsolve returns the following

Code : Tout sélectionner

``````[[undef,-0.929461941455],[undef,-0.187677134318-0.111743588445*i],[undef,-0.187677134318+0.111743588445*i],[undef,-0.0373387315939],[undef,-0.0369367368322],[0.0,0.0],[undef,0.008026807923-0.0578874749249*i],[undef,0.008026807923+0.0578874749249*i],[undef,0.0416488021385]]
``````
so there seems to be bug in the first coordinate. XCas delivers more reasonable result

Code : Tout sélectionner

``````[[1.48308123701274477069483,-0.929461941455349986406441],[0.646775735060209667044207e-1,-0.373387315939176868731258e-1],[-0.327403486563027120519700,-0.369367368322201136450837e-1],[0,0],[0.217223438787046949993830,0.416488021384544765087723e-1]]
``````
I am using giacpy 0.6.7 for windows (python 2.7, 32 bit )

Jose

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

### Re: fsolve and giacpy undef return

Yes but I think it is just because the windows dll is built with less dependency (may be lapack here?) so here is could encounter some accuract problem with [x0,x2] and not with [x2,x0]

Indeed it does the same in geogebra:
Capture du 2019-01-14 07-32-56.png (43.41 Kio) Consulté 702 fois

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

### Re: fsolve and giacpy undef return

That is a cause of concern.

In any case, Xcas for windows has lapack and blas dependencies precompiled (actually they are cyg librarires, but one can compile directly with lapack and blas dlls in mingwc). I'm not sure what fsolve of giac is dependent on, but its not unreasonable to depend on lapack and blas. I can try compiling giac with these (it has been a long time since I obtained the original source, so I have to update my gaic source) and replace the dlls and add the aditional dependencies in the python library folder and check if this will work (at least I will have a temporary workaround).

Jose

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

### Re: fsolve and giacpy undef return

I have changed some is_zero() to is_exactly_zero() so that it will work in the next releases.
https://dev.geogebra.org/trac/changeset/66408/