Numerical Methods Lab
Seven numerical methods with their full iteration tables. Newton–Raphson, bisection and secant find roots, Euler and RK4 step differential equations, and the trapezoid, midpoint, Simpson and finite-difference rules integrate and differentiate, with error columns that show each method converging.
How to Use
- Pick a method, or one of the examples below the inputs.
- Type the function: f(x) for root finding, integration and differentiation, or the right-hand side of dy/dx = f(x, y) for Euler and RK4.
- Set the parameters that appear: a start x₀ for Newton, two starts for secant, an interval [a, b] where f changes sign for bisection, a step h and end point for the ODE methods, and n intervals for integration.
- Read the result and the readouts, then the iteration table in Show Work: one row per step, with the update and an error column (|Δx|, the half-interval, or the gap to the exact value).
- Change a start, a tolerance or a step size and compare: Newton finds the root of x³ − x − 2 from 1.5 in 3 steps, bisection on [1, 2] needs 20.
Worked Example
Newton–Raphson on x³ − x − 2 from x₀ = 1.5 (the default). f(1.5) = −0.125 and f′(1.5) = 3(1.5)² − 1 = 5.75, so x₁ = 1.5 + 0.125/5.75 = 1.5217391. The next step moves by 0.00036 and the one after by 9.9 × 10⁻⁸, below the tolerance of 10⁻⁶, so the method stops after 3 iterations at x ≈ 1.5213797, where f(x) is about 4.5 × 10⁻¹⁴.
Bisection on the same equation over [1, 2]. f(1) = −2 and f(2) = 4 have opposite signs. The midpoint 1.5 gives −0.125, so the root is in [1.5, 2]; 1.75 gives 1.609375, so it is in [1.5, 1.75]; and so on. Each step halves the interval, so it takes 20 steps to get the half-width below 10⁻⁶: x ≈ 1.5213804, with half-width 9.5 × 10⁻⁷.
The common mistake: making h as small as possible. The central difference for the derivative of sin x at x = 1 has error 9.0 × 10⁻⁶ with h = 0.01 and 9.0 × 10⁻¹⁰ with h = 0.0001, but with h = 10⁻⁷ the error is back up to 1.9 × 10⁻¹⁰, about 17 times worse than at h = 10⁻⁵, because subtracting two nearly equal values of sin loses digits.
Show Work
Formulas
Where the Methods Came From
Isaac Newton described his root-finding method in De analysi, written in 1669 but not published until 1711, and applied it only to polynomials. Joseph Raphson published a simpler, purely algebraic version in 1690, which is why both names are attached. Bisection rests on the intermediate value theorem, which Bernard Bolzano proved in 1817: a continuous function that changes sign on [a, b] must cross zero there.
Thomas Simpson published his integration rule in 1743, although Johannes Kepler had used an equivalent rule for the volume of wine barrels in 1615. For differential equations, Leonhard Euler gave the step-by-step method in 1768, Carl Runge published a higher-order method in 1895, and Wilhelm Kutta completed the fourth-order scheme known as RK4 in 1901.
About This Tool
The Numerical Methods Lab runs the methods taught in a first numerical analysis course and prints every iteration, not just the answer, so the convergence rate is visible. Newton uses the exact symbolic derivative rather than a finite difference, and integration and differentiation compare their results with the exact value whenever one can be found.
Everything runs in your browser; nothing is uploaded.
Related tools: Euler’s Method Calculator, Integral Calculator, and Linear Interpolation Calculator.
Frequently Asked Questions
Which root finder should I use?
Bisection always converges when f(a) and f(b) have opposite signs, but only halves the interval each step. Newton converges fastest but needs a good start; secant is nearly as fast and needs no derivative. On x³ − x − 2 with tolerance 10⁻⁶, Newton from 1.5 takes 3 iterations, secant from 1 and 2 takes 7, and bisection on [1, 2] takes 20; all reach x = 1.52138.
How does Newton–Raphson work here?
It iterates xₙ₊₁ = xₙ − f(xₙ)/f′(xₙ) with the exact symbolic derivative, here f′ = 3x² − 1. From 1.5 the first step is 1.5 − (−0.125)/5.75 = 1.5217391, and the |Δx| column reads 0.0217, 0.00036, then 9.9 × 10⁻⁸: the number of correct digits roughly doubles each step. If f′(xₙ) = 0, as for x² − 4 started at 0, the step is undefined and the tool says so.
Euler or Runge–Kutta?
RK4, unless you are studying Euler itself. For y′ = x + y with y(0) = 1 and h = 0.1, Euler reaches 3.1874849 at x = 1 and RK4 reaches 3.4365595; the exact value is 2e − 2 = 3.4365637, so Euler is off by 0.249 and RK4 by 0.0000042. RK4 costs four slope evaluations per step instead of one, but its error falls like h⁴ instead of h.
How accurate is Simpson’s rule?
Its error falls like h⁴, and it is exact for cubics: ∫₀¹ (x³ − x − 2) dx gives −2.25 with n = 8, where the trapezoid rule is off by 0.0039. For ∫₀¹ e^(−x²) dx, which has no elementary antiderivative, n = 10 gives trapezoid 0.746210796, midpoint 0.747130878 and Simpson 0.746824948; the true value is 0.746824133, so Simpson is within 8.2 × 10⁻⁷. An odd n is rounded up to the next even number for Simpson.
Why does a smaller h make the derivative worse?
Rounding. The central difference error falls like h², so for sin x at x = 1 it is 9.0 × 10⁻⁶ at h = 0.01 and 9.0 × 10⁻¹⁰ at h = 0.0001. Below about h = 10⁻⁵, though, f(x + h) and f(x − h) agree in so many digits that their difference loses precision, and the error rises again to 1.9 × 10⁻¹⁰ at h = 10⁻⁷. The table shows six step sizes, each ten times smaller, so you can see both effects.
How do I use the Numerical Methods Lab?
Just type your numbers. The answer shows up right away — there is no button to press. Change anything and it updates by itself.
Do I need to install or sign up for anything?
Not at all — it runs in the browser with nothing to install and no account. After it loads once, it even works without an internet connection.
Is my information private?
Yes. Everything happens in your browser. Nothing you type is sent to a server or saved anywhere.
Common Use Cases
Comparing root finders
x³ − x − 2: Newton in 3 iterations, secant in 7, bisection in 20.
Fixed points
cos x = x has the solution 0.73908513: 4 Newton steps from 1, 5 secant steps from 0 and 1.
Checking your own code
Match an RK4 implementation row by row: k₁ to k₄ and yₙ₊₁ for every step.
Integrals with no formula
∫₀¹ e^(−x²) dx ≈ 0.746824948 by Simpson’s rule with n = 10.
Error analysis
Watch the central-difference error fall 100 times for every 10 times smaller h, until rounding takes over.
Last updated: