MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Table NDSolve Plot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg121951] Re: Table NDSolve Plot
  • From: Peter Pein <petsie at dordos.net>
  • Date: Fri, 7 Oct 2011 04:46:52 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <j6joh8$m3g$1@smc.vnet.net>

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



  • Prev by Date: Re: Re: simplification
  • Next by Date: Re: Extra parameter for DirichletDistribution
  • Previous by thread: Re: Table NDSolve Plot
  • Next by thread: Re: Table NDSolve Plot