ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 30 Apr 2018 08:38:34 -0500Make SageMath allow for Error of Mathematicahttp://ask.sagemath.org/question/42223/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 :)Mon, 30 Apr 2018 06:45:47 -0500http://ask.sagemath.org/question/42223/make-sagemath-allow-for-error-of-mathematica/Answer by JasonK for <p>Hello everyone! </p>
<p>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 </p>
<blockquote>
<p>"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. "</p>
</blockquote>
<p>and as a result Sage raised the error and returned no solution. </p>
<p>I am trying to get solutions to the system:</p>
<pre><code>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}
</code></pre>
<p>for the variables </p>
<pre><code>var={x1,x2,lamda1,lamda2,lamda3,lamda4}
</code></pre>
<p>and a sample of the code for the solve is: </p>
<pre><code>from sage.interfaces.mathematica import mathematica
sys = mathematica(sys)
var=mathematica(var)
sys.Solve(var)
</code></pre>
<p>Is it possible to make an exception for specific Mathematica errors so as to get the solution? </p>
<p>Many thanks,
Jason :)</p>
http://ask.sagemath.org/question/42223/make-sagemath-allow-for-error-of-mathematica/?answer=42226#post-id-42226Apologies 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
Mon, 30 Apr 2018 08:38:34 -0500http://ask.sagemath.org/question/42223/make-sagemath-allow-for-error-of-mathematica/?answer=42226#post-id-42226