MATLAB Differential equation for matlab

AI Thread Summary
The discussion revolves around solving the differential equation y(t) = e^(-t)*sin(t^2) for a MATLAB project, specifically finding a form where y is on the right side of the equation. The user has derived y' but is struggling to express it correctly for MATLAB's requirements. They need to reformulate the equation to use the Runge-Kutta method for numerical integration and compare it with an exact solution. Suggestions include testing with simpler equations and clarifying the definition of f(t, y), which leads to a proposed form of f(t, y) = -y + 2te^(-t)cos(t^2). The conversation emphasizes the need for proper formulation to proceed with MATLAB coding.
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:

y(t) = e^{-t}sin(t^2), 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

\dot{y} = e^{-t}(-sin(t^2)+2tcos(t^2)) = -y+2te^{-t}cos(t^2) = f(t,y)is this useful at all?
 

Similar threads

Replies
4
Views
1K
Replies
8
Views
2K
Replies
5
Views
2K
Replies
1
Views
2K
Replies
1
Views
2K
Replies
9
Views
3K
Replies
4
Views
3K
Replies
5
Views
3K
Replies
4
Views
4K
Back
Top