[Date Index]
[Thread Index]
[Author Index]
How Many Users Are Happy With FindRoot?
*To*: mathgroup at smc.vnet.net
*Subject*: [mg49150] How Many Users Are Happy With FindRoot?
*From*: "David Park" <djmp at earthlink.net>
*Date*: Mon, 5 Jul 2004 04:54:31 -0400 (EDT)
*Sender*: owner-wri-mathgroup at wolfram.com
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 enought 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: Periodic Table of Elements (Chemistry)**
Next by Date:
**Re: Univers font for PDF files**
Previous by thread:
**Re: Periodic Table of Elements (Chemistry)**
Next by thread:
**Re: How Many Users Are Happy With FindRoot?**
| |