Re: To plot solutions, FindRoot as a function
- To: mathgroup at smc.vnet.net
- Subject: [mg37372] Re: To plot solutions, FindRoot as a function
- From: "Peltio" <peltio at twilight.zone>
- Date: Fri, 25 Oct 2002 02:48:23 -0400 (EDT)
- Organization: Peltio Inc.
- References: <ap861r$53e$1@smc.vnet.net>
- Reply-to: "Peltio" <peltioNOSP at Miname.com.invalid>
- Sender: owner-wri-mathgroup at wolfram.com
"Veniamin Abalmassov" wrote: >I'd like to plot the solution of an equation which depends on two >parameters, e.g. >sol[a_,b_]:=FindRoot[a*Tanh[b*x] == x, {x, {0.01, 0.1}}] >Plot[sol[a,b], {a, 1, 2}, {b, 1, 2}] You were almost there! The problem is the typo (Plot instead of Plot3D) and the fact that FindRoot, and hence sol, returns a replacement rule instead of the value of x. You will be better off with: sol[a_,b_]:=x /. FindRoot[a*Tanh[b*x] == x, {x, {0.01, 0.1}}] Plot3D[sol[a,b], {a, 1, 2}, {b, 1, 2}] And if you want to see the single points (here I use a grid with a spacing of 0.05 units) you can use this, instead: sol[a_,b_]:=FindRoot[a*Tanh[b*x]==x,{x,{0.01,0.1}}] vals=Flatten[Table[{a,b,x/.sol[a,b]},{a,1,2,.05},{b,1,2,.05}],1]; pts=Point/@vals; Show[Graphics3D[pts],BoxRatios\[Rule]{1,1,1},Axes\[Rule]True] cheers, Peltio -- invalid address in reply, crafty decoding needed to answer in mail