FW: Re: To plot solutions, FindRoot as a function
- To: mathgroup at smc.vnet.net
- Subject: [mg37421] FW: [mg37353] Re: To plot solutions, FindRoot as a function
- From: "David Park" <djmp at earthlink.net>
- Date: Sun, 27 Oct 2002 06:33:30 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
RE: [mg37353] Re: To plot solutions, FindRoot as a function -----Original Message----- From: DrBob [mailto:drbob at bigfoot.com] To: mathgroup at smc.vnet.net Subject: [mg37421] RE: [mg37353] Re: To plot solutions, FindRoot as a function I was getting error messages, so I rewrote your solution this way: Series[a Tanh[b x] - x, {x, 0, 3}] // Normal x /. Solve[% == 0, x] start[a_, b_] = Last@% getSol[a_, b_] := Chop@x /. FindRoot[a Tanh[b x] == x, {x, start[a, b]}] Table[getSol[a, b], {a, 1, 2, .25}, {b, 1, 2, .25}]; ListDensityPlot[%] Plot3D[getSol[a, b], {a, 1, 2}, {b, 1, 2}] Of course, there's also a negative solution: Series[a Tanh[b x]/x - 1, {x, 0, 3}] // Normal x /. Solve[% == 0, x] start[a_, b_] = First@% getSol[a_, b_] := x /. FindRoot[a Tanh[b x] == x, {x, start[a, b]}] Table[getSol[a, b], {a, 1, 2, .25}, {b, 1, 2, .25}]; ListDensityPlot[%] Plot3D[getSol[a, b], {a, 1, 2}, {b, 1, 2}] I tried using the 5-th degree series instead, and got nowhere! DrBob -----Original Message----- From: Borut L [mailto:gollum at email.si] To: mathgroup at smc.vnet.net Subject: [mg37421] [mg37353] Re: To plot solutions, FindRoot as a function Hi Veniamin, First, there is always a trivial solution, i.e. x = 0. You are probably interested in the additional one, yes?. Depending on the values of a and b, it exists in Reals or it doesn't. I would carefully avoid continuous analysis in such problems and looked for a discrete solution. You can always increase resolution. Here we go. getSol[a_,b_,x_]:=FindRoot[Evaluate[a Tanh[b x] == x], {x,Sqrt[3 (a b-1)/(a b^3)]}] x/.Table[getSol[a,b,x],{a,1,2,.25},{b,1,2,.25}] ListDensityPlot[%] (* continuous :) *) Plot3D[Evaluate[x/.getSol[a,b,x]],{a,1,2},{b,1,2}] A note : You should check for the critical a and b, i.e. where the non-trivial solution vanishes. (e.g. a*b == 1). If you are thinking where I've got the initial value for FindRoot, think twice Series[a Tanh[b x],{x,0,3}]//Normal Hope that helps, Borut "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 | | | |