Re: Plotting a series of Roots
- To: mathgroup at smc.vnet.net
- Subject: [mg128881] Re: Plotting a series of Roots
- From: Bob Hanlon <hanlonr357 at gmail.com>
- Date: Sun, 2 Dec 2012 04:57:40 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-newout@smc.vnet.net
- Delivered-to: mathgroup-newsend@smc.vnet.net
- References: <20121201093730.A100D68C0@smc.vnet.net>
In[74]:= M = 10000; g = 1; A = 10; a = 1/100;(*initial plot temp*) b = 12/10;(*final plot temp*) c = 10^-8;(*initial temp*) d = 0;(*initial \[Beta]*)m = 1; In[81]:= s[\[Alpha]_?NumericQ, t_?NumericQ] := Module[ {bb = (g/(2*\[Pi])^(3/2)*(m/T)^(3/2)*E^(-m/T))}, \[Beta][t] /. NDSolve[{\[Beta]'[T] == (3*\[Alpha]^2*M*T^(5/2))/ (Sqrt[2*g]*m^(9/2))*(bb^2 - \[Beta][T]^2), \[Beta][c] == d}, \[Beta], {T, a, b}, Method -> "BDF"][[1]]]; The algorithms used in NSolve cannot solve this equation. You need to use either FindRoot or NMinimize. Neither FindRoot nor NMinimize provide all of the roots when there is more than one. FindRoot is faster than NMinimize in this case and given additional starting points FindRoot can locate more than one root when appropriate. In[91]:= Clear[t1, t2, t3] In[108]:= t2[alpha_?NumericQ, value_?NumericQ] := t /. (FindRoot[s[alpha, t] == value, {t, #}] & /@ {0.6, 1.0}); In[109]:= t2[0.6, 0.025] Out[109]= {0.547188, 0.852271} In[110]:= s[0.6, #] == 0.025 & /@ % Out[110]= {True, True} In[111]:= t3[alpha_?NumericQ, value_?NumericQ] := t /. NMinimize[{Abs[s[alpha, t] - value], a <= t <= b}, t][[2]]; In[112]:= t3[0.6, 0.025] Out[107]= 0.547188 Bob Hanlon On Sat, Dec 1, 2012 at 4:37 AM, William Duhe <wjduhe at loyno.edu> wrote: > I want to make the second bit of code operate like the first: > > First > > > > s1[lambda_, t_] = > x[t] /. DSolve[{x'[t] == lambda, x[0] == 0}, x[t], t][[1]]; > > lambda t; > > > t1[lambda_, value_] = t /. Solve[s1[lambda, t] == value, t][[1]]; > > value/lambda; > > > s1[lambda, t1[lambda, value]]; > > value; > > Plot[t1[lambda, 1], {lambda, .1, 1}, PlotRange -> Automatic] > > > > > > Second > > > > > M = 10000; > g = 1; > A = 10; > a = 1/100;(*initial plot temp*)b = 12/10;(*final plot temp*)c = > 10^-8;(*initial temp*)d = 0;(*initial \[Beta]*)m = 1; > > s[\[Alpha]_?NumericQ, t_?NumericQ] := > Module[{bb = (g/(2*\[Pi])^(3/2)*(m/T)^(3/2)*E^(-m/T))}, \[Beta][ > t] /. NDSolve[{\[Beta]'[ > T] == (3*\[Alpha]^2*M*T^(5/2))/(Sqrt[2*g]* > m^(9/2))*(bb^2 - \[Beta][T]^2), \[Beta][c] == > d}, \[Beta], {T, a, b}, Method -> "BDF"][[1]]]; > t1[\[Alpha]_?NumericQ, value_?NumericQ] = > t /. NSolve[s[\[Alpha], t] == value, t][[1]]; > Plot[t1[\[Alpha], .9], {\[Alpha], .1, 1}, PlotRange -> Automatic] > > > But I can't seem to make it go! >
- References:
- Re: Plotting a series of Roots
- From: William Duhe <wjduhe@loyno.edu>
- Re: Plotting a series of Roots