Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: Help with find root needed

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88970] Re: [mg88910] Help with find root needed
  • From: Darren Glosemeyer <darreng at wolfram.com>
  • Date: Thu, 22 May 2008 02:39:36 -0400 (EDT)
  • References: <200805211849.OAA10350@smc.vnet.net>

Aaron Fude wrote:
> Hi,
>
> In what follows, I'm looking for the largest root of a function, that
> is also a function of two parameters. The Manipulate command shows me
> that the root is consistently there (albeit near a singularity which
> might be what's causing problems). However, FindRoot doesn't find it
> as the plot shows. I get one error, but my guess is that it's
> referring to one particular point on the plot.
>
> f[z_, h_, \[Gamma]_] :=
>   Tanh[h*z] + (\[Gamma]^2 + 1 - z^2)/(\[Gamma]^2 - 1 - z^2) *
>     z/\[Gamma];
> Manipulate[
>  Plot[f[z, h, \[Gamma]], {z, 0, 10}], {h, .1, 10}, {\[Gamma], .1,
>   10}]
> K[h_, \[Gamma]_] :=
>   z /. FindRoot[f[z, h, \[Gamma]] == 0, {z, 10, 1, 10}];
> Plot3D[K[h, \[Gamma]], {h, .1, 10}, {\[Gamma], .1, 10}]
>
> Many thanks in advance!
>
> Aaron
>   

Starting closer to the root helps. If we start just to the right of the 
singularity, good results can be obtained.

In[1]:= f[z_, h_, \[Gamma]_] :=
          Tanh[h*z] + (\[Gamma]^2 + 1 - z^2)/(\[Gamma]^2 - 1 - z^2)*
            z/\[Gamma];

In[2]:= K[h_, \[Gamma]_] :=
          z /. FindRoot[f[z, h, \[Gamma]] == 0, {z, 1.01*(\[Gamma]^2 + 1)}];

In[3]:= Plot3D[K[h, \[Gamma]], {h, .01, 10}, {\[Gamma], .01, 10},
         PlotRange -> All]

The root finder is basically taking steps and refining step size to try 
to get to the root. With that sharp drop off heading to the left toward 
the singularity and starting far from the root, there is a better chance 
of the root finder taking too big of a step and stepping over the 
singularity.

Darren Glosemeyer
Wolfram Research


  • Prev by Date: Interpolation and plot doing strange things with mathematica 6 tia
  • Next by Date: Re: URL button on Documentation Center pages
  • Previous by thread: Help with find root needed
  • Next by thread: Re: Help with find root needed