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

Differential equation for matlab

  1. Oct 12, 2012 #1
    THE PROBLEM :

    y(t) = e^(-t)*sin(t^2);
    with t0 = 0 and T = 3.14159. Find y_0, and use it to deduce the corresponding expression
    for f(t, y) (Your f should have both a t and a y in it. Simplify it to find the y!).

    This is for a matlab project. I've solved this differential equation (which we get from the derivative of the problem above) , but apparently there's a way to solve it where we get y on the right hand side of the equation (and still have t's). This is the only way the code will work in matlab.

    MY ATTEMPT: basically I took the derivative of y=e^(-t)*sin(t^2) to get

    y'=-e^(-t)[sin(t^2)+(2t)cos(t^2)]

    You then inegrate to get the original formula plus a constant

    y=e^(-t)*sin(t^2)+C

    Now if we apply the inital condition y(0)=0, we get the original equation. Again.

    y=e^(-t)*sin(t^2)

    This is not correct. What am I missing?

    PS, if you want to see my code and think that will help I have that as well. Just ask. Thanks
     
    Last edited: Oct 12, 2012
  2. jcsd
  3. Oct 12, 2012 #2

    jedishrfu

    Staff: Mentor

    are you doing something with FFT (aka fourier transforms) on the equation?

    Thats what people often use matlab for given a complicated signal and use FFT to determine the component frequencies.
     
    Last edited: Oct 12, 2012
  4. Oct 12, 2012 #3
    No, I'm trying to approximate this differential equation using the runge-kutta method, then plot the error. But, I can't really do any of that without the proper differential equation. Which is where I'm stuck.
     
  5. Oct 12, 2012 #4

    jedishrfu

    Staff: Mentor

    Okay so given a differential equation, you want to use matlab to numerically integrate your equation via runge-kutta and to then compare it to an exact solution.

    Have you tried a simpler equation such as integrating a sin function to get a cos function to test your matlab code?

    To be fair, I'm not a heavy matlab person. I've done some numerical integration using open source physics java code where we converted the differential equation into first order differentials and I figure that's how it may need to be done here.

    I did find this predator prey simulation that compares two versions of runge-kutta in plot form that may help.

    http://www.mathworks.com/products/m...products/demos/shipping/matlab/lotkademo.html

    http://math.arizona.edu/~emcevoy/odes.pdf
     
    Last edited: Oct 12, 2012
  6. Oct 14, 2012 #5
    When you wrote:

    [itex] y(t) = e^{-t}sin(t^2) [/itex], did you find this, or was this given to you? I'm confused. Precisely what does the problem give you?
     
  7. Oct 14, 2012 #6
    So, I'm still confused about what f(t,y) is supposed to be, but I got

    [itex] \dot{y} = e^{-t}(-sin(t^2)+2tcos(t^2)) = -y+2te^{-t}cos(t^2) = f(t,y)[/itex]


    is this useful at all?
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook