Message Boards Message Boards

Solve an elementary quadratic equation?

Dear All,

May someone explain what is wrong with the functions Solve[] and Reduce[] applications when they solve a very simple quadratic equation:

$x^2+x+1=0$

This equation has two complex solutions:

$\frac{-1 +\sqrt{3} i}{2}$ and $\frac{-1 -\sqrt{3} i}{2}.$

Both the functions Solve[] and Reduce[] give other solutions:

In[1]:= Solve[x^2 + x + 1 == 0]
Out[1]= {{x -> -(-1)^(1/3)}, {x -> (-1)^(2/3)}}

In[2]:= Reduce[x^2 + x + 1 == 0]
Out[2]= x == -(-1)^(1/3) || x == (-1)^(2/3)

The function NSolve[] gives correct solutions:

In[3]:= NSolve[x^2 + x + 1 == 0]
Out[3]= {{x -> -0.5 - 0.866025 I}, {x -> -0.5 + 0.866025 I}}
10 Replies

Thank you, Daniel! I found an exhaustive explanation on the $Wolfram MathWorld$ page:

Cube Root -- from Wolfram MathWorld

The schoolbook definition of the cube root of a negative number is (-x)^(1/3)=-(x^(1/3)). However, extension of the cube root into the complex plane gives a branch cut along the negative real axis for the principal value of the cube root as illustrated above. By convention, "the" (principal) cube root is therefore a complex number with positive imaginary part. As a result, the Wolfram Language and other symbolic algebra languages and programs that return results valid over the entire complex plane therefore return complex results for (-x)^(1/3). For example, in the Wolfram Language, ComplexExpand[(-1)^(1/3)] gives the result 1/2+isqrt(3)/2.

When considering a positive real number x, the Wolfram Language function CubeRoot[x], which is equivalent to Surd[x, 3], may be used to return the real cube root.

-1 is not really the traditional interpretation of (-1)^(1/3). More common is to work with the "principal root".

POSTED BY: Daniel Lichtblau

First two reasons are clear, correct and acceptable! But the last one is somewhat confusing, because cubic root of $-1$ in traditional interpretation is $-1$. So, in such interpretations solutions of this equation are: $1$ and $1$. In my opinion, this is a serious confusion for a lot of people...

While I don't know why it is designed like this, here are a few possible reasons:

1) The solving algorithms have to be as general as possible (not just quadratic).

2) It would be possible to add an extra layer of code checking for cases where there is a more elementary presentation that is also small, but this would slow things down. That could be problematical for someone doing a large calculation. Often the right design decision is to have the calculation do the fastest thing and then let the user decide if he wants a different presentation.

3) It is a matter of perspective of what is unusual. I say this because the roots of unity (which includes the roots of -1) is a classical topic in mathematics.

POSTED BY: Todd Rowland

You don't really have to map ComplexExpand, this will gave you the same result:

ComplexExpand[x/.Solve[x^2 + x + 1 == 0]]    

$$\left\{-\frac{1}{2}-\frac{i \sqrt{3}}{2},-\frac{1}{2}+\frac{i \sqrt{3}}{2}\right\}$$

ComplexExpand[Reduce[x^2 + x + 1 == 0]]

$$x=-\frac{1}{2}-\frac{i \sqrt{3}}{2}\lor x=-\frac{1}{2}+\frac{i \sqrt{3}}{2}$$

POSTED BY: Sam Carrettie

Wolfram Alpha finds the same solutions:

enter image description here

But, I used Step-by-step solution and found solution with the well known formula in the traditional form:

enter image description here

After that I used other variant of Step-by-step solution procedure and found the solution in the traditional form, too:

enter image description here enter image description here

So, it's not clear why the result is presented in "non-traditional" form?

In[2]:= {{x -> -(-1)^(1/3)}, {x -> (-1)^(2/3)}} // FullForm
Out[2]//FullForm= \!\(TagBox[StyleBox[RowBox[{"List", "[", RowBox[{RowBox[{"List", "[", RowBox[{"Rule", "[", RowBox[{"x", ",", 
RowBox[{"Times", "[", RowBox[{RowBox[{"-", "1"}], ",", RowBox[{"Power", "[", RowBox[{RowBox[{"-", "1"}], ",", 
RowBox[{"Rational", "[", RowBox[{"1", ",", "3"}], "]"}]}], "]"}]}], "]"}]}], "]"}], "]"}], ",", RowBox[{"List", "[", RowBox[{"Rule", "[", 
RowBox[{"x", ",", RowBox[{"Power", "[", RowBox[{RowBox[{"-", "1"}], ",", RowBox[{"Rational", "[", RowBox[{"2", ",", "3"}], "]"}]}], "]"}]}], "]"}], "]"}]}], "]"}],ShowSpecialCharacters->False,ShowStringCharacters->True,\NumberMarks->True], FullForm]\)

What is the reason to present solutions in an unusual "rational" form?

Posted 7 years ago

Both Solve[] and Reduce[] give the exact solutions in using rational numbers. NSolve[] gives a numerical approximation to the solution.

To see this use the functions N and ComplexExpand.

In[1]:= Map[N, {{x -> -(-1)^(1/3)}, {x -> (-1)^(2/3)}}, {2}]
In[2]:=Map[ComplexExpand, {{x -> -(-1)^(1/3)}, {x -> (-1)^(2/3)}}, {2}]
Out[1]= {{x -> -0.5 - 0.866025 I}, {x -> -0.5 + 0.866025 I}}
Out[2]= {{x -> {{x -> -(1/2) - (I Sqrt[3])/2}, {x -> -(1/2) + (I Sqrt[3])/2}}
POSTED BY: O Mirza
POSTED BY: Frank Kampas

Thank you, Frank! It's somewhat unusual solution presentation!

The solutions from Solve and Reduce are correct.

In[1]:= Solve[x^2 + x + 1 == 0]

Out[1]= {{x -> -(-1)^(1/3)}, {x -> (-1)^(2/3)}}

In[2]:= N[%]

Out[2]= {{x -> -0.5 - 0.866025 I}, {x -> -0.5 + 0.866025 I}}
POSTED BY: Frank Kampas
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract