---
title: "RK-2: y' = sin x + cos y"
subject: "Numerical Method"
chapter: 6
key: "semester_4/numerical_method:rk2-sinx-cosy"
source: https://www.bctengineer.com/q/semester_4/numerical_method/rk2-sinx-cosy
site: BCT Engineering
---

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

Numerical Method · Chapter 6: Solution of ordinary differential equations

- Asked in: 2073 Magh, 6 marks
- Video: [Runge kutta method 2nd order |Rk-2 method | Runge kutta method](https://www.youtube.com/watch?v=Y9EqalZP_6U) — Arya Anjum
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_4/numerical_method/rk2-sinx-cosy
- Whole chapter: https://www.bctengineer.com/md/semester_4/numerical_method/chapter-6

## Question

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.

## 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.

## Answer

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:

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


#### First step
```text
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)
| step | xₙ | yₙ | k₁ = h·f(xₙ,yₙ) | k₂ = h·f(xₙ+h, yₙ+k₁) | yₙ₊₁ = yₙ + (k₁+k₂)/2 |
|---|---|---|---|---|---|
| 0 | 0.0000 | 2.0000 | -0.2081 | 0.1300 | 1.9610 |
| 1 | 0.5000 | 1.9610 | 0.0495 | 0.2079 | 2.0897 |
| 2 | 1.0000 | 2.0897 | 0.1728 | 0.1798 | 2.2660 |
| 3 | 1.5000 | 2.2660 | 0.1785 | 0.0713 | 2.3909 |

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

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Range 0(0.5)2 gives?
   A. h=2
   B. h=0.5, two steps
   C. h=0.25
   D. h=0.5, four steps
   Answer: D. 0,0.5,1,1.5,2. (Key point: Steps)

2. Angles in?
   A. Radians
   B. Degrees
   C. Grads
   D. Turns
   Answer: A. Standard. (Key point: Units)

3. k1 at (0,2)?
   A. 0.5
   B. 0.5(sin0+cos2) = -0.2081
   C. -0.4162
   D. 0.2081
   Answer: B. cos2=-0.4161. (Key point: k1)

4. y1?
   A. 2
   B. 1.7919
   C. 1.9610
   D. 2.0897
   Answer: C. 2+(-0.2081+0.1300)/2. (Key point: y1)

## Related in Numerical Method

- [Program for RK-4 second order IVP](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Ark4-program-second-order) — Numerical Method, chapter 6
- [RK-4: y'' - 3y' + y = sin x](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Ark4-second-order-ivp-y12) — Numerical Method, chapter 6
- [RK-2: y' = 4e^(0.8x) - 0.5y](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Ark2-xy-prime) — Numerical Method, chapter 6
- [RK-2: y' = xy + y²](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Ark2-xy-y2) — Numerical Method, chapter 6, asked 2×
- [Program for RK-4 first order IVP](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Ark4-program-first-order) — Numerical Method, chapter 6
- [RK-2: y'' = y - x y'](https://www.bctengineer.com/question.md?key=semester_4%2Fnumerical_method%3Ark2-y-double-prime-y-xy) — Numerical Method, chapter 6, asked 2×

## Related in other subjects

- [Condition for x cosα + y sinα = p to touch ellipse](https://www.bctengineer.com/question.md?key=semester_1%2Fmathematics_i%3Aellipse-tangent-condition-xcos-ysin) — Mathematics I, chapter 3
- [Solve sin x dy/dx + y cos x = x sin x](https://www.bctengineer.com/question.md?key=semester_1%2Fmathematics_i%3Ade-sinx-dy-dx-y-cosx) — Mathematics I, chapter 4
- [Second derivatives of r with x=r cosθ, y=r sinθ](https://www.bctengineer.com/question.md?key=semester_2%2Fmathematics%3Asecond-derivatives-r-x-r) — Mathematics, chapter 1
- [Volume of cardioid r=a(1+cosθ) about initial line](https://www.bctengineer.com/question.md?key=semester_1%2Fmathematics_i%3Avolume-cardioid-1-plus-cos-initial-line) — Mathematics I, chapter 2, asked 6×
