Skip to main content

RK-2: y' = sin x + cos y

Short answer

With RK2 (Heun's method) and h=0.5, evaluating f(x,y)=sin x+cos y. Results: y(0.5)≈1.9610, y(1.0)≈2.0897, y(1.5)≈2.2660, y(2.0)≈2.3909.

Solve y' = sin x + cos y subject to initial condition y(0) = 2 in the range 0(0.5)2 using the Runge-Kutta second order method.

Given y' = sin x + cos y, y(0) = 2, range 0(0.5)2 means x = 0, 0.5, 1.0, 1.5, 2.0, so h = 0.5 (four steps). Angles are in radians.

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₂)

First step

k₁ = h·f(x₀, y₀) = 0.5·f(0.0000, 2.0000) = -0.2081
k₂ = h·f(x₀+h, y₀+k₁) = 0.5·f(0.5000, 1.7919) = 0.1300
y₁ = y₀ + (k₁+k₂)/2 = 2.0000 + (-0.2081 + 0.1300)/2 = 1.9610

All steps (h = 0.5)

stepxₙyₙk₁ = h·f(xₙ,yₙ)k₂ = h·f(xₙ+h, yₙ+k₁)yₙ₊₁ = yₙ + (k₁+k₂)/2
00.00002.0000-0.20810.13001.9610
10.50001.96100.04950.20792.0897
21.00002.08970.17280.17982.2660
31.50002.26600.17850.07132.3909

Answer: y(0.5) ≈ 1.9610, y(1) ≈ 2.0897, y(1.5) ≈ 2.2660, y(2) ≈ 2.3909

✓ Answer checked by Claude Opus 5.5 (high effort)

All Numerical Method chapter 6 questions →