MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Bug in Solve?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102946] Re: [mg102921] Bug in Solve?
  • From: Daniel Lichtblau <danl at wolfram.com>
  • Date: Thu, 3 Sep 2009 05:36:39 -0400 (EDT)
  • References: <200909020803.EAA03289@smc.vnet.net>

tonysin wrote:
> I am just trying to learn Mathematica. What am I doing wrong here?
> 
> I have a very simple equation:
> 
> x^3 - 15 x + 2 = 0
> 
> When I plot it in Mathematica 7,
> 
> ClearAll[*]
> f[x_] := x^3 - 15 x + 2
> Plot[f[x], {x, -5, 5}]
> 
> 
> it gives the expected graph of a cubic, with three real roots near -4,
> 0, and 4.
> 
> 
> When I NSolve it,
> 
> NSolve[f[x] == 0, x]
> 
> it gives
> 
> {{x -> -3.938}, {x -> 0.133492}, {x -> 3.80451}}
> 
> which is exactly what you would expect from the graph.
> 
> But when I Solve it
> 
> Solve[f[x] == 0, x]
> 
> it gives this mess
> 
> {{x -> 5/(-1 + 2 I Sqrt[31])^(1/3) + (-1 + 2 I Sqrt[31])^(
>     1/3)}, {x -> -((5 (1 + I Sqrt[3]))/(
>      2 (-1 + 2 I Sqrt[31])^(1/3))) -
>     1/2 (1 - I Sqrt[3]) (-1 + 2 I Sqrt[31])^(1/3)}, {x -> -((
>      5 (1 - I Sqrt[3]))/(2 (-1 + 2 I Sqrt[31])^(1/3))) -
>     1/2 (1 + I Sqrt[3]) (-1 + 2 I Sqrt[31])^(1/3)}}
> 
> 
> I don't know how it looks in your font, but that "I" in each solution
> is the imaginary i.  Solve is saying this equation has no real roots,
> even though the graph clearly shows that all three roots are real.
> 
> Can someone tell me if I am doing something wrong, or am I expecting
> something wrong, or if I just can't trust Mathematica?  Thanks for any
> help.

 From your list of possibilities, I'd choose the second one. Your cubic 
has no rational solutions. That takes it to what is called the casus 
irreducibilis.

http://mathworld.wolfram.com/CasusIrreducibilis.html
http://en.wikipedia.org/wiki/Casus_irreducibilis

If you want a different form of solution you can either convert radicals 
to trig/arctrigs, or else disable use of the radicals cubic formula. I 
show each below.

In[8]:= InputForm[Solve[x^3 - 15 x + 2==0, x] /.
         Rule[x,a_]:>Rule[x,TrigExpand[ComplexExpand[a]]]]
Out[8]//InputForm=
{{x -> Sqrt[5]*Cos[ArcTan[2*Sqrt[31]]/3] +
     Sqrt[15]*Sin[ArcTan[2*Sqrt[31]]/3]},
  {x -> -2*Sqrt[5]*Cos[ArcTan[2*Sqrt[31]]/3]},
  {x -> Sqrt[5]*Cos[ArcTan[2*Sqrt[31]]/3] -
     Sqrt[15]*Sin[ArcTan[2*Sqrt[31]]/3]}}

In[9]:= SetOptions[Roots,Cubics->False];

In[10]:= InputForm[Solve[x^3 - 15 x + 2==0, x]]
Out[10]//InputForm=
{{x -> Root[2 - 15*#1 + #1^3 & , 1, 0]},
  {x -> Root[2 - 15*#1 + #1^3 & , 2, 0]},
  {x -> Root[2 - 15*#1 + #1^3 & , 3, 0]}}


Daniel Lichtblau
Wolfram Research




  • Prev by Date: Re: Re: Replace in operators
  • Next by Date: Re: Bug in Solve?
  • Previous by thread: Re: Bug in Solve?
  • Next by thread: Re: Bug in Solve?