Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5414 > unrolled thread
| Started by | Howie <hcohl001@gmail.com> |
|---|---|
| First post | 2011-10-06 08:23 +0000 |
| Last post | 2011-10-07 08:56 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Table NDSolve Plot Howie <hcohl001@gmail.com> - 2011-10-06 08:23 +0000
Re: Table NDSolve Plot Peter Pein <petsie@dordos.net> - 2011-10-07 08:56 +0000
| From | Howie <hcohl001@gmail.com> |
|---|---|
| Date | 2011-10-06 08:23 +0000 |
| Subject | Table NDSolve Plot |
| Message-ID | <j6joh8$m3g$1@smc.vnet.net> |
I know this is a basic question, but I am having a hard time figuring
this out on my own.
I would like to numerically solve an ordinary differential equation
with a parameter which varies over a range of numbers and plot all the
solutions with different values of the parameter on the same plot.
Also, I would like to be able to then over-plot another solution on
the same plot.
For instance:
h=0
n=0
k=0.25
s = NDSolve[{(h - k^2 n (1 + n) z^2) w[z] -
z (1 + k^2 - 2 k^2 z^2) Derivative[1][w][
z] + (1 - z^2) (1 - k^2 z^2) (w^\[Prime]\[Prime])[z] == 0,
w[2] == 1, w'[2] == -1}, w, {z, 1.1, 3.0}]
Plot[Evaluate[w[z] /. s], {z, 1.1, 3.0}, PlotStyle -> Automatic]
Plot[1/2 Log[(z + 1)/(z - 1)], {z, 1.1, 3.0}, PlotStyle -> Automatic]
I would like to do this for instance 10 increments of k from 0 to 1,
and also the Log plot, all on the same plot.
Thanks!
[toc] | [next] | [standalone]
| From | Peter Pein <petsie@dordos.net> |
|---|---|
| Date | 2011-10-07 08:56 +0000 |
| Message-ID | <j6merd$7f4$1@smc.vnet.net> |
| In reply to | #5414 |
Am 06.10.2011 10:23, schrieb Howie:
> I know this is a basic question, but I am having a hard time figuring
> this out on my own.
>
> I would like to numerically solve an ordinary differential equation
> with a parameter which varies over a range of numbers and plot all the
> solutions with different values of the parameter on the same plot.
> Also, I would like to be able to then over-plot another solution on
> the same plot.
>
> For instance:
>
> h=0
> n=0
> k=0.25
> s = NDSolve[{(h - k^2 n (1 + n) z^2) w[z] -
> z (1 + k^2 - 2 k^2 z^2) Derivative[1][w][
> z] + (1 - z^2) (1 - k^2 z^2) (w^\[Prime]\[Prime])[z] == 0,
> w[2] == 1, w'[2] == -1}, w, {z, 1.1, 3.0}]
> Plot[Evaluate[w[z] /. s], {z, 1.1, 3.0}, PlotStyle -> Automatic]
> Plot[1/2 Log[(z + 1)/(z - 1)], {z, 1.1, 3.0}, PlotStyle -> Automatic]
> I would like to do this for instance 10 increments of k from 0 to 1,
> and also the Log plot, all on the same plot.
>
> Thanks!
>
Hi,
why not solving the differential equation exactly? Then create all
plots you want and display these together with the log-plot using Show.
something like:
In[1]:= f[z_] = FullSimplify[With[{h = 0, n = 0},
w[z] /. First[DSolve[{(1 - z^2)*(1 - k^2*z^2)*Derivative[2][w][z] -
z*(1 + k^2 - 2*k^2*z^2)*
Derivative[1][w][z] + (h - n*(n + 1)*k^2*z^2)*w[z] == 0, w[2]
== Log[3]/2,
Derivative[1][w][2] == -(1/3)}, w, z]]], 0 < k < 1 && 1/k < z]
Out[1]= (1/6)*(2*I*Sqrt[3 - 12*k^2]*(EllipticF[ArcSin[2], k^2] -
EllipticF[ArcSin[z], k^2]) + Log[27])
In[2]:= Show[Join[{Plot[(1/2)*Log[(z + 1)/(z - 1)], {z, 1.1, 3.},
PlotStyle -> Thick]},
Table[Plot[f[z], {z, 1, 3}, PlotStyle -> Hue[k]], {k, Range[9]/10}]],
PlotRange -> {All, All},
Axes -> None, Frame -> True, GridLines -> {Automatic,
(1/4)*Log[3]*Range[5]},
GridLinesStyle -> LightGray]
Peter
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web