Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Part 3: Taylor Series, Error Order, and Derivative Methods

Module 1: Foundations of Discrete Computing | COMP 521

Part 1 showed how finite differences arise from Taylor series. Part 2 showed why floating-point arithmetic limits accuracy. Part 3 puts those ideas together: verify the theory numerically, build custom formulas on purpose, and decide when finite differences are the wrong tool.

Learning Objectives

By the end of this section, you will be able to:

Introduction: From Theory to Practice

Why this matters: numerical analysis becomes useful only when it changes what you do in code. This reading is where the theory from Module 1 turns into practical method design and scientific judgment.

The main question is no longer “what is a derivative?” The main question is “how should I compute a derivative in a real scientific workflow, and how do I know the result is trustworthy?” Taylor series gives the truncation model, floating-point arithmetic gives the round-off model, and numerical experiments tell us whether the implemented method actually behaves the way the theory predicts.

<Figure size 700x450 with 1 Axes>

What to notice: the right-hand side of each curve shows truncation error, so the slope reveals the method order. The left-hand upturn appears when round-off begins to dominate, which is why making hh smaller eventually stops helping.

Interpretation: the preview answers the opening prediction in two stages. On the truncation-dominated side, higher-order methods win because their error falls faster with hh. On the round-off-dominated side, even a formally better method can lose if the subtraction becomes numerically brittle.

Build a finite polynomial before taking an infinite limit

Why this matters: a Taylor polynomial is a controlled local approximation. Writing an infinite sum with an equals sign makes a stronger claim, and we should know what justifies it before using it in a calculation.

Near x0x_0, write x=x0+hx=x_0+h and seek Pm(h)=a0+a1h+⋯+amhmP_m(h)=a_0+a_1h+\cdots+a_mh^m. Match the value and derivatives of ff at x0x_0. At h=0h=0, the kkth derivative of the polynomial is k!akk!a_k, so

ak=f(k)(x0)k!,Pm(h)=∑k=0mf(k)(x0)k!hk.a_k=\frac{f^{(k)}(x_0)}{k!},\qquad P_m(h)=\sum_{k=0}^m\frac{f^{(k)}(x_0)}{k!}h^k.

The constant matches the value, the linear term adds slope, and the quadratic term adds curvature. Matching at one point does not make two functions equal throughout an interval. Taylor’s theorem supplies the missing statement: if ff has continuous derivatives through order m+1m+1 on the intervening interval,

f(x0+h)=Pm(h)+Rm+1(h),Rm+1(h)=f(m+1)(ξ)(m+1)!hm+1f(x_0+h)=P_m(h)+R_{m+1}(h),\qquad R_{m+1}(h)=\frac{f^{(m+1)}(\xi)}{(m+1)!}h^{m+1}

for some ξ\xi between x0x_0 and x0+hx_0+h. The equality includes the remainder. Dropping it gives an approximation. A known derivative bound Mm+1M_{m+1} gives

∣f(x0+h)−Pm(h)∣≤Mm+1(m+1)!∣h∣m+1.|f(x_0+h)-P_m(h)|\le\frac{M_{m+1}}{(m+1)!}|h|^{m+1}.

At fixed degree this controls the error as hh shrinks. At fixed hh, increasing the degree improves a general function’s approximation only if the remainder actually becomes smaller. An infinite Taylor series equals the function where Rm+1→0R_{m+1}\to0 as m→∞m\to\infty; smoothness alone does not ensure that limit. For example, the smooth function f(x)=e−1/x2f(x)=e^{-1/x^2} for x≠0x\ne0, with f(0)=0f(0)=0, has every derivative zero at 0. Its Taylor series there is zero, but the function is positive away from 0. Finite local error statements and equality to an infinite series are different claims.

Predict → Run → Explain: how much accuracy does another term buy?

For f(x)=exf(x)=e^x at x0=0x_0=0, every derivative at the expansion point is 1. For 0≤h≤10\le h\le1, the next derivative is bounded by ee, so the remainder is at most ehm+1/(m+1)!e h^{m+1}/(m+1)!. Predict which requires more terms for the same absolute error: h=0.2h=0.2 or h=1h=1.

h=0.2, degree=1: error=2.140e-02, bound=5.437e-02
h=0.2, degree=2: error=1.403e-03, bound=3.624e-03
h=0.2, degree=4: error=2.758e-06, bound=7.249e-06
h=0.2, degree=8: error=1.440e-12, bound=3.835e-12
h=1.0, degree=1: error=7.183e-01, bound=1.359e+00
h=1.0, degree=2: error=2.183e-01, bound=4.530e-01
h=1.0, degree=4: error=9.948e-03, bound=2.265e-02
h=1.0, degree=8: error=3.059e-06, bound=7.491e-06
Exponential Taylor polynomials track the curve near zero; residuals and derivative-based bounds decrease with degree on the positive interval.

Left: matching value, slope, and curvature improves the local shape. Right: solid residual curves are compared with dashed remainder bounds for degrees 1, 2, and 4 on 0<h≤10<h\le1. The bound is an upper limit, not the observed error.

Open full-size figure

Every added term in this recurrence costs one multiplication, one division, and one addition. Degree 8 uses 24 scalar arithmetic operations after initialization, compared with 6 for degree 2. That is an operation count, not a timing benchmark, and general derivatives may be expensive to obtain. Choose a degree from an accuracy target and a justified bound, then check the computed error. More arithmetic can eventually add rounding without useful accuracy. Optimized library functions need not use this classroom algorithm.

Verifying Error Predictions

Why this matters: if a method does not show the predicted slope in a controlled test, you should not trust it in a harder scientific problem.

For this experiment, the analytical information is known exactly. We choose f(x)=sin⁡xf(x)=\sin x and evaluate the derivative at x=1 radx=1\,\mathrm{rad}, so the true derivative is f′(x)=cos⁡xf'(x)=\cos x and the exact value is cos⁡(1)\cos(1).

What is approximated numerically is the derivative itself, using forward, central, and fourth-order central finite-difference formulas evaluated over a range of step sizes.

What the theory predicts is not just “one method is better.” It predicts specific slopes on a log-log plot, specific convergence ratios under halving, and a specific failure mode when round-off takes over.

The forward-difference truncation model is

Etrunc(h)=O(h).E_{\mathrm{trunc}}(h) = O(h).

This equation says that, before round-off dominates, halving hh should reduce the forward-difference truncation error by about a factor of 2.

The central-difference truncation model is

Etrunc(h)=O(h2).E_{\mathrm{trunc}}(h) = O(h^2).

This equation says that, before round-off dominates, halving hh should reduce the central-difference truncation error by about a factor of 4.

The fourth-order central-difference truncation model is

Etrunc(h)=O(h4).E_{\mathrm{trunc}}(h) = O(h^4).

This equation says that, before round-off dominates, halving hh should reduce the fourth-order central-difference truncation error by about a factor of 16.

More generally, if the leading error behaves like

error∝hp,\text{error} \propto h^p,

this equation says that the error is controlled by a power law in the step size.

Then halving the step size changes the leading error by about

E(h)E(h/2)≈2p.\frac{E(h)}{E(h/2)} \approx 2^p.

This equation turns a theoretical order pp into a practical convergence-ratio check that you can measure from computed data.

For forward difference, Taylor series predicts

f(x+h)−f(x)h−f′(x)≈h2f′′(x).\frac{f(x+h)-f(x)}{h} - f'(x) \approx \frac{h}{2} f''(x).

This equation says that the leading forward-difference error is proportional to the second derivative of the function at the evaluation point.

For f(x)=sin⁡xf(x)=\sin x, we have f′′(x)=−sin⁡xf''(x)=-\sin x, so at x=1 radx=1\,\mathrm{rad} the prediction becomes

f(x+h)−f(x)h−f′(x)≈−h2sin⁡x.\frac{f(x+h)-f(x)}{h} - f'(x) \approx -\frac{h}{2}\sin x.

This equation says that the forward-difference error should be negative at x=1 radx=1\,\mathrm{rad} because sin⁡(1)>0\sin(1) > 0.

For central difference, Taylor series predicts

f(x+h)−f(x−h)2h−f′(x)≈h26f′′′(x).\frac{f(x+h)-f(x-h)}{2h} - f'(x) \approx \frac{h^2}{6} f'''(x).

This equation says that the leading central-difference error is proportional to the third derivative and therefore falls more quickly with hh.

For f(x)=sin⁡xf(x)=\sin x, we have f′′′(x)=−cos⁡xf'''(x)=-\cos x, so at x=1 radx=1\,\mathrm{rad} the prediction becomes

f(x+h)−f(x−h)2h−f′(x)≈−h26cos⁡x.\frac{f(x+h)-f(x-h)}{2h} - f'(x) \approx -\frac{h^2}{6}\cos x.

This equation says that the central-difference error should also be negative here, but much smaller for moderate hh because it is second order rather than first order.

The experiment below checks four things at once:

This cell reuses the shared helper functions defined earlier.

What students should compare in the output: the slope on the right side of each curve, the ordering of the methods in the truncation-dominated regime, and the left-side upturn where shrinking hh stops helping.

<Figure size 700x450 with 1 Axes>

The plotted curves should show straight-line truncation behavior on the right and round-off upturn on the left. That is the practical version of the theory from Parts 1 and 2.

This cell reuses the shared helper functions defined earlier.

What the table is checking: whether halving hh changes the error by about the factor Taylor series predicts before round-off interferes.

Observed convergence orders before round-off dominates
----------------------------------------------------------------
method              h      abs error     observed p
forward      1.00e-01      4.294e-02              -
             5.00e-02      2.126e-02          1.014
             2.50e-02      1.057e-02          1.007
             1.25e-02      5.273e-03          1.004
central      1.00e-01      9.001e-04              -
             5.00e-02      2.251e-04          1.999
             2.50e-02      5.628e-05          2.000
             1.25e-02      1.407e-05          2.000
central4     1.00e-01      1.799e-06              -
             5.00e-02      1.125e-07          3.999
             2.50e-02      7.035e-09          4.000
             1.25e-02      4.397e-10          4.000

This table checks whether the measured order approaches the Taylor-series prediction before floating-point effects interfere.

The takeaway is simple: when the observed slope matches the predicted slope in the right regime, the implementation and the theory are telling the same story.

Designing Custom Finite Difference Formulas

Why this matters: real scientific codes often need derivatives at boundaries, interfaces, or irregular data locations where the standard centered stencil is unavailable.

Student mental model: designing a stencil is solving a cancellation problem with Taylor coefficients.

Suppose we want f′′(x)f''(x) at a boundary point and only have access to f(x)f(x), f(x+h)f(x+h), and f(x+2h)f(x+2h). Boundary points force one-sided formulas because the data do not exist symmetrically on both sides.

The derivative we want is the second derivative f′′(x)f''(x). The unwanted terms are f(x)f(x), f′(x)f'(x), and as many higher-order terms as possible. The strategy is to choose a linear combination that cancels the unwanted Taylor coefficients and leaves the target derivative behind.

What is known exactly in this section is the Taylor expansion of each nearby sample. What is approximated numerically is the boundary second derivative, where symmetry is unavailable. What the theory predicts is that the missing left-hand data will cost accuracy.

Start with the forward Taylor expansion:

f(x+h)=f(x)+hf′(x)+h22f′′(x)+h36f′′′(x)+O(h4).f(x+h)=f(x)+h f'(x)+\frac{h^2}{2}f''(x)+\frac{h^3}{6}f'''(x)+O(h^4).

This equation says that a sample one step away contains the value, slope, curvature, and higher-order corrections.

Now write the expansion two steps away:

f(x+2h)=f(x)+2hf′(x)+2h2f′′(x)+4h33f′′′(x)+O(h4).f(x+2h)=f(x)+2h f'(x)+2h^2 f''(x)+\frac{4h^3}{3}f'''(x)+O(h^4).

This equation says that moving farther away changes the Taylor coefficients in a predictable way, which is exactly what lets us engineer cancellations.

To remove the first-derivative term, form the combination f(x+2h)−2f(x+h)+f(x)f(x+2h)-2f(x+h)+f(x):

f(x+2h)−2f(x+h)+f(x)=h2f′′(x)+h3f′′′(x)+O(h4).f(x+2h)-2f(x+h)+f(x)=h^2 f''(x)+h^3 f'''(x)+O(h^4).

This equation says that the constant and first-derivative terms cancel, leaving the second derivative as the leading surviving term.

Now divide by h2h^2:

f′′(x)≈f(x+2h)−2f(x+h)+f(x)h2.f''(x) \approx \frac{f(x+2h)-2f(x+h)+f(x)}{h^2}.

This equation gives a one-sided approximation to the second derivative using only boundary-accessible function values.

The truncation model for this stencil is

f′′(x)=f(x+2h)−2f(x+h)+f(x)h2+O(h).f''(x) = \frac{f(x+2h)-2f(x+h)+f(x)}{h^2} + O(h).

This equation says that the one-sided second-derivative stencil is only first-order accurate, which is the price we pay for losing symmetry at the boundary.

This cell reuses the shared helper functions defined earlier.

What students should compare in the output: how the absolute error shrinks when hh is halved, and whether the measured order stays near 1 instead of drifting toward the centered-method orders from earlier.

One-sided second derivative for f(x) = e^x at x = 0
----------------------------------------------------------------
         h         approx      abs error     observed p
  1.00e-01     1.10609220      1.061e-01              -
  5.00e-02     1.05149013      5.149e-02          1.043
  2.50e-02     1.02536852      2.537e-02          1.021
  1.25e-02     1.01259164      1.259e-02          1.011

This numerical check should show observed order near 1, which confirms the first-order Taylor prediction for the boundary stencil.

This confirms the first-order convergence predicted by Taylor series. Losing symmetry costs an order of accuracy.

the lack of symmetry at the boundary forces all of the sample points onto one side of $x$, so the stencil loses the cancellation pattern that made the centered formulas more accurate.

Figure 2:What to notice in this figure: the lack of symmetry at the boundary forces all of the sample points onto one side of xx, so the stencil loses the cancellation pattern that made the centered formulas more accurate.

Open full-size figure

General Recipe for Custom Methods

Why this matters: once you see stencil design as a systematic process, you can build methods for boundaries, PDE grids, and irregular geometries instead of memorizing isolated formulas.

Use this recipe when you need a custom stencil:

  1. Choose the sample locations your problem actually provides, such as x−hx-h, xx, x+hx+h, or a one-sided boundary set.

  2. Expand each sample value about the point where you want the derivative.

  3. Assign unknown stencil weights to the samples you plan to combine.

  4. Match the target derivative by forcing its coefficient to become 1 after the appropriate division by hh.

  5. Cancel the lower-order unwanted terms, starting with constants and then moving through the derivative terms you do not want.

  6. Identify the first term that survives, because that term sets the truncation order.

  7. Verify the observed order numerically on a smooth function with a known derivative.

The structured summary below is the compact version of the workflow:

Design stepQuestion to askTypical output
GeometryWhich sample points are available?centered or one-sided stencil points
Taylor modelWhat derivatives appear in each expansion?coefficient table in powers of hh
CancellationWhich terms must vanish?a linear system for the stencil weights
AccuracyWhich term survives first?the order pp in error∝hp\text{error} \propto h^p
ValidationDoes the implementation show the predicted slope?numerical verification against the expected order

This is a stencil-design workflow, not a formula to memorize. This same logic reappears in PDE finite-difference stencils, ghost-cell formulas, and boundary-condition enforcement.

When NOT to Use Numerical Derivatives

Why this matters: good numerical work includes knowing when not to apply a familiar tool.

Analytical Derivatives Available

Why this matters: if symbolic differentiation is easy and the expression is stable, finite differences are usually inferior because they add truncation and round-off error to a problem that did not need them.

Consider the polynomial

f(x)=x3−2x2+5x−3.f(x)=x^3-2x^2+5x-3.

This equation defines a function whose derivative is easy to compute exactly by hand.

The analytical derivative is

f′(x)=3x2−4x+5.f'(x)=3x^2-4x+5.

This equation says that we can evaluate the derivative directly, with no step-size tuning and no finite-difference approximation error.

This cell reuses the shared helper functions defined earlier.

What students should compare in the output: the exact derivative, the finite-difference approximation, and the small but nonzero difference that appears only because the numerical method introduces approximation and floating-point error.

Exact derivative:          9.000000000000
Finite-difference result:  9.000000000103
Absolute difference:       1.034e-10

Finite differences are often a useful fallback, not the gold standard.

Noisy Data

Why this matters: differentiation amplifies high-frequency variation, so even modest measurement noise can overwhelm the derivative.

Suppose a velocity curve or luminosity signal is measured with small observational noise. The function values may still look reasonable, but numerical differentiation magnifies the noise because differences divide by a small spacing.

What is known exactly here is the smooth underlying signal. What is approximated numerically is the derivative of noisy samples, and what theory predicts is amplification of the shortest-scale fluctuations.

This cell reuses the NumPy and Matplotlib imports from the setup cell, but does not depend on the shared helper functions.

<Figure size 700x450 with 1 Axes>

What to notice: the derivative curve becomes jagged even though the original noise is mild. The amplification is strongest at small scales because differencing divides by the sample spacing, which is exactly why direct numerical derivatives are dangerous on noisy measurements.

If the scientific quantity is noisy, smoothing, model fitting, or a weak-form approach is often more defensible than direct finite differencing.

The takeaway is that a visually reasonable signal can still produce a scientifically misleading derivative.

Expensive Function Evaluations

Why this matters: some “functions” are really whole simulations, optimization solves, or Monte Carlo estimates.

A single function evaluation might mean integrating an ODE system for a stellar model, running a radiative-transfer iteration, or estimating a likelihood with thousands of random samples. In that setting, even a central difference costs two expensive evaluations per scalar derivative, and higher-order stencils cost more.

As a concrete example, suppose one function call means integrating an orbit for 105 timesteps or solving a PDE relaxation to tolerance. Then a gradient with 100 parameters already requires hundreds of such solves if you use finite differences.

The takeaway is that cost alone can make an otherwise valid derivative estimate a poor scientific choice.

You Need Many Derivatives

Why this matters: finite differences scale linearly with the number of differentiated inputs, which becomes absurd for modern optimization problems.

If you need derivatives with respect to many parameters, the cost explodes:

parameters =        10  forward calls =        11  central calls =        20
parameters =     10000  forward calls =     10001  central calls =     20000
parameters =   1000000  forward calls =   1000001  central calls =   2000000

Forward differences share one baseline evaluation across all coordinates, so a fresh gradient costs n+1n+1 calls. If the baseline is already cached, the additional cost is nn. Central differences need 2n2n calls.

For neural networks or large inverse problems, finite differences for millions of parameters is not merely inconvenient. It is computationally unreasonable.

The takeaway is that scaling with parameter count is a scientific design constraint, not just an implementation nuisance.

Automatic Differentiation

Why this matters: automatic differentiation is one of the core modern tools for optimization, inverse problems, and machine learning.

Automatic differentiation differentiates the implemented computation itself. It is not symbolic algebra, and it is not finite differencing. It is also not taking derivatives of some idealized mathematical object floating in Platonic heaven. Instead, it applies the chain rule to the executed computation graph and returns derivatives accurate up to the floating-point precision of that implemented computation.

What is known exactly here is the code path you actually execute. What is approximated or constrained numerically is everything imposed by floating-point arithmetic, control flow, and the smoothness of the implemented operations.

Here is the clean distinction:

MethodDerivative qualityCostTypical useLimitations
Symbolic differentiationexact algebraic derivative before numerical evaluationcan become algebraically cumbersomesimple closed-form expressions, computer algebramay be unavailable for black-box code or complex control flow
Finite differencesapproximate derivative with truncation and round-off errormultiple function evaluations per derivativeblack-box verification, quick experiments, small parameter countssensitive to hh, noise, and computational cost
Automatic differentiationderivative of the implemented computation to machine precisionoften comparable to a small multiple of function evaluation costoptimization, neural networks, inverse problemsneeds AD-compatible code and still inherits floating-point and differentiability limits

This conceptual preview reuses finite_diff and math from the shared setup above. It is intentionally not a full dependency-heavy tutorial.

import jax
import jax.numpy as jnp


def jax_function(x):
    """Return a smooth function for an automatic-differentiation preview."""
    return jnp.sin(x) * jnp.exp(-x**2) + x**3


def analytical_derivative(x: float) -> float:
    """Return the analytical derivative of the preview function."""
    return (
        math.cos(x) * math.exp(-x**2)
        - 2.0 * x * math.sin(x) * math.exp(-x**2)
        + 3.0 * x**2
    )


x_ad = 1.0
ad_value = float(jax.grad(jax_function)(x_ad))
exact_value = analytical_derivative(x_ad)
fd_value = finite_diff(lambda z: math.sin(z) * math.exp(-(z**2)) + z**3, x_ad, 1.0e-5)

print(f"Analytical derivative:      {exact_value:.12f}")
print(f"Automatic differentiation: {ad_value:.12f}")
print(f"Finite difference:         {fd_value:.12f}")
print(f"|AD - exact|:              {abs(ad_value - exact_value):.3e}")
print(f"|FD - exact|:              {abs(fd_value - exact_value):.3e}")

This preview is intentionally shown without in-page execution so the reading stays lightweight and render-stable. The key point is narrower and more honest: AD removes finite-difference truncation error and step-size tuning, but it still inherits the floating-point and smoothness limits of the implemented computation.

The takeaway is that AD is powerful because it matches the code you run, not because it transcends numerical analysis.

When to Use Each Method

Why this matters: decision frameworks are useful only if they reflect actual computational trade-offs.

Use this checklist as a heuristic, not a law:

  1. Check smoothness and noise first, including for a black-box function. If the data are noisy, model or smooth the signal and test sensitivity to that choice before trusting its derivative. At a non-smooth point, establish whether the derivative you want exists.

  2. If an analytical derivative is easy to derive and evaluate stably, use it.

  3. If the function is a smooth black box and you only need a few derivatives, finite differences may be reasonable; sweep the step size to check convergence and noise amplification.

  4. If you need many derivatives and have access to differentiable source code, automatic differentiation is usually the right tool.

  5. If the function evaluation is extremely expensive, rethink whether derivative-free reformulation, surrogate modeling, or adjoint methods would be better.

The right choice depends on smoothness, cost, noise, and access to the source code of the implemented computation.

MethodBest whenMain strengthMain weaknessTypical COMP 521 use case
Analytical derivativeclosed-form math is availableno truncation error and no step-size tuningmay be tedious or unavailablechecking toy models and benchmark functions
Finite differencesblack-box function, small derivative counteasy to implement and easy to inspectsensitive to hh, noise, and evaluation costvalidating convergence ideas and debugging
Automatic differentiationdifferentiable source code and many parametersscalable accurate gradients for implemented codedepends on AD-compatible operationsoptimization and neural-network training
A derivative-method comparison first checks noise and smoothness, then pairs analytical formulas, smooth black boxes, differentiable source code, and costly evaluations with candidate methods and verification checks.

Figure 3:Assess noise and smoothness before selecting a derivative method, including when the function is a black box. The table pairs available information with candidate approaches and checks; these are conditional choices, not guarantees. Smoothing noisy data changes the estimated signal, so test sensitivity to the smoothing or model choice as well as to the derivative calculation.

Open full-size figure

Verification Strategy

Why this matters: scientific verification is stronger than “two numbers seem close.”

If you know a true derivative, compare against it. If you do not know a true derivative, compare multiple step sizes and multiple stencils. Agreement between two wrong methods is still possible, so method comparison must be tied to convergence expectations, not just raw closeness.

This section separates three different checks that students often blur together:

For the mixed test function

f(x)=sin⁡x e−x2+x3,f(x)=\sin x\,e^{-x^2}+x^3,

we can still differentiate analytically and use that exact derivative as a benchmark.

The analytical derivative is

f′(x)=e−x2(cos⁡x−2xsin⁡x)+3x2.f'(x)=e^{-x^2}\left(\cos x - 2x \sin x\right) + 3x^2.

This equation gives us a trustworthy target for checking several numerical stencils at once.

This cell reuses the shared helper functions defined earlier.

What students should compare in the output: how the different stencils rank at the same xx, how the error changes with hh, and whether the better-looking result is also the one supported by convergence expectations.

Verification at x = 0.7
------------------------------------------------------------------------
method              h         approx      abs error
forward       1.0e-02     1.39857624      1.254e-02
forward       1.0e-04     1.38615574      1.239e-04
forward       1.0e-06     1.38603309      1.239e-06
central       1.0e-02     1.38618793      1.561e-04
central       1.0e-04     1.38603186      1.561e-08
central       1.0e-06     1.38603185      2.247e-11
central4      1.0e-02     1.38603187      1.867e-08
central4      1.0e-04     1.38603185      2.924e-13
central4      1.0e-06     1.38603185      2.247e-11

This comparison teaches a practical lesson: reliable verification uses both exact-reference testing and cross-method comparison, but it becomes compelling only when convergence-order testing tells the same story.

Use this verification checklist when validating a derivative computation:

If convergence fails, the cause may be a bug, the wrong asymptotic regime, round-off domination, or loss of smoothness.

Agreement between methods is encouraging, but not by itself proof of correctness.

From Taylor expansions to quadrature panels

Taylor-series reasoning does not disappear after finite differences. It explains the order claims for the quadrature rules.

On one left-rectangle panel of width hh, expand a smooth integrand about the left endpoint:

f(xi+s)=f(xi)+f′(xi)s+O(s2),0≤s≤h.f(x_i+s)=f(x_i)+f'(x_i)s+O(s^2), \qquad 0\leq s\leq h.

Integrating the expansion gives

∫xixi+hf(x) dx=hf(xi)+h22f′(xi)+O(h3).\int_{x_i}^{x_i+h} f(x)\,dx =h f(x_i)+\frac{h^2}{2}f'(x_i)+O(h^3).

The omitted area on one panel is therefore O(h2)O(h^2). A fixed interval contains about (b−a)/h(b-a)/h panels, so the composite left-rectangle error is O(h)O(h), not O(h2)O(h^2). This local-to-global count is the source of the first order you will measure in a convergence study.

For the trapezoid rule, symmetric endpoint samples cancel the leading odd Taylor term and give global order 2. Simpson’s symmetric two-panel weights cancel further terms and give global order 4 when the required derivatives are smooth. These are claims about a refinement regime; test them before the floating-point floor and away from a discontinuity or branch point.

Bridge to later numerical methods

The same habits you built here will reappear when you solve

f(x)=0,f(x)=0,

because root-finding methods depend on local approximations and convergence behavior.

The same logic will reappear when you approximate

∫f(x) dx,\int f(x)\,dx,

because quadrature rules are also built by matching and canceling Taylor terms.

The same reasoning returns again for differential equations such as

dydt=f(t,y),\frac{dy}{dt}=f(t,y),

because ODE solvers are designed around local truncation error, stability, and the repeated accumulation of floating-point effects.

Block 2 uses the quadrature case first. Block 3 then introduces root finding, whose bracketing and initial-guess contracts are different from integration. Block 4 introduces time stepping, where local error is accumulated through a trajectory and stability adds a further constraint. The throughline is the same: Taylor-series reasoning tells us what the method is trying to approximate, and numerical verification tells us whether the implementation behaves that way.

The takeaway to carry forward is that every new method still demands both approximation logic and verification evidence.

Final Checklist

Before you leave Module 1, make sure you can:

Next: numerical integration. Root finding follows in a later reading.