MathGroup Archive 1997

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

Search the Archive

Re: Help with findroot

  • To: mathgroup at
  • Subject: [mg9181] Re: [mg9169] Help with findroot
  • From: Olivier Gerard <jacquesg at>
  • Date: Tue, 21 Oct 1997 02:02:54 -0400
  • Sender: owner-wri-mathgroup at

Hi Karl,

Your example is clearly a difficult one for any general purpose routines
because the function whose zeros you try to find is a very regular one
(square root) ponctuated by the essential singularities of the other

As the method used by FindRoot is Newton descent, if you don't give
starting values sufficiently close on the *same* side of the
singularity, you cannot expect much in this case.

How can we do that ?

As Tan[x] dominates all the rest near the singularities, you can find a
good approximation of all the roots by just looking at Tan[f[x]] roots.
This gives a table of the first 10:

rootlist = Table[ Evaluate[First[
(x/. Solve[ Sqrt[x/(1.2 10^-4)] == (2 k+1) Pi/2,x])]],{k,1,10}]

and you can then feed Findroot with these values. If you remark that
Tan[x] tends to -Infinity when x tends to Pi/2 from the right, you know
you must add a small quantity to the Tan[f[x]] root to bracket the root
you are searching for.

Here is a complete example:

x/. Map[ FindRoot[Sqrt[x/(12 10^-5)]==-1/10  Tan[Sqrt[x/(12*10^-5)]],
	WorkingPrecision->30, MaxIterations ->24]&,

	(x/. Solve[ Sqrt[x/(12 10^-5)]==(2k+1) Pi/2, x])
	] ],{k,1,10}]

FindRoot::"frdig": "\!\(30\) working digits is insufficient to achieve
the absolute tolerance \!\(1.00000000000000000065`*^-20\)."

FindRoot::"frdig": "\!\(30\) working digits is insufficient to achieve
the absolute tolerance \!\(1.00000000000000000065`*^-20\)."


In such cases, you must to be able to conduct the calculation with as
many digits as necessary, so don't artificially limit Mathematica
precision by using fixed precision numbers such as 1.2. The simplest
way is to use fractions as demonstrated in my code. If you don't do
this, Mathematica will complain it has not enough precision to achieve
what you want.

Note that there were two cases for which the automatic accuracy goal
(=working precision - 10=20) was not achieved. You can change that by
setting explicitely accuracy goal to 20 and increasing WorkingPrecision
to a higher level.
It was necessary to increase the MaxIterations option as the slope of
the function was large.

Hope it helps.

Olivier Gerard

At 09:38 +0200 97.10.16, Karl Kevala wrote:
> I'm having a problem using findroot to solve an equation.  Perhaps
> someone
>  could shed some light on what's wrong.
> FindRoot[Sqrt[x/(1.2 10^ -4)]==-0.1*Tan[Sqrt[x/(1.2*10^
> -4)]],{x,0.1,0.1,2}]
> Mathematica 3. returns a value of -0.07 for x which is not anywhere
> close to correct.
>  Further, I've tried several different starting values and min/max
> limits, but
>  a negative answer is always returned.  Eventually I'de like to compile
> a list
>  of all the roots of the equation up to, say, x=1000, but I can't even
> get one
>  right now.
> Thanks,
> Karl Kevala

  • Prev by Date: Re: Horse Race Puzzle
  • Next by Date: Re: Not so Useful Dumb User Questions
  • Previous by thread: Re: Help with findroot
  • Next by thread: Re: Help with findroot