How do I use Euler's forward difference method and the second order Runge-Kutta method to work out a third order ODE?
3 views (last 30 days)
Show older comments
The given equation is y'''-3y'-3xy=0 with initial conditons y(0)=1.11983, y'(0)=0.83697, y''(0)=0.12356. h=0.1. The question asks to find the numerical solution y at x=0.1, x=0.2 and x=0.3 using the Euler's forward difference method and the second order Runge-Kutta method based on, k1=hf(xn,yn) k2=hf(xn+h/2, yn+k1/2) yn+1=yn+k2.
I first turned the given equation into three first oder differential equations such that dy/dx=v so y(0)=1.11983, dv/dx=w so v(0)=y'(0)=0.83697 and dw/dx=3v+3xy so w(0)=y''(0)=0.12356.
However, Im not sure on how to work out y1,y2 and y3 for both Eulers and Runge-Kutta methods.
1 Comment
James Tursa
on 21 Mar 2022
Can you post the code you have written so far? Then we can help steer you in the right direction.
Accepted Answer
Torsten
on 21 Mar 2022
Edited: Torsten
on 21 Mar 2022
Don't work with y1, y2 and y3, but with y = (y(1),y(2),y(3)).
Define the vector of derivatives as
f = @(t,y) [y(2) y(3) 3*y(2)+3*t*y(1)];
and the vector of initial conditions as
Y(1,:) = [1.11983 0.83697 0.12356];
Then, for Euler explicit, e.g., you can update all three ODE solutions as if it was a case for one unknown function:
Y(i+1,:) = Y(i,:) + dt*f(t(i),Y(i,:))
0 Comments
More Answers (0)
See Also
Categories
Find more on Numerical Integration and Differential Equations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!