Skip to main content

RK-2: y'' + x y' + y = 0

Short answer

Convert to first-order system y'=z, z'=-xz-y. With h=0.1, Heun's method gives y(0.1)=0.9950, y(0.2)=0.9801.

Solve y'' + xy' + y = 0; y(0) = 1, y'(0) = 0 for x = 0(0.1)0.2 using the RK2 method.

Convert the 2nd-order equation to two first-order equations. Let z = y', then

dy/dx = z                = f₁(x, y, z)
dz/dx = −x·z − y         = f₂(x, y, z)
y(0) = 1, z(0) = 0, h = 0.1

The second-order Runge–Kutta (Heun / modified Euler) formulas are:

k₁ = h·f(xₙ, yₙ)
k₂ = h·f(xₙ + h, yₙ + k₁)
yₙ₊₁ = yₙ + ½(k₁ + k₂)

applied to y and z together: k₁(y) and k₂(y) use f₁, k₁(z) and k₂(z) use f₂, and in k₂ both y and z are advanced by their own k₁ values.

Step 1 (x₀ = 0 → 0.1)

k₁(y) = 0.1·z₀ = 0.1(0) = 0.0000
k₁(z) = 0.1(−0·0 − 1) = -0.1000
k₂(y) = 0.1(z₀ + k₁(z)) = 0.1(0 − 0.1) = -0.0100
k₂(z) = 0.1[−0.1(−0.1) − (1 + 0)] = -0.0990
y₁ = 1 + ½(0 − 0.01) = 0.9950
z₁ = 0 + ½(−0.1 − 0.0990) = -0.0995

Step 2 (x₁ = 0.1 → 0.2)

k₁(y) = 0.1(−0.0995) = -0.0100
k₁(z) = 0.1[−0.1(−0.0995) − 0.995] = -0.0985
k₂(y) = -0.0198,  k₂(z) = -0.0945
y₂ = 0.9801,  z₂ = -0.1960

Summary table

stepxyz=y'k₁(y)k₁(z)k₂(y)k₂(z)yₙ₊₁zₙ₊₁
00.00001.00000.00000.0000-0.1000-0.0100-0.09900.9950-0.0995
10.10000.9950-0.0995-0.0100-0.0985-0.0198-0.09450.9801-0.1960

Answer: y(0.1) ≈ 0.9950, y(0.2) ≈ 0.9801 (with y'(0.1) ≈ -0.0995, y'(0.2) ≈ -0.1960). The exact solution y = e^(−x²/2) gives 0.9950 and 0.9802.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Numerical Method chapter 6 questions →