📘 CodingMarble Learn

Numerical Methods: Finding Roots and Areas Step by Step

Some equations and areas cannot be found with a neat formula. Numerical methods get as close as we like with simple repeated steps: check a change of sign, halve the interval (bisection), slide down tangents (Newton-Raphson), repeat x = g(x) (fixed-point iteration), add up trapeziums for an area, and walk along a slope in small steps (Euler).

🎬 Step-by-step story

  1. Step 1: the curve y = x³ − x − 1 is below the x-axis at x = 1 and above it at x = 2. So it must cross zero in between. That crossing is the root.
  2. Step 2: bisection. Check the middle point, keep the half where the sign changes, and repeat. The interval halves every time.
  3. Step 3: Newton-Raphson. Draw the tangent at your guess and slide down it to the x-axis. That is your next, better guess.
  4. Step 4: trapezium rule. Cut the area under a curve into strips, treat each strip as a trapezium and add them up.
  5. Step 5: Euler's method. Know the slope rule and the start point, then walk forward in small straight steps.
  6. Step 6: your turn. Pick a method, change the number of steps and watch the answer get closer to the true value.

Tip: drag the 3D scene to turn it. Use two fingers to zoom.

🤔 Common doubts, cleared

Why must the function be continuous for the sign test?

A break lets the graph jump from below to above without touching zero, like y = 1/x. Only an unbroken curve is forced to cross the axis.

Why does bisection always work but go slowly?

It only uses the sign, not the size, of f. It never loses the root, but it shrinks the gap by just half each time.

Why is Newton-Raphson so fast?

Close to the root the tangent is almost the same as the curve, so the point where it hits the axis is very close to the real root. The error is roughly squared each step.

Why is the trapezium answer too big for y = x²?

The straight top of each strip sits above a curve that bends upwards, so every strip has a little extra area.

Why does Euler's answer fall below eˣ?

The slope of eˣ keeps increasing, but Euler uses the slope at the start of each step, which is the smallest slope in that step. So each step falls a bit short.

How many steps are enough?

Keep going until the answer stops changing at the accuracy you need. In free play, raise n and watch when the digits settle.

Why we need numerical methods

Some equations, like x³ − x − 1 = 0 or eˣ = 3x, have no simple formula for x. A numerical method is a set of simple steps that we repeat to get closer and closer to the answer. Each repeat is called an iteration.

Change of sign

If f(x) is continuous (no breaks or jumps) on [a, b], and f(a) and f(b) have opposite signs, then there is at least one root between a and b.

Example: f(1) = −1 and f(2) = 5, so x³ − x − 1 = 0 has a root between 1 and 2.

When the sign test fails

To show a root is 1.32 to 2 decimal places, check f(1.315) and f(1.325) have opposite signs.

Finding roots: bisection, Newton-Raphson and fixed-point iteration

Interval bisection

Start with [a, b] where the sign changes. Find the middle m = (a + b) ÷ 2. Keep the half that still has a sign change. Each step halves the width, so it always works, but it is slow: about 3 to 4 halvings per extra correct decimal place.

Newton-Raphson

xₙ₊₁ = xₙ − f(xₙ) ÷ f′(xₙ)

The tangent at xₙ is a straight line that hugs the curve. Where it meets the x-axis is the next guess. Near the root, the number of correct digits roughly doubles each step. It fails if f′(xₙ) = 0 (flat tangent, no crossing) or if the start is far away and the tangents jump off to another root.

Fixed-point iteration

Rearrange f(x) = 0 into x = g(x) and repeat xₙ₊₁ = g(xₙ). On a graph of y = x and y = g(x) this makes a staircase or a cobweb. It converges if |g′(x)| < 1 near the root. For x³ − x − 1 = 0, the form x = ∛(x + 1) converges, but x = x³ − 1 does not.

Writing it as an algorithm

In computing, bisection is a loop: while b − a > tolerance: m = (a + b)/2; if f(a)·f(m) < 0 then b = m else a = m. Storing each value in a list lets you see the sequence of estimates.

Numerical integration: the trapezium rule

To estimate ∫ₐᵇ f(x) dx, split [a, b] into n strips of width h = (b − a) ÷ n. Join the tops with straight lines, so each strip is a trapezium.

Area ≈ (h ÷ 2) × [y₀ + yₙ + 2(y₁ + y₂ + … + yₙ₋₁)]

The first and last heights are used once; every middle height is shared by two strips, so it is counted twice.

Other rules exist: the mid-ordinate rule uses rectangles at the middle of each strip, and Simpson's rule fits curves (parabolas) instead of straight lines.

Small steps: Euler's method for motion and growth

Often we know a rule for change (a differential equation), such as dy/dx = f(x, y), and a starting value. Euler's method walks forward in steps of size h:

xₙ₊₁ = xₙ + h, yₙ₊₁ = yₙ + h × f(xₙ, yₙ)

In physics this is the method of small steps: in each small time Δt, new velocity = old velocity + a × Δt, and new position = old position + v × Δt. A spreadsheet or a short program repeats this thousands of times to model a falling ball with air resistance or a cooling cup of tea.

Smaller steps give better answers but need more work. Errors also build up step by step, so check by halving h and seeing if the answer changes.

Errors, accuracy and choosing a method

MethodSpeedAlways works?
Bisectionslow, steadyyes, if a sign change exists
Newton-Raphsonvery fast near rootno: needs f′ ≠ 0 and a good start
Fixed-pointmediumonly if |g′| < 1

Try it at home

On a calculator type 1 and press =. Then type ∛(Ans + 1) and keep pressing =. Watch the numbers settle at 1.3247. You have just done fixed-point iteration.

Key formulas and definitions

Worked examples

1. Show that x³ − x − 1 = 0 has a root between 1 and 2.

f(1) = 1 − 1 − 1 = −1 < 0. f(2) = 8 − 2 − 1 = 5 > 0. f is a polynomial, so it is continuous. The sign changes, so there is a root in (1, 2).

2. Do two steps of bisection on f(x) = x³ − x − 1 starting from [1, 2].

m = 1.5: f(1.5) = 3.375 − 1.5 − 1 = 0.875 > 0, sign change is between 1 and 1.5, new interval [1, 1.5]. m = 1.25: f(1.25) = 1.953 − 1.25 − 1 = −0.297 < 0, new interval [1.25, 1.5].

3. Use Newton-Raphson with x₀ = 2 to find x₁ and x₂ for x³ − x − 1 = 0.

f′(x) = 3x² − 1. x₁ = 2 − 5 ÷ 11 = 1.5455. f(1.5455) = 1.1458, f′(1.5455) = 6.1655, so x₂ = 1.5455 − 1.1458 ÷ 6.1655 = 1.3596. (The root is 1.3247.)

4. Use xₙ₊₁ = ∛(xₙ + 1) with x₀ = 1 to find x₁, x₂, x₃.

x₁ = ∛2 = 1.2599. x₂ = ∛2.2599 = 1.3123. x₃ = ∛2.3123 = 1.3224. The values climb in a staircase towards 1.3247.

5. Estimate ∫₀² x² dx with the trapezium rule and 4 strips. Is it an over- or under-estimate?

h = 0.5. Heights: 0, 0.25, 1, 2.25, 4. Area ≈ 0.25 × [0 + 4 + 2(0.25 + 1 + 2.25)] = 0.25 × 11 = 2.75. Exact = 8/3 = 2.667. Over-estimate, because y = x² bends upwards.

6. dy/dx = y, y(0) = 1. Use Euler with h = 0.5 to estimate y(1). Find the percentage error.

y₁ = 1 + 0.5 × 1 = 1.5 (at x = 0.5). y₂ = 1.5 + 0.5 × 1.5 = 2.25 (at x = 1). True y(1) = e ≈ 2.718. Error = 0.468, relative error ≈ 0.468 ÷ 2.718 ≈ 17%.

7. A ball is dropped (a = 9.8 m/s²). Use small steps of Δt = 0.1 s to find v and s after 0.3 s.

Each step: v_new = v + 9.8 × 0.1 = v + 0.98; s_new = s + v × 0.1 (using the old v). t = 0.1: v = 0.98, s = 0. t = 0.2: v = 1.96, s = 0.098. t = 0.3: v = 2.94, s = 0.294 m. True s = ½ × 9.8 × 0.09 = 0.441 m; smaller steps reduce the gap.

Common mistakes

Practice quiz

1. f(1) = −2 and f(2) = 3, and f is continuous. What can you say?
2. The Newton-Raphson formula is:
3. Each bisection step makes the interval:
4. For a curve that bends upwards, the trapezium rule gives:
5. Euler's method moves from one point to the next using:

Practice: answer these yourself

Type or choose your answer, then press Check. Use a hint if you are stuck; the full solution appears after you answer.

Frequently asked questions

What is a numerical method in simple words?

A recipe of simple steps, repeated again and again, that gets closer and closer to an answer we cannot find exactly with algebra.

Which is better, bisection or Newton-Raphson?

Newton-Raphson is much faster near the root, but it needs the derivative and a good start. Bisection is slower but never fails once you have a sign change. Many programs start with bisection and finish with Newton.

Is the trapezium rule exact for straight lines?

Yes. If y is a straight line, each trapezium matches the area exactly, so there is no error.

Where this is taught

ItalySecondaria di secondo grado – classe 5ª (esame di Stato)Computation, networks and simulation
England (GCSE, A level)Year 13J Numerical methods
England (GCSE, A level)Year 13I Numerical methods
Germany (Bavaria)Jahrgangsstufe 11Profile area (science-technology school, 27 h)
FranceTerminaleAlgorithms

Learn first

Learn next

Related lessons

All Maths lessons