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: [mg49181] RE: How Many Users Are Happy With FindRoot?
  • From: "David Park" <djmp at earthlink.net>
  • Date: Tue, 6 Jul 2004 03:34:10 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Tom,

Your routine looks nice enough, but still most users aren't going to think
of it. One of my beliefs is that Mathematica is not so much a toolbox for
doing mathematics as a meta toolbox for making the tools to do mathematics.
But I make an exception for FindRoot. I think it should be more robust and
have simpler usage out of the box for real roots of real functions. This is
a bread and butter function.

The completion of Andrzej's routine is

<< "NumericalMath`IntervalRoots`"

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

intervals =
    IntervalBisection[f[x], x, Interval[{-3*N[Pi], 3*N[Pi]}],
   0.1, MaxRecursion -> 10];

MapThread[FindRoot[f[x], {x, Plus @@ #/2}] &, {List @@ intervals}]
{{x -> -7.78813}, {x -> -4.51891}, {x -> 0.}, {x -> 4.51891}, {x ->
7.78813}}

But I was unaware of or had forgotten about IntervalRoots. Again, how many
people are going to think of it BEFORE spending a lot of time with FindRoot,
which they might expect to easily solve a problem like this?

It's true that there is no such thing as perfect root finder even for real
functions. I once wrote a very robust routine for solving the mass action
chemical equilibrium equation. It will quickly solve for all concentrations
to nearly the full precision of the floating point processor over nearly the
full number range of the processor. But it uses a special transformation of
the function and only works for that type of equation. I tried Ted's routine
on these equations and found it worked extremely well. I was able to break
it but it wasn't easy.

That's why I think a significantly better FindRoot could be provided to
Mathematica users.

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





From: Thomas Burton [mailto:tburton at brahea.com]
To: mathgroup at smc.vnet.net

[[ This message was both posted and mailed: see
   the 'To' and 'Newsgroups' headers for details. ]]

Golly! I'm pleased as punch with FindRoot :-)

Seriously, the following short, simple-minded, and obvious extension has so
far bailed me out of the kind of problem you describe:

rootSearch[f_,{x_,xMin_,xMax_,dx_,eps_}]:=
  Union[Table[FindRoot[f,{x,x0}],{x0,xMin,xMax,dx}],
     SameTest -> (Abs[#1[[1,-1]]-#2[[1,-1]]]<eps&)]

I plot the function and then choose limits xMin and xMax and increment dx
appropriately.  I get more frustrated when an upgrade to Mathematica breaks
existing code. I had a client frozen to version 4.x because I didn't have
time to sort out why version 5 broke code I wrote for them. Among the issues
were new failures in (my usage of) FindRoot (not for closed-form
expressions).

Which is partly why I am wary of Mathgroup extensions. If the evolution of
core Mathematica functions breaks my code, what about MathSource?

Finding real roots of closed-form expressions is, I should think, a common
application of Mathematica that deserves a method more sophisticated than
Newton and secant.  One one hand, to upgrade Mr Ersek's RootSearch from
MathSource to Mathematica's core entails a lot of work: vetting of methods,
extensive quality assurance, commitment to perpetual maintenance, etc.

On the other hand, Mr. Ersek has already done some of the work. Also it's
easy to check the results of  a root finder. I always check FindRoot.
RootSearch would be no different. Perhaps the case could be made that
Wolfram
should upgrade Ersek's RootSearch to a standard add-on.

Tom Burton

On Sun, 4 Jul 2004 23:09:59 -1000, David Park wrote
(in article <ccb5t7$enc$1 at smc.vnet.net>):

> Dear MathGroup,
>
> I am continually being frustrated with the usage and performance of
> FindRoot....
> 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.





  • Prev by Date: Re: How Many Users Are Happy With FindRoot?
  • Next by Date: Re: PlotLabel with assigned variables *and* on several lines
  • Previous by thread: Re: How Many Users Are Happy With FindRoot?
  • Next by thread: Re: Univers font for PDF files