       Re: roots

• To: mathgroup at smc.vnet.net
• Subject: [mg29532] Re: roots
• Date: Sat, 23 Jun 2001 01:47:18 -0400 (EDT)
• Organization: Wolfram Research, Inc.
• References: <9gh5gs\$99v\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```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:= 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:= <<Algebra`RootIsolation`

In:= CountRoots[poly, {x, -Infinity, Infinity}]//Timing
Out= {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:= SetOptions[Root, ExactRootIsolation->True];

Now we compute the real roots of poly,

In:= rts=Table[Root[poly, i], {i, 14}];//Timing
Out= {2.55 Second, Null}

find their numerical approximations,

In:= nrs=N[rts, 25];//Timing
Out= {4.09 Second, Null}

and check which of them satisfy the equation x/20+Cos[x]==0

In:= #/20+Cos[#]&/@nrs

-24       -24       -24
-24
Out= {-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:= Drop[nrs, 1]//InputForm

Out//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,

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:=
> 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:=
> FindRoot[0.05*x + Cos[x] == 0, {x, -18.8966}]
> Out=
> {x -> -19.1433}
> In:=
> FindRoot[0.05*x + Cos[x] == 0, {x, {-18.394}}]
> Out=
> {x -> -18.4538}
> In:=
> FindRoot[0.05*x + Cos[x] == 0, {x, -13.4688}]
> Out=
> {x -> -13.4028}
> In:=
> FindRoot[0.05*x + Cos[x] == 0, {x, -11.6596}]
> Out=
> {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:= FindRoot[0.05 x  +Cos[x] == 0,{x,0}]
> >
> > Out= {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
> >
> >
> >
> >
> >
> >

```

• Prev by Date: FW: How to use Rules on Sequences?
• Next by Date: Re: Originality
• Previous by thread: Re: roots
• Next by thread: Re: Re: roots