ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 22 Jun 2020 18:52:47 +0200solve: Possible bug?https://ask.sagemath.org/question/51910/solve-possible-bug/Hello,
This question is relevant to Question #2 in the topic "desolve: wrong solution?!". If **desolve** is using **solve** internally when initial conditions are invoked to find the constants after obtaining the general solution, perhaps this is where the problem lies.
Consider the following expression
a=var('a')
f=-1/2*(I*sqrt(3)*2^(1/3) - 2^(1/3))/(-2*a - 1)^(1/3)
sol=solve(f==-2,a);show(sol)
sol is [a == (-5/8)]
Now, if we plug that back in f,
check=f.subs(sol).n();print(check`)
this gives 1.00000000000000 - 1.73205080756888*I, where it ought to give -2 (if there is a solution)
And I tried this with Mathematica also
Solve[-1/2 (I Sqrt[3] 2^(1/3) - 2^(1/3))/(-2 a - 1)^(1/3) == -2, a]
It returns an empty list {} for this, indicating that there is no solution.
What is wrong with Sage's **solve** function here?
Update:
I tried **solve** with "sympy" agorithm. It agreed with Mathematica. It looks like there is a problem with MaximaThu, 11 Jun 2020 19:16:47 +0200https://ask.sagemath.org/question/51910/solve-possible-bug/Answer by dsejas for <p>Hello,</p>
<p>This question is relevant to Question #2 in the topic "desolve: wrong solution?!". If <strong>desolve</strong> is using <strong>solve</strong> internally when initial conditions are invoked to find the constants after obtaining the general solution, perhaps this is where the problem lies. </p>
<p>Consider the following expression</p>
<pre><code>a=var('a')
f=-1/2*(I*sqrt(3)*2^(1/3) - 2^(1/3))/(-2*a - 1)^(1/3)
sol=solve(f==-2,a);show(sol)
</code></pre>
<p>sol is [a == (-5/8)]</p>
<p>Now, if we plug that back in f,</p>
<pre><code>check=f.subs(sol).n();print(check`)
</code></pre>
<p>this gives 1.00000000000000 - 1.73205080756888*I, where it ought to give -2 (if there is a solution)</p>
<p>And I tried this with Mathematica also </p>
<pre><code>Solve[-1/2 (I Sqrt[3] 2^(1/3) - 2^(1/3))/(-2 a - 1)^(1/3) == -2, a]
</code></pre>
<p>It returns an empty list {} for this, indicating that there is no solution.</p>
<p>What is wrong with Sage's <strong>solve</strong> function here?</p>
<p>Update:
I tried <strong>solve</strong> with "sympy" agorithm. It agreed with Mathematica. It looks like there is a problem with Maxima</p>
https://ask.sagemath.org/question/51910/solve-possible-bug/?answer=51913#post-id-51913Hello, @curios_mind!
I think you found an interesting problem. My appreciation is that $a=-5/8$ is the correct answer (up to complex representation). Let me explain...
Observe the numerator of your expression $f$ can be written as
$$\sqrt[3]{2}\left(\frac{1}{2}-i\frac{\sqrt{3}}{2}\right)=\sqrt[3]{2}\bigl(\cos(\pi/3)-i\sin(\pi/3)\bigr)$$
which is nothing more than one of the possible solutions of the equation $x^3=-2$, or alternatively, this is one of the possible values of $\sqrt[3]{-2}$ in the complex plain.
Now, consider the denominator for $a=-5/8$:
$$\left(-2\left(\frac{-5}{8}\right)-1\right)^{1/3}=\sqrt[3]{\frac{1}{4}}=\sqrt[3]{\frac{1}{2^2}}$$
So, what $f$ is for $a=-5/8$ turns out to be
$$\frac{\sqrt[3]{-2}}{\sqrt[3]{\frac{1}{2^2}}}=\sqrt[3]{-2}\sqrt[3]{2^2}=\sqrt[3]{-2^3}=-2$$
So the original equation is satisfied.
If you want to be more formal,
$$\frac{\sqrt[3]{-2}}{\sqrt[3]{\frac{1}{2^2}}}=\sqrt[3]{-2}\sqrt[3]{4}=\sqrt[3]{2}\bigl(\cos(\pi/3)-i\sin(\pi/3)\bigr)\sqrt[3]{4}\bigl(\cos(\pi/3)+i\sin(\pi/3)\bigr)=\sqrt[3]{8}(\cos^2(\pi/3)+\sin^2(\pi/3))=\sqrt[3]{8}=2$$
Of course, as you can see, this depends on you choosing the correct representation of complex numbers like $\sqrt[3]{-4}$. If you choose wrongly, for example, $\sqrt[3]{-4}=\sqrt[3]{4}\bigl(\cos(\pi/3)-i\sin(\pi/3)\bigr)$, you won't get the answer, but other possible value for $f$ in the complex plain. That is what happened when you subs $a=-5/8$: Sage didn't choose the correct complex representations of some cube roots.
In summary, the problem is that you have a complex equation with ambiguous numbers like cube roots. Sage and Maxima did what they could, which is to give you a correct answer, up to complex representation. In this case, it is up to you to decide if this is what you wanted or not. If this is not the solution you expected, or you want an alternative solution, I recommend you to rewrite the cube roots explicitly as one of their possible complex number values.
I hope this helps!Fri, 12 Jun 2020 07:40:04 +0200https://ask.sagemath.org/question/51910/solve-possible-bug/?answer=51913#post-id-51913Comment by dsejas for <p>Hello, <a href="/users/23477/curios_mind/">@curios_mind</a>!</p>
<p>I think you found an interesting problem. My appreciation is that $a=-5/8$ is the correct answer (up to complex representation). Let me explain...</p>
<p>Observe the numerator of your expression $f$ can be written as
$$\sqrt[3]{2}\left(\frac{1}{2}-i\frac{\sqrt{3}}{2}\right)=\sqrt[3]{2}\bigl(\cos(\pi/3)-i\sin(\pi/3)\bigr)$$
which is nothing more than one of the possible solutions of the equation $x^3=-2$, or alternatively, this is one of the possible values of $\sqrt[3]{-2}$ in the complex plain.</p>
<p>Now, consider the denominator for $a=-5/8$:
$$\left(-2\left(\frac{-5}{8}\right)-1\right)^{1/3}=\sqrt[3]{\frac{1}{4}}=\sqrt[3]{\frac{1}{2^2}}$$</p>
<p>So, what $f$ is for $a=-5/8$ turns out to be
$$\frac{\sqrt[3]{-2}}{\sqrt[3]{\frac{1}{2^2}}}=\sqrt[3]{-2}\sqrt[3]{2^2}=\sqrt[3]{-2^3}=-2$$
So the original equation is satisfied.</p>
<p>If you want to be more formal,
$$\frac{\sqrt[3]{-2}}{\sqrt[3]{\frac{1}{2^2}}}=\sqrt[3]{-2}\sqrt[3]{4}=\sqrt[3]{2}\bigl(\cos(\pi/3)-i\sin(\pi/3)\bigr)\sqrt[3]{4}\bigl(\cos(\pi/3)+i\sin(\pi/3)\bigr)=\sqrt[3]{8}(\cos^2(\pi/3)+\sin^2(\pi/3))=\sqrt[3]{8}=2$$</p>
<p>Of course, as you can see, this depends on you choosing the correct representation of complex numbers like $\sqrt[3]{-4}$. If you choose wrongly, for example, $\sqrt[3]{-4}=\sqrt[3]{4}\bigl(\cos(\pi/3)-i\sin(\pi/3)\bigr)$, you won't get the answer, but other possible value for $f$ in the complex plain. That is what happened when you subs $a=-5/8$: Sage didn't choose the correct complex representations of some cube roots.</p>
<p>In summary, the problem is that you have a complex equation with ambiguous numbers like cube roots. Sage and Maxima did what they could, which is to give you a correct answer, up to complex representation. In this case, it is up to you to decide if this is what you wanted or not. If this is not the solution you expected, or you want an alternative solution, I recommend you to rewrite the cube roots explicitly as one of their possible complex number values.</p>
<p>I hope this helps!</p>
https://ask.sagemath.org/question/51910/solve-possible-bug/?comment=52150#post-id-52150Hello, @curios_mind! If there is indeed a problem with Mathematica, it is unfortunate that we can't fix it ourselves or even see what the problem actually is, due to the closed source nature of that software.
My personal vision is that there are adequate tools for every type of work. In this case, SageMath shined and Mathematica failed us, but perhaps there is some other situation where Mathematica shines and Sage is not up to the challenge.
However, there is one thing we can be sure of: The fact of Sage being open-source is one of its best features, while Mathematica being closed-source is one of its biggest drawbacks. For example, if there is something Sage can't do, you can write your own code to implement that functionality; in Mathematica is not always possible,Mon, 22 Jun 2020 18:52:47 +0200https://ask.sagemath.org/question/51910/solve-possible-bug/?comment=52150#post-id-52150Comment by curios_mind for <p>Hello, <a href="/users/23477/curios_mind/">@curios_mind</a>!</p>
<p>I think you found an interesting problem. My appreciation is that $a=-5/8$ is the correct answer (up to complex representation). Let me explain...</p>
<p>Observe the numerator of your expression $f$ can be written as
$$\sqrt[3]{2}\left(\frac{1}{2}-i\frac{\sqrt{3}}{2}\right)=\sqrt[3]{2}\bigl(\cos(\pi/3)-i\sin(\pi/3)\bigr)$$
which is nothing more than one of the possible solutions of the equation $x^3=-2$, or alternatively, this is one of the possible values of $\sqrt[3]{-2}$ in the complex plain.</p>
<p>Now, consider the denominator for $a=-5/8$:
$$\left(-2\left(\frac{-5}{8}\right)-1\right)^{1/3}=\sqrt[3]{\frac{1}{4}}=\sqrt[3]{\frac{1}{2^2}}$$</p>
<p>So, what $f$ is for $a=-5/8$ turns out to be
$$\frac{\sqrt[3]{-2}}{\sqrt[3]{\frac{1}{2^2}}}=\sqrt[3]{-2}\sqrt[3]{2^2}=\sqrt[3]{-2^3}=-2$$
So the original equation is satisfied.</p>
<p>If you want to be more formal,
$$\frac{\sqrt[3]{-2}}{\sqrt[3]{\frac{1}{2^2}}}=\sqrt[3]{-2}\sqrt[3]{4}=\sqrt[3]{2}\bigl(\cos(\pi/3)-i\sin(\pi/3)\bigr)\sqrt[3]{4}\bigl(\cos(\pi/3)+i\sin(\pi/3)\bigr)=\sqrt[3]{8}(\cos^2(\pi/3)+\sin^2(\pi/3))=\sqrt[3]{8}=2$$</p>
<p>Of course, as you can see, this depends on you choosing the correct representation of complex numbers like $\sqrt[3]{-4}$. If you choose wrongly, for example, $\sqrt[3]{-4}=\sqrt[3]{4}\bigl(\cos(\pi/3)-i\sin(\pi/3)\bigr)$, you won't get the answer, but other possible value for $f$ in the complex plain. That is what happened when you subs $a=-5/8$: Sage didn't choose the correct complex representations of some cube roots.</p>
<p>In summary, the problem is that you have a complex equation with ambiguous numbers like cube roots. Sage and Maxima did what they could, which is to give you a correct answer, up to complex representation. In this case, it is up to you to decide if this is what you wanted or not. If this is not the solution you expected, or you want an alternative solution, I recommend you to rewrite the cube roots explicitly as one of their possible complex number values.</p>
<p>I hope this helps!</p>
https://ask.sagemath.org/question/51910/solve-possible-bug/?comment=51990#post-id-51990Thanks. I see. After you, I did it by hand also. I calculated all 3 roots of the numerator, and all 3 roots of the denominator. I checked combinations that reveal real valued results and 3 combination gave -2. So, a=-5/8 is in fact a solution.
It looks that then Mathematica has a problem :)Sun, 14 Jun 2020 23:38:02 +0200https://ask.sagemath.org/question/51910/solve-possible-bug/?comment=51990#post-id-51990