## order of variables in solve

Bugs

lukamar
Messages : 299
Inscription : ven. juin 30, 2017 9:55 am
Localisation : Zagreb, Croatia

### order of variables in solve

Hello,

the accuracy of solve seems to depend on the order of variables and/or equations in some cases, e.g.

Code : Tout sélectionner

``solve(grad(x^2-y^2-lambda*(x^3+y^3-3*x*y),[x,y,lambda]),[x,y,lambda])``
returns

Code : Tout sélectionner

``[[0,0,sqrt(2*(sqrt(13)-1)/9)],[-expr("rootof([[1,-65,203,-2035],[1,0,10,-936,-3251]])",0)/4032,-expr("rootof([[1,-2,-49,-838],[1,0,10,-936,-3251]])",0)/504,sqrt(2*(sqrt(13)-1)/9)],[0,0,-(sqrt(2*(sqrt(13)-1)/9))],[-expr("rootof([[1,-2,-49,-838],[1,0,10,-936,-3251]])",0)/504,-expr("rootof([[1,-65,203,-2035],[1,0,10,-936,-3251]])",0)/4032,-(sqrt(2*(sqrt(13)-1)/9))],[0,0,lambda]]``
i.e. four solutions, while

Code : Tout sélectionner

``solve(grad(x^2-y^2-lambda*(x^3+y^3-3*x*y),[lambda,x,y]),[lambda,x,y])``
returns just 2 solutions:

Code : Tout sélectionner

``[[lambda,0,0],[0.760927982497,1.45681504207,0.845960595657]]``

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

### Re: order of variables in solve

That's because the ideal is not 0-dimensional, rational univariate representation is not applicable, the current implementation of solve computes variables w.r.t. the order given (inverse order to be more precise). If a polynomial can not be solved exactly, approx roots are computed instead, and accuracy errors may propagate.

lukamar
Messages : 299
Inscription : ven. juin 30, 2017 9:55 am
Localisation : Zagreb, Croatia

### Re: order of variables in solve

Thanks for the explanation! It helps when using solve programmatically within other algorithms.