MathGroup Archive 2006

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

Search the Archive

Re: Getting the (correct) roots of a polynomial

  • To: mathgroup at smc.vnet.net
  • Subject: [mg67296] Re: Getting the (correct) roots of a polynomial
  • From: Peter Pein <petsie at dordos.net>
  • Date: Fri, 16 Jun 2006 00:27:34 -0400 (EDT)
  • References: <e6opm6$s9l$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

nickc8514 at yahoo.com schrieb:
> Hi, I have what seems like a simple question, but I haven't been able
> to find a satisfactory answer.  I wish to find the complex roots of the
> quartic polynomial
> 
> (z - I u) z (z + I v) (z - I v) + (g^2) z (z + I v) + (g^2) z (z - I v)
> + (g^2)(z + I v)(z - I v)
> 
...
> TestVals = {u -> 1/10,  v -> 10^4, g -> 1, w -> 10^7}
...
> Soln = Solve[Poly==0,z];
> Table[N[(Poly /. Soln[[j]]) /. TestVals],{j,1,4}]
> 
> The values returned were of order 10^9.  I also tried plugging in the
> parameter values first (i.e. applying the rules in TestVals) before
> using Solve, and this also produced bad solutions.
>

Hi Nick,

  it is a FAQ, that people ask for exact results, while using inexact numbers. Sometimes it is not possible to do exact calculation but in this case it is. And it is not too slow to wait for:

In[1]:=
Timing[
   poly = (z - I*u)*z*(z + I*v)*(z - I*v) + g^2*z*(z + I*v) + g^2*z*(z - I*v) +
     g^2*(z + I*v)*(z - I*v);
   soln = Solve[poly == 0, z];
   test = {u -> 1/10, v -> 10^4, g -> 1};
   Simplify[poly /. soln /. test]
]

Out[1]=
{3.719 Second,{0,0,0,0}}

In[2]:=
ClearCache[];
Timing[(Simplify[poly /. z -> #1] & ) /@ (ruhts = (Root[Function[z, Evaluate[poly]], #1] & ) /@
       Range[4]) /. test]

Out[3]=
{0.01499999999999968*Second, {0, 0, 0, 0}}

As a rule of thumb: If you want exact results, use exact numbers where possible.

hth,
   Peter


  • Prev by Date: Re: 3D plots
  • Next by Date: Re: Re: Determining continuity of regions/curves from inequalities
  • Previous by thread: Re: Getting the (correct) roots of a polynomial
  • Next by thread: More puzzles on Check[ ], Off[ ] , Indeterminate , Overflow[ ] , etc.