# Make SageMath allow for Error of Mathematica

Hello everyone!

I am currently trying on the interface of SageMath to Mathematica for the solution of polynomial equations and inequalities. Whilst doing that I came across an instance that is typical for Mathematica when solving systems of polynomial equation and inequalities. I tried to solve the system and Mathematica returned the error

"Mathematica ERROR: Solve::ratnz: Solve was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result. "

and as a result Sage raised the error and returned no solution.

I am trying to get solutions to the system:

sys={0.500000000000000*lamda2*theta3 - 3*x1^2 + 2*lamda1 - lamda3 + 5==0,lamda1 + lamda2 - lamda4 + 3*theta1 - 6*x2==0,lamda1*(theta2 + 2*x1 + x2 - 7.50000000000000)==0,(0.500000000000000*theta3*x1 + x2 - 1.50000000000000)*lamda2==0,-lamda3*x1==0,-lamda4*x2==0}


for the variables

var={x1,x2,lamda1,lamda2,lamda3,lamda4}


and a sample of the code for the solve is:

from sage.interfaces.mathematica import mathematica
sys = mathematica(sys)
var=mathematica(var)
sys.Solve(var)


Is it possible to make an exception for specific Mathematica errors so as to get the solution?

Many thanks, Jason :)

edit retag close merge delete

Sort by » oldest newest most voted

Apologies for posting again but I figured out you can pass the option as a normal arguement so:

mathematica('Off[Solve::ratnz]')


does the trick and solve returns the solutions.

Hope this helps someone else too.

JasonK

more