Using 4th order runge kutta to solve second ordee differential equation

2.2k Views Asked by At

Use Runge-Kutta formular (4th order) to find $y(0.2)$ for the differential equation \begin{cases} &\dfrac{d^2y}{dx^2} - x\,\dfrac{dy}{dx} + y=0 \\[1em ] \text{ given that }&y=1,~~ \dfrac{dy}{dx}=0~\text{ when }x=0 \end{cases}

1

There are 1 best solutions below

0
On

The standard trick to solve a second order differential equation numerically is to define $z(x)=y'(x)$, and then you get a system of two first order differential equations: $$ \cases{\frac{dy}{dx}=z(x)\\ \frac{dz}{dx}=x\cdot z(x)-y(x)} $$ given that $z(0)=0,y(0)=1$.

You can express this as a single differential equation using vectors as well: $$ \frac{d(y,z)}{dx}=(z,x\cdot z-y) $$ where the last expression is a vector-valued function of the free variable $x$ and the vector $(y,z)$ (I'll call it $f(x,(y,z))$). If you use this formulation, the formulas for Runge-Kutta are exactly the same as the ones you're used to, an you use it exactly the same way. It's just that all the function values are vectors instead of real numbers (and once we're done calculating, we're interested in the first component of the vector, not the entire vector).

To get you started, here is the first intermediate calculation of RK4, using a step size of $0.1$: $$ k_1=0.1\cdot f(0,(1,0))=0.1\cdot(0,-1)=(0,-0.1) $$ The next calculation uses $f(0.05,(1,0)+k_1/2)$