MathGroup Archive 2001

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

Search the Archive

RE: roots

  • To: mathgroup at smc.vnet.net
  • Subject: [mg29403] RE: [mg29380] roots
  • From: "David Park" <djmp at earthlink.net>
  • Date: Sat, 16 Jun 2001 22:43:51 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Maarten,

In a problem like this, FindRoot needs some help.

f[x_] := 0.05x + Cos[x]

Look for the turning points in the function.

f'[x]
0.05 - Sin[x]

The turning points will occur at ArcSin[0.05] +/- 2n Pi and
(Pi-ArcSin[0.05])+/- 2n Pi. This generates the turning points over a
somewhat wider range than we need.

tpts = Sort[Flatten[Table[{ArcSin[0.05] + 2*Pi*n,
       Pi - ArcSin[0.05] + 2*Pi*n}, {n, -4, 3}]]];

Between successive turning points we have monotonic functions. If we use the
turning points as limits and start at the midpoint, FindRoot just might get
the root. The following generates the second argument for FindRoot using
this approach.

Partition[tpts, 2, 1]
rootspecs = {x, Plus @@ #/2, First[#], Last[#]} & /@ %

This is the second item on a list of 15 generated rootspecs.

{x, -20.4204, -22.0412, -18.7995}

I then Map FindRoot onto this list of rootspecs. I used the Check command to
weed out cases where FindRoot went outside the specified domain. You obtain
error messages for those cases but no returned value.

rootsols = Check[FindRoot[f[x], #], Unevaluated[Sequence[]]] & /@ rootspecs

{{x -> -19.14330451998876}, {x -> -18.453754054424195},
  {x -> -13.402772345741981},
  {x -> -11.615238480230595},
  {x -> -7.471140913774326}, {x -> -4.963166669457849},
  {x -> -1.4959299134300144},
  {x -> 1.6535692756905693}, {x -> 4.486156653004949},
  {x -> 8.280873579694441}, {x -> 10.446026873732087},
  {x -> 14.98402202417216}, {x -> 16.323959951197935}}

We could also have weeded our the domains with no roots by checking if f
evaluated at the turning points changed signs.

It would be nice if FindRoot had an option or mode such that it wouldn't
quit when it goes outside the specified domain, but used a bisection step
and resumed from the midpoint of the resulting domain. I think this would
generally be of value when we were dealing with monotonic functions in the
specified range.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/


> From: maarten.vanderburgt at icos.be [mailto:maarten.vanderburgt at icos.be]
To: mathgroup at smc.vnet.net
>
> 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
>



  • Prev by Date: Roots of a function
  • Next by Date: Re: pattern matching quirks
  • Previous by thread: Re: roots
  • Next by thread: Re: roots