MathGroup Archive 2002

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

Search the Archive

Re: To plot solutions, FindRoot as a function


Veniamin,

There are a few problems with your code that you need to address
before it will work:
(i) The output from FindRoot is in the form of a replacement rule:
x->something. And this will not work as input for the plotting
routine;
(ii) You should use Plot3D not Plot;
(iii) Your initial guess is not in the neighborhood of the root so you
always get x=0 (or its approximation)

The following changes have been made and now your code woirks


sol[a_, b_] := x /. FindRoot[a*Tanh[b*x] == x, {x, 2}]
Plot3D[sol[a, b], {a, 1, 2}, {b, 1, 2}, PlotPoints -> 40]


Cheers,

Brian

Veniamin Abalmassov <V.Abalmassov at unibas.ch> wrote in message news:<ap861r$53e$1 at smc.vnet.net>...
> Hello,
> 
> I'd like to plot the solution of an equation which depends on two 
> parameters, e.g.
> 
> a*Tanh[b*x] == x
> 
> So, I'd like to see it in 3D, one axis is "a", other is "b", and the last 
> is "solution".
> 
> I've tried naively to do it as follows:
> 
> sol[a_,b_]:=FindRoot[a*Tanh[b*x] == x, {x, {0.01, 0.1}}]
> Plot[sol[a,b], {a, 1, 2}, {b, 1, 2}]
> 
> And it doesn't work. Help me, please. What can I do?
> 
> Thanks a lot,
> 
> Veniamin


  • Prev by Date: Re: Different EPS exported file from frontend and kernel
  • Next by Date: Re: how to get a real fortran file
  • Previous by thread: Re: To plot solutions, FindRoot as a function
  • Next by thread: FW: Re: To plot solutions, FindRoot as a function