Differential equation for matlab

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
5 replies · 3K views
cameuth
Messages
17
Reaction score
0
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:
Physics news on Phys.org
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:
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.
 
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:
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?
 
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?