Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #12530

Re: Plotting a series of Roots

From Bob Hanlon <hanlonr357@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Plotting a series of Roots
Date 2012-12-03 08:30 +0000
Message-ID <k9hnvj$pg$1@smc.vnet.net> (permalink)
References <20121201093730.A100D68C0@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


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@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!
>

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Plotting a series of Roots Bob Hanlon <hanlonr357@gmail.com> - 2012-12-03 08:30 +0000

csiph-web