# Solving differential equation with a constant

1. Jul 21, 2010

### zarei

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

2. Jul 21, 2010

### antibrane

You can solve it using

Code (Text):
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 (Text):
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 $k$ on the horizontal axis you will need to choose $t$ (or just make a three-dimensional plot). The plot may be done like

Code (Text):

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 $t0$ is the $t$ you are choosing.

3. Jul 21, 2010

### Mute

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!

4. Jul 22, 2010