MathGroup Archive 2004

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

Search the Archive

RE : How Many Users Are Happy With FindRoot?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg49168] RE : [mg49150] How Many Users Are Happy With FindRoot?
  • From: "Florian Jaccard" <florian.jaccard at eiaj.ch>
  • Date: Tue, 6 Jul 2004 03:33:31 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Dear David,

I agree completely !
In my university of applied sciences, I let the RootSearch package on the
server, so the students use Ted Ersek's program !

It would be very useful to have this program in the next update !

Greetings
 
F.Jaccard


-----Message d'origine-----
De : David Park [mailto:djmp at earthlink.net] 
Envoyé : lundi, 5. juillet 2004 10:55
À : mathgroup at smc.vnet.net
Objet : [mg49150] How Many Users Are Happy With FindRoot?

Dear MathGroup,

I am continually being frustrated with the usage and performance of
FindRoot. Consider the problem of finding the roots lying between -3 Pi and
3 Pi of the following function.

f[x_] = Tan[x] - (x/2)^2*Tanh[x]; 

If we plot the function we can see why FindRoot runs into difficulty.

Plot[f[x], {x, -3*Pi, 3*Pi}, Frame -> True, 
   Axes -> {True, False}, PlotRange -> {-15, 15}]; 

If we pick starting values that are close enough we obtain the actual roots.

FindRoot[f[x], {x, {-7.5, -4, 2, 4, 7.5}}]
{x -> {-7.78813, -4.51891, 0., 4.51891, 7.78813}}

But I object to having to pick the initial values that closely. This is not
convenient and should not be necessary. If we pick the starting values to
just be in the middle of each branch, we only obtain one correct root out of
five.

FindRoot[f[x], {x, {-2*Pi, -Pi, 0, Pi, 2*Pi}}]
{x -> {-4.51891, 0., 0., 0., 4.51891}}

With the algorithm that Mathematica uses there is no reason we should expect
any better. The root searching is jumping from branch to branch. So let's
confine it to a single branch. We obtain an error message and an incorrect
answer.

FindRoot[f[x], {x, -2*Pi, -5*(Pi/2), -3*(Pi/2)}]
{x -> -5.36881}

It appears that in being ambitious enough to handle complex roots and
multiple equations FindRoot has skimped on finding real roots of real
equations. Mathematica should use more adaptive methods, perhaps using
bisection or other methods to locate roots in a fixed region. One should not
even have to give a starting point. These are probably the most common
applications of FindRoot and we should expect better performance.

There is a solution. There is a package in MathSource,
Enhancements`RootSearch`, by Ted Ersek. It is far better at handling roots
of real expressions.

Needs["Enhancements`RootSearch`"]

RootSearch[f[x] == 0, {x, -3*Pi, 3*Pi}]
{{x -> -7.78813}, {x -> -4.51891}, {x -> 0.}, {x -> 4.51891}, {x ->
7.78813}}

This shouldn't be buried away in MathSource. It should be part of
Mathematica proper, on an equal par with FindRoot. It should be the user's
first choice for finding real roots of real equations. One shouldn't spend
time fumbling with FindRoot and then searching outside Mathematica proper
for a solution.

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














  • Prev by Date: Re: Normal distribtion
  • Next by Date: Re: How Many Users Are Happy With FindRoot?
  • Previous by thread: Normal Product Distribution
  • Next by thread: Re: PlotLabel with assigned variables *and* on several lines