       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:= 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:= 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"][]];

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:= Clear[t1, t2, t3]

In:= t2[alpha_?NumericQ, value_?NumericQ] :=
t /. (FindRoot[s[alpha, t] == value, {t, #}] & /@ {0.6, 1.0});

In:= t2[0.6, 0.025]

Out= {0.547188, 0.852271}

In:= s[0.6, #] == 0.025 & /@ %

Out= {True, True}

In:= t3[alpha_?NumericQ, value_?NumericQ] :=
t /. NMinimize[{Abs[s[alpha, t] - value], a <= t <= b}, t][];

In:= t3[0.6, 0.025]

Out= 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}, x[t], t][];
>
> lambda t;
>
>
> t1[lambda_, value_] = t /. Solve[s1[lambda, t] == value, t][];
>
> 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"][]];
> t1[\[Alpha]_?NumericQ, value_?NumericQ] =
>   t /. NSolve[s[\[Alpha], t] == value, t][];
> Plot[t1[\[Alpha], .9], {\[Alpha], .1, 1}, PlotRange -> Automatic]
>
>
> But I can't seem to make it go!
>

```

• Prev by Date: Creating a Function to Display Numbers in Percent Format
• Next by Date: Mathematica 9 for Windows
• Previous by thread: Re: Plotting a series of Roots
• Next by thread: Re: Unfortunate Side Effect of Upgrading to Mathematica