How do I use Euler's forward difference method and the second order Runge-Kutta method to work out a third order ODE?

8 Ansichten (letzte 30 Tage)
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.

Akzeptierte Antwort

Torsten
Torsten am 21 Mär. 2022
Bearbeitet: Torsten am 21 Mär. 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,:))

Weitere Antworten (0)

Kategorien

Mehr zu Numerical Integration and Differential Equations finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by