Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1997
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1997

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

Search the Archive

Re: Help with findroot

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

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
(tangent).

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:

In[1]:=
x/. Map[ FindRoot[Sqrt[x/(12 10^-5)]==-1/10  Tan[Sqrt[x/(12*10^-5)]],
	{x,#,#(1+2/100000)},
	WorkingPrecision->30, MaxIterations ->24]&,

     Table[Evaluate[First[
	(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\)."

Out[1]=
{
0.00268873607796611887069764090412,
0.0074261826194566946160960896946,
0.0145323079006264369142195053877,
0.0239836183574210343873004975396,
0.035827380509233890874647154856,
0.050062891245430953402233797855,
0.066643827402591068860991918233,
0.085593468362931953353908980075,
0.106911814227110340526576903488,
0.130598865050298892779541380190
}

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