Re: Re: roots
- To: mathgroup at smc.vnet.net
- Subject: [mg29544] Re: [mg29532] Re: roots
- From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
- Date: Sun, 24 Jun 2001 02:00:58 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
In fact the extra root of poly lies outside the range -20<x<20:
In[2]:=
<<Algebra`RootIsolation`
In[3]:=
CountRoots[poly, {x, -20,20}]//Timing
Out[3]=
{4.98333 Second,13}
The roots can also be found by using InequalitySolve, though this seems to
take longer than your method:
In[5]:=
Timing[N[InequalitySolve[poly == 0 && -20 < x < 20, x]]]
Out[5]=
{68.8833 Second, x == -19.1433 || x == -18.4538 ||
x == -13.4028 || x == -11.6152 || x == -7.47114 ||
x == -4.96317 || x == -1.49593 || x == 1.65357 ||
x == 4.48616 || x == 8.28087 || x == 10.446 ||
x == 14.984 || x == 16.324}
Of course one would still need to verify that they do approximate the roots
of the original equation.
--
Andrzej Kozlowski
Toyama International University
JAPAN
http://platon.c.u-tokyo.ac.jp/andrzej/
http://sigma.tuins.ac.jp/~andrzej/
on 6/23/01 2:47 PM, Adam Strzebonski at adams at wolfram.com wrote:
> One can get approximations of the roots by approximating
> Cos[x] with initial terms of its Taylor series (we don't
> get a proof that there are only 13 solutions, but we get
> 13 good approximations of solutions).
>
> In[1]:= poly=x/20+Normal[Series[Cos[x], {x, 0, 100}]];
>
> We need to find approximations of real roots of poly.
> I don't want to use NSolve here, because it tries to find
> all complex roots. For high degree polynomials, if the number
> of real roots is much smaller than the degree, it is faster
> to isolate the real roots using exact methods than to find
> all the complex roots numerically.
>
> We count the real roots first, so that we don't create any
> nonreal Root objects: the exact isolation of nonreal roots
> is slow.
>
> In[2]:= <<Algebra`RootIsolation`
>
> In[3]:= CountRoots[poly, {x, -Infinity, Infinity}]//Timing
> Out[3]= {4.58 Second, 14}
>
> The default root isolation method is based on computing numerical
> approximations of all complex roots, so we need to change it.
>
> In[4]:= SetOptions[Root, ExactRootIsolation->True];
>
> Now we compute the real roots of poly,
>
> In[5]:= rts=Table[Root[poly, i], {i, 14}];//Timing
> Out[5]= {2.55 Second, Null}
>
> find their numerical approximations,
>
> In[6]:= nrs=N[rts, 25];//Timing
> Out[6]= {4.09 Second, Null}
>
> and check which of them satisfy the equation x/20+Cos[x]==0
>
> In[7]:= #/20+Cos[#]&/@nrs
>
> -24 -24 -24
> -24
> Out[7]= {-1.65832863853270619235960, 0. 10 , 0. 10 , 0. 10 , 0.
> 10 ,
>
> -24 -24 -25 -25 -24 -24
> -24
>> 0. 10 , 0. 10 , 0. 10 , 0. 10 , 0. 10 , 0. 10 , 0. 10 ,
>
> -24 -24
>> 0. 10 , 0. 10 }
>
> Here are the 13 roots of x/20+Cos[x]==0
>
> In[8]:= Drop[nrs, 1]//InputForm
>
> Out[8]//InputForm=
> {-19.14330451806538667880986570564361032264`25,
> -18.45375405471092374532000068940118616129`25,
> -13.40277147194542547333729073937332385855`25,
> -11.61523861449023313015711996574049279572`25,
> -7.47114091373322226214343658073674762609`25,
> -4.96316768881794772985279294265779822657`25,
> -1.49592991327175815500746007291204533048`25,
> 1.65356927612222660064136483786947282365`25,
> 4.48615628721076275861724952418303472826`25,
> 8.28087358013665167538895805572450457893`25,
> 10.44602686367261821801301652620945695607`25,
> 14.98402202436415195182719178207711523666`25,
>
> 16.32395994938114931284258124546947389267`25}
>
>
> Best Regards,
>
> Adam Strzebonski
> Wolfram Research
>
>
> Andrzej Kozlowski wrote:
>>
>> It seems to me that the easiest way is this. First of all, we know that the
>> roots will all be between -20<x<20 (since Abs[Cos[x]]<1). So start with
>> In[5]:=
>> Plot[0.05 x +Cos[x],{x,-20,20}]
>>
>> You will see all 13-teen roots. Now click on the graphic to select it.
>> Holding the Command key down on the Mac (I guess the Control key under
>> Windows?) click on the individual points where the curve intersects the x
>> axis and Copy. Paste the result into the FindRoot command (removing the
>> y-value) as below. You will get pretty good approximations to all the roots.
>> Here are just the first four values obtained in this way:
>>
>> In[7]:=
>> FindRoot[0.05*x + Cos[x] == 0, {x, -18.8966}]
>> Out[7]=
>> {x -> -19.1433}
>> In[8]:=
>> FindRoot[0.05*x + Cos[x] == 0, {x, {-18.394}}]
>> Out[8]=
>> {x -> -18.4538}
>> In[9]:=
>> FindRoot[0.05*x + Cos[x] == 0, {x, -13.4688}]
>> Out[9]=
>> {x -> -13.4028}
>> In[10]:=
>> FindRoot[0.05*x + Cos[x] == 0, {x, -11.6596}]
>> Out[10]=
>> {x -> -11.6152}
>>
>> --
>> Andrzej Kozlowski
>> Toyama International University
>> JAPAN
>>
>> http://platon.c.u-tokyo.ac.jp/andrzej/
>> http://sigma.tuins.ac.jp/~andrzej/
>>
>> on 01.6.16 3:47 PM, maarten.vanderburgt at icos.be at
>> maarten.vanderburgt at icos.be wrote:
>>
>>> hallo,
>>>
>>> What is the easiest solution to finding the 13 (real) roots of 0.05 x +
>>> Cos[x] == 0.
>>> I can be easily seen that there are 13 roots by plotting:
>>> Plot[{0.05 x,-Cos[x]},{x,-30,30}]
>>> but this is not sufficient for finding accurate numerical values.
>>>
>>> FindRoot only gives one value and it is hard to predict which root it will
>>> find with a specified start value:
>>>
>>> In[83]:= FindRoot[0.05 x +Cos[x] == 0,{x,0}]
>>>
>>> Out[83]= {x -> -4.96317}
>>>
>>> There are three roots closer to 0 then x == -4.96317
>>>
>>> An NSolve only works for polynomials.
>>>
>>> Is there no simple way to find all roots of such an equation, eventually
>>> within a specified range.
>>>
>>> thanks for your help
>>>
>>> Maarten van der Burgt
>>> Leuven
>>>
>>>
>>>
>>>
>>>
>>>
>
>