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, 23 Feb 2015 01:43:09 -0600Solve behaviour on same equation twicehttp://ask.sagemath.org/question/25843/solve-behaviour-on-same-equation-twice/Two questions:
**The first one:**
Solving an equation:
solve(sin(x)==0,x)
gives the solution `[a=pi]`
but
solve([sin(x)==0,sin(x)==0],x)
raises to the somehow better solution `[[a == pi*z425]]` Where is the difference between the two equations?
**A second one:** A previous version of sage 5.something could solve
solve([sin(x)==0,-sin(x)==0],x)
However Sage 6.4.1 Returns an empty list.
Mon, 16 Feb 2015 03:03:27 -0600http://ask.sagemath.org/question/25843/solve-behaviour-on-same-equation-twice/Answer by Thorsten for <p>Two questions:
<strong>The first one:</strong>
Solving an equation:</p>
<pre><code>solve(sin(x)==0,x)
</code></pre>
<p>gives the solution <code>[a=pi]</code>
but </p>
<pre><code>solve([sin(x)==0,sin(x)==0],x)
</code></pre>
<p>raises to the somehow better solution <code>[[a == pi*z425]]</code> Where is the difference between the two equations?</p>
<p><strong>A second one:</strong> A previous version of sage 5.something could solve </p>
<pre><code>solve([sin(x)==0,-sin(x)==0],x)
</code></pre>
<p>However Sage 6.4.1 Returns an empty list.</p>
http://ask.sagemath.org/question/25843/solve-behaviour-on-same-equation-twice/?answer=25899#post-id-25899I have now looked at the underlying code for solve. It turns out that if the first argument of solve is an equation or a list of just one equation the object function sage.symbolic.expression.Expression.solve is used. This explains why the output of
solve([sin(x)==0,sin(x)==0],x
and
solve([sin(x)==0],x)
may differ.
To force to get all solutions in the first case one can use
solve(sin(x)==0,x,to_poly_solve='force')
Another thing I've found out is that in the definition of the underlying maxima function solve is declared as
`solve ([eqn_1, …, eqn_n], [x_1, …, x_n])` so the number of equations should match the number of variables.
If one reformulates the problem to
solve(-sin(x)*sin(x)==0,x,to_poly_solve='force')
all solutions will be displayed.
However I liked the behaviour of previous Versions of sage
That is: If solve could't find a solution the original equation was returned. That way it was clear that there may exist solutions sage could not found. Mon, 23 Feb 2015 01:43:09 -0600http://ask.sagemath.org/question/25843/solve-behaviour-on-same-equation-twice/?answer=25899#post-id-25899