Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Solving differential equation with a constant

  1. Jul 21, 2010 #1
    I am working with mathematica. I have a simple differential equation as follows:
    where k is a constant between 1<k<20.
    How can solve this equation and then plot y in terms of k?
  2. jcsd
  3. Jul 21, 2010 #2
    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 [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 (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 [itex]t0[/itex] is the [itex]t[/itex] you are choosing.
  4. Jul 21, 2010 #3


    User Avatar
    Homework Helper

    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!
  5. Jul 22, 2010 #4
    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?
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook