[Date Index]
[Thread Index]
[Author Index]
Re: Emergent Help: NSolve Problems!
*To*: mathgroup at smc.vnet.net
*Subject*: [mg39791] Re: [mg39753] Emergent Help: NSolve Problems!
*From*: Daniel Lichtblau <danl at wolfram.com>
*Date*: Fri, 7 Mar 2003 03:39:09 -0500 (EST)
*References*: <200303060735.CAA09182@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
Chengzhou Wang wrote:
>
> Hi, guys
>
> I have some complicated polynomials, and I want to calculate its roots.
> HOwever, when I use NSolve, it creates some problems. Say a simple
> example:
>
> temp[s_]=s^10+10 s^9+ 10 s^8 +10 s^7 +10 s^6+ 10 s^5 +10 s^4 +1;
> NSolve[temp[s]==0, s]
>
> It will give:
>
> Out[4]= {{s -> -8.99998}, {s -> -1.06539}, {s -> -0.468828 - 0.886239 I},
>
> > {s -> -0.468828 + 0.886239 I}, {s -> -0.409684 - 0.469948 I},
>
> > {s -> -0.409684 + 0.469948 I}, {s -> 0.401048 - 0.312597 I},
>
> > {s -> 0.401048 + 0.312597 I}, {s -> 0.51015 - 0.878693 I},
>
> > {s -> 0.51015 + 0.878693 I}}
>
> But when I plug in the first number, which is "-8.99998", it should give a
> value close to zero. However, it gives:
>
> In[5]:= temp[-8.99998]
> Out[5]= -411.473
>
> The other roots seems OK. Does anyone know why? This is just a simple
> example. I have some more complicated polynomials to deal with.
>
> Thanks in advance!
>
> PS: Please reply (cc) to my email. I did not subscribe my email to the
> this email group!
>
> --
> Chengzhou
You are only plugging in the first 6 significant digits of the actual
solution, and error from this truncation is sufficiently large to make
the residual appear big.
temp[s_]=s^10+10 s^9+ 10 s^8 +10 s^7 +10 s^6+ 10 s^5 +10 s^4 +1;
In[14]:= soln = NSolve[temp[s]==0, s];
In[15]:= InputForm[First[soln]]
Out[15]//InputForm= {s -> -8.999981180131652}
In[16]:= temp[-8.999981180131652]
-7
Out[16]= -4.76837 10
If you plug in via rule replacement you do not risk this problem of
inadvertantly truncating needed digits.
In[17]:= InputForm[temp[s] /. soln]
Out[17]//InputForm=
{-4.76837158203125*^-7, 2.220446049250313*^-15,
2.581268532253489*^-15 - 1.5543122344752192*^-15*I,
2.581268532253489*^-15 + 1.5543122344752192*^-15*I,
1.8388068845354155*^-16 - 1.0234868508263162*^-16*I,
1.8388068845354155*^-16 + 1.0234868508263162*^-16*I,
1.968911145233676*^-16 - 2.2036409155767878*^-16*I,
1.968911145233676*^-16 + 2.2036409155767878*^-16*I,
-8.770761894538737*^-15 + 7.549516567451064*^-15*I,
-8.770761894538737*^-15 - 7.549516567451064*^-15*I}
By the way, if you take into account the magnitude of that solution
(around 10^1), the degree of the equation (10), magnitude of coefficient
sizes (1 for lead, 10 for the rest), and the fact that the error is
around the 7th digit, you can estimate that the error in residual
computation may be as large as roughly 10^(-6)*10^10. So obtaining a
residual around O(10^3) using the truncated solution is not surprising.
Daniel Lichtblau
Wolfram Research
Prev by Date:
**Re: Emergent Help: NSolve Problems!**
Next by Date:
**Re: Emergent Help: NSolve Problems!**
Previous by thread:
**Re: Emergent Help: NSolve Problems!**
Next by thread:
**Re: Emergent Help: NSolve Problems!**
| |