Free Numerical methods practice problems with diagrams, hints and full worked solutions. New values every time, at three levels: roots and interpolation, trapezoid and Simpson rules, Euler, Heun and Runge–Kutta.
Free practice problemEasy
Apply Newton–Raphson to f(x) = e−x − x with the starting value x₀ = 0. Find x2.
For a root: check the sign change for bisection, or compute f and f′ for Newton, and keep six or more digits in a table of iterates.
For a table value: interpolate linearly between the two neighbouring points.
For an integral: find h = (b − a)/n, list f at every node, apply the weights (1, 2, …, 2, 1 for trapezoid; 1, 4, 2, …, 4, 1 for Simpson with even n) and multiply by h/2 or h/3.
For an ODE: step from t₀ with yₙ₊₁ = yₙ + h·f(tₙ, yₙ) (Euler) or the averaged slope (Heun), one row per step, until you reach the requested t.
Common mistakes
Keeping the wrong half of the bisection interval, or miscounting the steps.
Writing x − f′/f instead of x − f/f′ in Newton–Raphson.
Giving interior nodes weight 1 in the trapezoid rule, or using Simpson with an odd number of strips.
Rounding iterates too early.
Doing one Euler step too few or too many to reach the final time.
Key formulas
Bisection
c = (a + b)/2, width after n steps (b − a)/2ⁿ
Newton–Raphson
xn+1 = xₙ − f(xₙ)/f′(xₙ)
Linear interpolation
y = y₁ + (y₂ − y₁)(x − x₁)/(x₂ − x₁)
Trapezoid rule
T = (h/2)[f₀ + 2f₁ + … + 2fn−1 + fₙ], h = (b − a)/n
Many equations and integrals have no formula for their answer: x = cos x, ∫e−x²dx, or most differential equations. Numerical methods compute the answer step by step to any accuracy you need.
The bisection method finds a root of f(x) = 0 on an interval [a, b] where f changes sign. Take the midpoint c = (a + b)/2 and keep the half where the sign still changes.
Example: f(x) = x² − 2 on [1, 2]. c₁ = 1.5 gives f = 0.25 > 0, so keep [1, 1.5]. c₂ = 1.25 gives f = −0.4375 < 0, so keep [1.25, 1.5]. Then c₃ = 1.375.
Each step halves the interval, so after n steps its width is (b − a)/2ⁿ. Bisection is slow but it always works once you have a sign change.
Self-check Bisection starts on an interval of length 1. How wide is the interval after 10 steps?
1/100
1/1024
1/10
1/20
Answer: 1/1024. Every step halves it: 1/2¹⁰ = 1/1024 ≈ 0.001. Dividing by 10 or 20 treats the halving as if it were additive.
2Newton–Raphson
Newton–Raphson follows the tangent line down to the x-axis and uses that crossing as the next guess:
xn+1 = xₙ − f(xₙ)/f′(xₙ)
For f(x) = x² − 2 with f′(x) = 2x and x₀ = 2: x₁ = 2 − 2/4 = 1.5, x₂ = 1.5 − 0.25/3 = 1.416667, x₃ = 1.414216. The root is √2 = 1.414214.
Near the root, Newton roughly doubles the number of correct digits in every step. It can fail when f′(xₙ) is close to 0, or when the start is far from the root.
Keep at least six digits in every iterate; rounding early stops the method from improving.
Self-check One Newton step for f(x) = x² − 5 from x₀ = 2 gives…
1.75
2.25
2.2
2.5
Answer: 2.25. f(2) = −1 and f′(2) = 4, so x₁ = 2 − (−1)/4 = 2.25. Adding −1/4 instead of subtracting it gives 1.75.
3Linear interpolation
Tables give values only at certain points. Linear interpolation draws a straight line between the two neighbouring table points:
y = y₁ + (y₂ − y₁)·(x − x₁)/(x₂ − x₁)
Example: the table gives f(1) = 2.0 and f(2) = 2.6. At x = 1.4 the fraction is 0.4, so f(1.4) ≈ 2.0 + 0.6·0.4 = 2.24.
Inverse interpolation works the same way the other way round: to find where y = 2.3, the fraction is (2.3 − 2.0)/0.6 = 0.5, so x ≈ 1.5.
4Trapezoid rule and Simpson’s rule
To integrate f from a to b, split the interval into n strips of width h = (b − a)/n with nodes x₀, x₁, …, xₙ.
The trapezoid rule replaces the curve in each strip by a straight line. Every interior node belongs to two strips, so it counts twice:
T = (h/2)[f₀ + 2f₁ + 2f₂ + … + 2fn−1 + fₙ]
Simpson’s rule fits parabolas through three nodes at a time. It needs an even n:
S = (h/3)[f₀ + 4f₁ + 2f₂ + 4f₃ + … + 4fn−1 + fₙ]
For ∫01 x² dx = 1/3 with n = 2 (h = 0.5): T = 0.25·(0 + 0.5 + 1) = 0.375, while S = (0.5/3)·(0 + 1 + 1) = 0.3333, exact.
The trapezoid error shrinks like h² and Simpson’s like h⁴: halving h makes Simpson about 16 times more accurate.
Self-check Which weights does the trapezoid rule give the nodes x₀, x₁, x₂, x₃?
1, 1, 1, 1
1, 2, 2, 1
1, 4, 2, 1
1, 4, 4, 1
Answer: 1, 2, 2, 1. The two end points belong to one strip and the interior points to two, so 1, 2, 2, 1 with the factor h/2. The 4s belong to Simpson’s rule.
5Euler and Heun for differential equations
For y′ = f(t, y) with y(t₀) = y₀, step forward in time with a step h. Euler’s method uses the slope at the start of each step:
yn+1 = yₙ + h·f(tₙ, yₙ)
Heun’s method (improved Euler) predicts with Euler, then averages the slopes at both ends: k₁ = f(tₙ, yₙ), k₂ = f(tₙ + h, yₙ + h·k₁), yn+1 = yₙ + (h/2)(k₁ + k₂).
Euler’s error is proportional to h, Heun’s to h². The classical Runge–Kutta method (RK4) uses four slopes and is accurate to h⁴.
Worked example
Solve y′ = y, y(0) = 1 with Euler’s method and h = 0.1 up to t = 0.3, and compare with the exact solution eᵗ.
1
Step 1
y₁ = 1 + 0.1·1 = 1.1
2
Step 2
y₂ = 1.1 + 0.1·1.1 = 1.21
3
Step 3
y₃ = 1.21 + 0.1·1.21 = 1.331
4
Compare
The exact value is e0.3 = 1.349859, so the global error is 0.0189. One Heun step from y₀ would give 1 + 0.05·(1 + 1.1) = 1.105 against e0.1 = 1.105171.
Answer
y(0.3) ≈ 1.331 with Euler; the error 0.019 shrinks roughly in proportion to h.
6Common mistakes and exam questions
Counting the first bisection midpoint as step 0, or keeping the wrong half of the interval.
Writing x − f′/f instead of x − f/f′ in Newton’s method.
Forgetting the factor 2 on interior nodes, or using h instead of h/2 in the trapezoid rule.
Using Simpson’s rule with an odd number of strips.
In Euler’s method, using the slope at the end of the step, or doing one step too few.
Easy: bisection, Newton iterations and interpolation in a table. Medium: the trapezoid and Simpson rules, their error and the number of strips needed. Hard: Euler, Heun and Runge–Kutta steps for differential equations.
Self-check y′ = 2y with y(0) = 1. What does one Euler step with h = 0.2 give?
1.2
1.49
1.4
2.4
Answer: 1.4. y₁ = 1 + 0.2·(2·1) = 1.4. Forgetting the factor 2 in the slope gives 1.2; 1.49 is the exact value e0.4.
The bisection method starts on an interval of length 4. Every step halves the interval. How many steps n are needed at least before the interval is shorter than 0.0001?
b − a = 4ε = 0.0001
Find n
Show hints
After n steps the interval has length (b − a)/2ⁿ.
Solve 4/2ⁿ < 0.0001, so 2ⁿ > 40000.
n > log₂(40000) = 15.29
Show the answer and the step-by-step solution
Root finding and interpolation: bisection keeps an interval [a, b] on which f changes sign; each step takes the midpoint c = (a + b)/2 and keeps the half where the sign still changes, so after n steps the interval is (b − a)/2ⁿ wide. Newton–Raphson follows the tangent line to the axis: xn+1 = xn − f(xn)/f′(xn); near a simple root it roughly doubles the number of correct digits per step. Linear interpolation between two table points: y = y₁ + (y₂ − y₁)(x − x₁)/(x₂ − x₁).
Condition
4/2ⁿ < 0.0001 → 2ⁿ > 40000
Logarithm
n > ln(40000)/ln 2 = 15.29
n = 16
Check
2¹⁵ = 32768 < 40000 < 2¹⁶ = 65536
Answer
n = 16
Example 2Medium
Approximate ∫01.5 √(1 + x³) dx with the trapezoid rule using n = 3 strips. Give T.
f(x) = √(1 + x³)[a, b] = [0, 1.5]n = 3
Find T
Show hints
h = (1.5 − 0)/3 = 0.5; the nodes are 0, 0.5, 1, 1.5.
Weights: 1, 2, 2, …, 2, 1; T = (h/2)·Σ wᵢfᵢ.
The weighted sum is Σ wᵢfᵢ = 8.041398.
Show the answer and the step-by-step solution
Numerical integration: split [a, b] into n strips of width h = (b − a)/n with nodes x₀ … xₙ. Trapezoid rule: T = (h/2)[f₀ + 2f₁ + 2f₂ + … + 2fn−1 + fₙ]. Simpson's rule (n even): S = (h/3)[f₀ + 4f₁ + 2f₂ + 4f₃ + … + 4fn−1 + fₙ]. The trapezoid error shrinks like h² (bound (b − a)h²·M/12 with M = max|f″|), Simpson's like h⁴, so Simpson is usually far more accurate for the same nodes.
Numerical solution of y′ = f(t, y): Euler's method steps along the slope at the start of each step: yn+1 = yₙ + h·f(tₙ, yₙ). Heun's method (improved Euler) averages the slope at the start and at an Euler prediction: k₁ = f(tₙ, yₙ), k₂ = f(tₙ + h, yₙ + h·k₁), yn+1 = yₙ + (h/2)(k₁ + k₂). The classical Runge–Kutta method (RK4) combines four slopes: yn+1 = yₙ + (h/6)(k₁ + 2k₂ + 2k₃ + k₄). The global error of Euler is proportional to h, Heun's to h², RK4's to h⁴.
Many equations and integrals have no formula for their answer: x = cos x, ∫e−x²dx, or most differential equations. Numerical methods compute the answer step by step to any accuracy you need.
The bisection method finds a root of f(x) = 0 on an interval [a, b] where f changes sign. Take the midpoint c = (a + b)/2 and keep the half where the sign still changes.
How do I solve Numerical methods problems step by step?
For a root: check the sign change for bisection, or compute f and f′ for Newton, and keep six or more digits in a table of iterates.
For a table value: interpolate linearly between the two neighbouring points.
For an integral: find h = (b − a)/n, list f at every node, apply the weights (1, 2, …, 2, 1 for trapezoid; 1, 4, 2, …, 4, 1 for Simpson with even n) and multiply by h/2 or h/3.
For an ODE: step from t₀ with yₙ₊₁ = yₙ + h·f(tₙ, yₙ) (Euler) or the averaged slope (Heun), one row per step, until you reach the requested t.
What are common mistakes in Numerical methods?
Keeping the wrong half of the bisection interval, or miscounting the steps.
Writing x − f′/f instead of x − f/f′ in Newton–Raphson.
Giving interior nodes weight 1 in the trapezoid rule, or using Simpson with an odd number of strips.
Rounding iterates too early.
Doing one Euler step too few or too many to reach the final time.
What do the Numerical methods exercises cover?
Easy: roots and interpolation
Medium: trapezoid and Simpson rules
Hard: Euler, Heun and Runge–Kutta
Every problem has new values, so you learn the method instead of an answer. Stuck? Open a small hint first, and the full explanation only when you need it.
How practising works
Every problem has new values, so you learn the method instead of an answer.
Stuck? Open a small hint first, and the full explanation only when you need it.
Your progress, mistakes and saved problems are kept, so you can review before the exam.