2
$\begingroup$

Solving a differential equation I found that its solution was analytic, and I stored it as an expression from the default rule output of the DSolve[] function:

soleq2 = y[x] /. soleq2[[1, 1]]

Which has output:

Sqrt[x] BesselJ[Sqrt[13]/2, x] C[1] + Sqrt[x] BesselY[Sqrt[13]/2, x] C[2]

I then plotted this:

Manipulate[Plot[soleq2, {x, 0, 10}], {C[1], 0, 10}, {C[2], 0, 10}]

but the plot does not show anything, only the sliders for the modulation of C[1] and C[2]. I tried substituting these constants with other letters thinking their format might interfere with the kernel, but to no avail.

$\endgroup$
1
  • 1
    $\begingroup$ See the "Possible Issues" section of the documentation for Manipulate where it explains that, and gives an example for, Manipulate only "notices" explicit visible parameters. $\endgroup$ – Bob Hanlon Jan 13 at 17:09
4
$\begingroup$

It is because your control variables are not local to Manipulate. One way around it is

soleq2 = Sqrt[x] BesselJ[Sqrt[13]/2, x] C[1] + 
   Sqrt[x] BesselY[Sqrt[13]/2, x] C[2];
Manipulate[
 Plot[soleq2 /. {C[1] -> c[1], C[2] -> c[2]}, {x, 0, 10}],
 {c[1], 0, 10},
 {c[2], 0, 10},
 TrackedSymbols :> {c[1], c[2]}
 ]

enter image description here

Or you could move the expression inside Manipulate, so it "sees" C[1] and C[2]

Manipulate[
soleq2=Sqrt[x] BesselJ[Sqrt[13]/2,x] C[1]+Sqrt[x] BesselY[Sqrt[13]/2,x] C[2];
Plot[soleq2,{x,0,10}],
{C[1],0,10},
{C[2],0,10},
TrackedSymbols:>{C[1],C[2]}
]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.