Re: Solving 3d degree polynomial

• To: mathgroup at smc.vnet.net
• Subject: [mg90817] Re: Solving 3d degree polynomial
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Fri, 25 Jul 2008 06:15:07 -0400 (EDT)
• Organization: The Open University, Milton Keynes, UK
• References: <g69fpi\$icu\$1@smc.vnet.net>

Floris Zoutman wrote:

> I have a function
> f(q)=2n(n+1)q^3-(1+t)(2n+1)q^2+2(t-(n+1)A)q+(1+t)A
> in which n>1, -1<A<1, and 0<t<1 are parameters. If I fill in appropriate values for the parameters before:
> Solve[Y==0,q] it gives me 3 real roots.
> If instead I ask for a symbolic solution before filling in the same values of the parameters, Mathematica gives almost the same roots, but now there is an imaginary part to the solution. It is of the order 10^(-16). Why are the roots complex if I find a solution before filling in parameters, but real if I fill in parameters before finding the solution?

The tiny -- negligible -- spurious imaginary (or real) parts are due to
rounding error when parameters are replaced by numerical values into the
large symbolic expressions returned by Solve[].

Use *Chop[]* to discard tiny floating-point values or *ComplexExpand[]*
to simplify symbolically.

In[1]:= expr =
2*n*(n + 1)*q^3 - (1 + t)*(2*n + 1)*q^2
+ 2*(t - (n +1)*A)*q + (1 + t)*A;
sols = Solve[expr == 0, q];
sols /. {n -> 2, A -> 0, t -> 1/2}
N[%]
Chop[%]
ComplexExpand /@ (sols /. {n -> 2, A -> 0, t -> 1/2})
N[%]
Chop[%]

Out[3]=
5    1   1  135                  1/3
{{q -> -- + -- (- (--- + 54 I Sqrt[11]))    +
24   36  2   4

9
-------------------------------},
2/3  135                 1/3
8 2    (--- + 54 I Sqrt[11])
4

5    1                   1  135                  1/3
{q -> -- - -- (1 - I Sqrt[3]) (- (--- + 54 I Sqrt[11]))    -
24   72                  2   4

9 (1 + I Sqrt[3])
--------------------------------},
2/3  135                 1/3
16 2    (--- + 54 I Sqrt[11])
4

5    1                   1  135                  1/3
{q -> -- - -- (1 + I Sqrt[3]) (- (--- + 54 I Sqrt[11]))    -
24   72                  2   4

9 (1 - I Sqrt[3])
--------------------------------}}
2/3  135                 1/3
16 2    (--- + 54 I Sqrt[11])
4

Out[4]=
-17
{{q -> 0.432178 - 2.77556 10    I},

-17             -17
{q -> -2.77556 10    - 4.16334 10    I},

-17
{q -> 0.192822 + 9.71445 10    I}}

Out[5]= {{q -> 0.432178}, {q -> 0}, {q -> 0.192822}}

Out[6]=
5    1     1        8 Sqrt[11]
{{q -> -- + - Cos[- ArcTan[----------]]},
24   4     3            5

5    1     1        8 Sqrt[11]
{q -> -- - - Cos[- ArcTan[----------]] -
24   8     3            5

1             1        8 Sqrt[11]
- Sqrt[3] Sin[- ArcTan[----------]]},
8             3            5

5    1     1        8 Sqrt[11]
{q -> -- - - Cos[- ArcTan[----------]] +
24   8     3            5

1             1        8 Sqrt[11]
- Sqrt[3] Sin[- ArcTan[----------]]}}
8             3            5

Out[7]=
-17
{{q -> 0.432178}, {q -> 2.77556 10   }, {q -> 0.192822}}

Out[8]= {{q -> 0.432178}, {q -> 0}, {q -> 0.192822}}

Regards,
-- Jean-Marc

• Prev by Date: Re: Reading Directive Values
• Next by Date: Comments on online documentation
• Previous by thread: Re: Solving 3d degree polynomial
• Next by thread: Function Programming Problems