# Creating Plots for a Family of Solutions

I am wondering how do you set the parameters appropriately for $a_n,\,\alpha,\,\text{and }b_n$ to plot the family of solution of:

$u_n(r,t) = [a_n\cos(k_n\alpha t)+b_n\sin(k_n\alpha t)]J_0(k_nr)$

where the Bessel function of the first kind of zero order represents $J_0.$

$0<k_1<k_2<\ldots<k_n<\ldots$ are all positve zeros of $J_0$.

The original equation is: $u_{tt}=\alpha(u_{rr}+\tfrac{1}{r}u_r), \quad 0<r<1,~ t>0,$

$u(1,t)=0, \qquad t>0,$

$u(r,t)$ remain finite as $r\rightarrow 0^+,$

$u(r,0)=f(r), \qquad 0<r<1,$

$u_t(r,0)=g(r), \qquad 0<r<1,~~$ where $f,g$ are initial displacement and velocities.

I tried something of the type:

0<r<1;
t>0;
Plot3D[Cos[8.654 t] + Sin[8.654 t] BesselJ[0, 8.654 r], {r, 0, 1}, {t,0, 10}]


Choosing other parameters in the solution to have the value of 1.

The output would resemble the following: First graphic is for $J_0(2.4r)$, Second graphic is for $J_0(5.5r)$, and Third graphic is for $J_0(8.7r)$.

I guess you have some sort of time evolution of Bessel-like waves. I also see that your examples deal with 3rd zero of Bessel J0 - I'll use it too. Define a function:

mYf[r_, t_, n_] := With[
{k = BesselJZero[0, n]},
(Cos[k t] + Sin[k t]) BesselJ[0, k r]
]


Build a time evolution list:

giflist = Table[
RevolutionPlot3D[
Evaluate[N@mYf[r, t, 3]],
{r, 0, 1},
SphericalRegion -> True,
PlotRange -> {{-1, 1}, {-1, 1}, {-1.5, 1.5}},
ImageSize -> 450,
PlotStyle -> Opacity[.7],
ColorFunction -> "TemperatureMap",
MeshStyle -> Opacity[.5],
PlotLabel -> time == t
],
{t, 0, 2 Pi/N[BesselJZero[0, 3]], .05}
];


Display as animated .GIF -

Export["bessel.gif", giflist] Display as a table:

GraphicsGrid[
Partition[
Show[#,Boxed ->False, Axes -> False] & /@ giflist,
5
],
ImageSize -> 500,
Spacings -> 0
] Create an interface to investigate parameters. You BTW did not define dependence of a and b on n so I'll just define them generically:

Manipulate[
RevolutionPlot3D[
Evaluate[N@mYf[r, t, n, a, b, α]],
{r, 0, 1},
SphericalRegion -> True,
PlotRange -> {{-1, 1}, {-1, 1}, {-1.5, 1.5}},
ImageSize -> 350,
PlotStyle -> Opacity[.7],
ColorFunction -> "TemperatureMap",
MeshStyle -> Opacity[.5],
PlotLabel -> time == t,
PlotPoints -> 25
],
{{t, 1.36, "time"}, 0, 2, ImageSize -> Tiny},
Delimiter,
"zero's order",
{{n, 7, ""}, Range, SetterBar, ImageSize -> Tiny},
Delimiter,
{{a, 1.2, "a_n"}, 0, 2, ImageSize -> Tiny},
{{b, 1, "b_n"}, 0, 2, ImageSize -> Tiny},
{{α, .9, "α"}, 0, 2, ImageSize -> Tiny},
FrameMargins -> 0,
ImageMargins -> 0,
ControlPlacement -> Left,
Initialization :> (
mYf[r_, t_, n_, a_, b_, α_] :=
With[
{k =  BesselJZero[0, n]},
(a Cos[α k t] +
b Sin[α k t]) *
BesselJ[0, k r]
]
)
] • +1...Vitaliy, brilliant!! Honestly, this is some nice work. You must got good at this fast or been using mathematica for some time. Thanks, I did not have any information on a,b, or n so thanks for just making some assumptions on them. – night owl Feb 19 '12 at 10:12
• One comment though. When I export the function to a graphic .gif the animation does not show. Only output is: bessel.gif. Any ideas? – night owl Feb 19 '12 at 10:13
• @nightowl You're welcome ;) GIF won't show in your notebook. GIF is saved to a default location (My Documents on Windows) if only file name is mentioned in in "..." inside Export function. You can put there the whole directory/file path to where you want to save GIF. Use menu Insert >> File Path.... Read more here: reference.wolfram.com/mathematica/ref/Export.html – Vitaliy Kaurov Feb 19 '12 at 10:32

Let's say you want to plot a family of functions $f_{a,\,b,\,c}(x)=a\sin(b\,x^c)$ for $a\in\{-2,-1,1,2\}$, $b\in\{1,2\}$, $c\in\{1,2,3\}$:

(* Define the function itself *)
f[x_, a_, b_, c_] := a Sin[b x^c]

(* Generate a table consisting of all possible
combinations for the values of a, b, c *)
fPlot = Table[
f[#, a, b, c],
{a, {-2, -1, 1, 2}},
{b, 1, 2},
{c, 1, 3}
];

(* Flatten it so it's a 2-dimensional list that
can be plotted as usual *)
fPlot = Flatten[#, 1] & @ fPlot;

(* Convert it to a function, making use of the "#"
introduced in the Table statement above *)
fPlot = Function[Evaluate@fPlot];

(* Plot it *)
Plot[fPlot[x] // Evaluate, {x, 0, 3}] • Thanks David for the general idea of creating families of graphs. – night owl Feb 19 '12 at 9:32
• some corrections though. I think $c \in {1,2,3}$ where as in the code you have ${c,1,3}$. Next would be, you said make use of the # to make it into a function, but I only see the @ being used in the section of code. Is this what you meant? Overall, nice implementation. – night owl Feb 19 '12 at 9:34
• 1. {c,1,3} loops from 1 to 3, which is equivalent to {c,{1,2,3}}. – David Feb 19 '12 at 16:22
• 2. Using # is completely independent of anything, it's simply short notation for Slot. You can for example write #^2& and it will work; @x is simply a shortcut for [x]. In my solution, I used # as short for Slot without making a function out of it initially. The reason for this is that Function has the attribute HoldAll, which would have required me to use Evaluate in each step involving some transformation of the function body. The way I did it was manipulating the whole thing first, and then making a function out of it at the very end. – David Feb 19 '12 at 16:24