Solving differential equation with a constant

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 4K views
zarei
Messages
8
Reaction score
0
Hi,
I am working with mathematica. I have a simple differential equation as follows:
y''[t]+k^2y[t]+(1/t^2)y[t]=0
where k is a constant between 1<k<20.
How can solve this equation and then plot y in terms of k?
thanks
 
Physics news on Phys.org
You can solve it using

Code:
DSolve[y''[t] + k^2 y[t] + (1/t^2) y[t] == 0, y[t], t]

which gives the answer in terms of Bessel functions. To plot it though, you will need to choose some initial conditions, which you would insert like

Code:
DSolve[{y''[t] + k^2 y[t] + (1/t^2) y[t] == 0,y[0]==0,y'[0]==0}, y[t], t]

and to plot with [itex]k[/itex] on the horizontal axis you will need to choose [itex]t[/itex] (or just make a three-dimensional plot). The plot may be done like


Code:
sol=DSolve[{y''[t] + k^2 y[t] + (1/t^2) y[t] == 0,y[0]==0,y'[0]==0}, y[t], t]
Plot[y[t]/.sol/.t->t0 , {k,1,20}]

where [itex]t0[/itex] is the [itex]t[/itex] you are choosing.
 
16180339887 said:
Code:
sol=DSolve[{y''[t] + k^2 y[t] + (1/t^2) y[t] == 0,y[0]==0,y'[0]==0}, y[t], t]
Plot[y[t]/.sol/.t->t0 , {k,1,20}]

Just a note: if you choose y(0), y'(0) = 0, the unique solution for this initial condition is y(t) = 0, so I suggest choosing something different for the initial conditions!
 
Thanks for reply,
I have a similar equation where cannot be solved with DSolve. It can be solved just by NDSolve. Could you please guide me how the final solution can be plotted in terms of constant k when we use the NDSolve?