Re: using FindRoot to find multiple answers in a domain?

• To: mathgroup at smc.vnet.net
• Subject: [mg69114] Re: [mg69059] using FindRoot to find multiple answers in a domain?
• From: "Carl K. Woll" <carlw at wolfram.com>
• Date: Wed, 30 Aug 2006 06:34:01 -0400 (EDT)
• References: <200608290725.DAA28991@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```akil wrote:
> I want to find all answers that exist in a certain domain, but FindRoot
> gives only the first answer it finds (Using other methods like Solve,Reduce
> etc takes too long, so Im stuck with using FindRoot). I give the problem I
> have by example, the functions I use are really complex, but by solving the
> problem for the example, I could solve t for the complex part.
>
> Example:
>
> Finding all intersections of Cos[x] and Sin[x] in the domain [0,10Pi]
>
> Doing:
> FindRoot[Cos[antwoord] == Sin[antwoord], {antwoord, 0, 0, 10Pi}]
>
> FindRoot[Cos[antwoord] == Sin[antwoord], {antwoord, %, %, 10Pi}]
>
> does not work the second FindRoot gives the exact same answer back. So using
> this in a loop to find all intersections does not work.
>
> Doing FindRoot[Cos[antwoord] == Sin[antwoord], {antwoord, %+0.01, %+0.01,
> 10Pi}] instead, also does not work.
>
> Any way to find all intersections in a specified domain?
>
> Akil
>

If the only special functions contained in your equation are
trigonometric and exponential, then you can try interval methods from
the IntervalRoots package. For your example:

Needs["NumericalMath`IntervalRoots`"]

In[2]:=
IntervalNewton[Cos[x]-Sin[x],x,Interval[{0,10Pi}],10^-6,MaxRecursion->10]

Out[2]=
Interval[{0.785398, 0.785398}, {3.92699, 3.92699}, {7.06858, 7.06858},
{10.2102, 10.2102}, {13.3518, 13.3518}, {16.4934, 16.4934}, {19.635,
19.635}, {22.7765, 22.7765}, {25.9181, 25.9181}, {29.0597, 29.0597}]

The nice thing about interval methods is that all roots are guaranteed
to lie in the returned Interval object, although some of the
subintervals may not contain any roots.

Carl Woll
Wolfram Research

```

• Prev by Date: Re: Writing and reading a comma delimited or tab delimited file one record at a time
• Next by Date: Re: using FindRoot to find multiple answers in a domain?
• Previous by thread: using FindRoot to find multiple answers in a domain?
• Next by thread: Re: using FindRoot to find multiple answers in a domain?