MathGroup Archive 2009

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

Search the Archive

Re: Bug in Solve?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102948] Re: [mg102921] Bug in Solve?
  • From: Leonid Shifrin <lshifr at gmail.com>
  • Date: Thu, 3 Sep 2009 05:37:01 -0400 (EDT)
  • References: <200909020803.EAA03289@smc.vnet.net>

Hi,

don't worry, you can trust Mathematica, at least in your case. Don't get
scared by the presence of I in front. The final results are real. This is
easy to see numerically:

In[1] =
result = {{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)}};

In[2] = N[result]

Out[2] ={{x->3.80451-4.44089*10^-16 I},{x->-3.938+0.
I},{x->0.133492+4.44089*10^-16 I}}

You can also see this analytically by asking Mathematica to verify that the
answers
have no imaginary parts:

In[3]:=
 r1 =Part[x/.result,1]

Out[3]=
5/(-1+2 I Sqrt[31])^(1/3)+(-1+2 I Sqrt[31])^(1/3)

In[4]:=
r2 =Part[x/.result,2]

Out[4]=
-((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)

In[5]:=
r3 = Part[x/.result,3]

Out[5]=
-((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)

Now,

In[6]:= FullSimplify[Arg[r1]]

Out[6]= 0

In[7]:= FullSimplify[Arg[r2]]

Out[7]= \[Pi]

In[8]:= FullSimplify[Arg[r3]]

Out[8]= 0

Getting the absolute values of these roots is however harder. I only managed
to get
an analytical expression for the first one, by asking Mathematica to compute
Abs and Arg
of each of the two terms in the sum and then combining the results:

5/(-1+2 I Sqrt[31])^(1/3)+(-1+2 I Sqrt[31])^(1/3) == Sqrt[5] (Cos[1/3
ArcTan[2 Sqrt[31]]]+Sqrt[3] Sin[1/3 ArcTan[2 Sqrt[31]]])

(it is interesting that while I am certain that the result is correct,   I
was unable to  verify this identity with FullSimplify). For the other two
roots, my feeling is  that one has to use numerics.

Hope this helps.

Regards,
Leonid



On Wed, Sep 2, 2009 at 12:03 PM, tonysin <a2mgoog at yahoo.com> 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.
>
>



  • Prev by Date: Re: Bug in Solve?
  • Next by Date: Re: Re: Faster alternative to AppendTo?
  • Previous by thread: Re: Re: Bug in Solve?
  • Next by thread: Re: Bug in Solve?