Page 1 sur 1

solve

Publié : lun. août 21, 2017 12:46 am
par lukamar
Hello,

the function 'solve' fails to find the solution (x=4/3,y=sqrt(2/3),u1=sqrt(2/3),u2=0,u3=0) to the following system of equations:
y-u1+u2=0, x-2*y*u1+u3=0, u1*(2-x-y^2)=0, u2*x=0, u3*y=0.

When I enter

Code : Tout sélectionner

solve([y-u1+u2=0,x-2*u1*y+u3=0,u1*(2-x-y^2)=0,u2*x=0,u3*y=0],[x,y,u1,u2,u3])
I get only the solution [0,-u2,0,u2,0]. Assuming

Code : Tout sélectionner

assume(u1>0)
the function 'solve' fails to find any solution. As the above system is quite easy to solve, I think it may be a bug.

Re: solve

Publié : lun. août 21, 2017 7:50 am
par parisse
I checked, it's a limitation of the solve algorithm if the number of solutions is infinite, you get only generic solutions. Here after computing the Groebner basis in lex order, the first equation solved is -u2*u3=0 with respect to u3, and the solver returns 0 (u2 is considered generic, the special case u2=0 is unfortunately ignored).

Re: solve

Publié : mar. août 22, 2017 1:59 pm
par parisse
I have improved the solve postprocessing algorithm, it will now return [[0,0,0,0,0],[2*(1/3*sqrt(6))^2,1/3*sqrt(6),1/3*sqrt(6),0,0],[2*(-1/3*sqrt(6))^2,-1/3*sqrt(6),-1/3*sqrt(6),0,0],[0,-u2,0,u2,0],[-u3,0,0,0,u3]]

Re: solve

Publié : mar. août 22, 2017 3:15 pm
par lukamar
That's it. I was solving some problems using Karush-Kuhn-Tucker conditions and I noticed that 'solve' failed to find solution in some quite simple cases. The above system is one example. I believe this fix covers for that.

Re: solve

Publié : jeu. sept. 07, 2017 6:56 am
par lukamar
There is a bug in function 'solve'. When I enter

Code : Tout sélectionner

assume(x>-pi/2 and x<pi/2); solve(1/(1+tan(x)^2)=0,x)
'solve' returns [-pi/2,pi/2]. But not only these points are excluded from domain of x, but the expression 1/(1+tan(x)^2) can't vanish because it's undefined for x=k*pi/2, where k is integer.

Re: solve

Publié : jeu. sept. 07, 2017 8:36 am
par parisse
There is indeed a missing check for excluded values that I'm fixing now.
If the assume inequations are large, solve will still return -pi/2 and pi/2 because trigonometric equations are sometimes rewritten in terms of half tangent and it's too difficult to track. It's not wrong if you consider limits :-)