Author-reviewedEvidence: highv1.0.0

Trapezoidal Rule

The trapezoidal rule approximates a definite integral by replacing a curve with straight-line segments and summing the resulting trapezoid areas.

Status
Published, version 1.0.0
Last reviewed
22 Sep 2026, by Dr Darrin Baines
Report a problem
Tell us if something is wrong or out of date

Concept Architecture

What the trapezoidal rule does

It is simple, transparent and especially useful when a function is available only at discrete time points. This page explains the single-interval and composite formulas, approximation error, irregular grids and applications to survival, costs and QALYs in health-economic models.

The method approximates the area implied by linear interpolation between observations. It does not recover unobserved curvature or correct biased, missing or poorly timed measurements.

One interval is approximated by one trapezoid

For a function (f(x)) observed at endpoints (a) and (b), the integral is:

I=∫abf(x) dxI=\int_a^b f(x)\,dx

The trapezoidal approximation is:

T=b−a2[f(a)+f(b)]T = \frac{b-a}{2} \left[f(a)+f(b)\right]

This is the interval width multiplied by the average of the two endpoint heights. Geometrically, it is the area under the straight line connecting ((a,f(a))) and ((b,f(b))).

The composite rule adds adjacent trapezoids

For an equally spaced grid (a=x_0<x_1<\cdots<x_n=b) with step size:

h=b−anh=\frac{b-a}{n}

the composite trapezoidal rule is:

Tn=h[12f(x0)+∑i=1n−1f(xi)+12f(xn)]T_n =h\left[ \frac{1}{2}f(x_0) +\sum_{i=1}^{n-1}f(x_i) +\frac{1}{2}f(x_n) \right]

Interior points receive full weight because each belongs to two neighbouring trapezoids. The two outer endpoints receive half weight because each belongs to only one.

Unequal intervals require their actual widths

Health data are often observed at irregular times. In that case, a single common step size must not be assumed. The composite approximation is:

T=∑i=0n−1xi+1−xi2[f(xi)+f(xi+1)]T = \sum_{i=0}^{n-1} \frac{x_{i+1}-x_i}{2} \left[f(x_i)+f(x_{i+1})\right]

Each interval contributes its own width multiplied by its average endpoint height. The observations must be sorted by the integration variable, and duplicated or reversed times must be resolved before calculation.

A worked example integrates a curved function

Consider:

I=∫01x2 dxI=\int_0^1 x^2\,dx

The exact integral is:

I=x33∣01=13≈0.333333I=\left.\frac{x^3}{3}\right|_0^1=\frac{1}{3}\approx0.333333

Use four equal subintervals, so (h=0.25). The function values are:

(x_i)(f(x_i)=x_i^2)
0.000.0000
0.250.0625
0.500.2500
0.750.5625
1.001.0000

The composite approximation is:

T4=0.25[12(0)+0.0625+0.25+0.5625+12(1)]=0.34375T_4 =0.25\left[ \frac{1}{2}(0) +0.0625+0.25+0.5625 +\frac{1}{2}(1) \right] =0.34375

The signed approximation error is:

T4−I=0.34375−0.333333…=0.0104167T_4-I =0.34375-0.333333\ldots =0.0104167

Because (x^2) is convex, the secant lines lie above the curve and the trapezoidal rule overestimates the integral.

Curvature determines the direction and size of error

For one interval and a function with a continuous second derivative, there is some (\xi\in(a,b)) such that:

∫abf(x) dx−T=−(b−a)312f′′(ξ)\int_a^b f(x)\,dx-T =- \frac{(b-a)^3}{12}f''(\xi)

For the composite rule on (n) equal intervals, there is some (\xi\in(a,b)) such that:

∫abf(x) dx−Tn=−(b−a)12h2f′′(ξ)\int_a^b f(x)\,dx-T_n =- \frac{(b-a)}{12}h^2 f''(\xi)

When (f''(x)>0), the function is convex and (T_n) tends to exceed the true integral. When (f''(x)<0), the function is concave and (T_n) tends to fall below it. A linear function has zero second derivative and is integrated exactly.

Error falls quadratically as the grid is refined

For a sufficiently smooth function on a uniform grid, the global discretisation error is of order (h^2):

I−Tn=O(h2)I-T_n=O(h^2)

Halving (h) therefore reduces the leading error by approximately a factor of four once the asymptotic regime applies. This convergence rate concerns numerical integration error, not sampling uncertainty or measurement error in the function values.

If (|f''(x)|\le M) throughout ([a,b]), an absolute error bound is:

∣I−Tn∣≤(b−a)12h2M|I-T_n| \le \frac{(b-a)}{12}h^2M

The bound may be conservative, and it cannot be evaluated without defensible information about curvature.

Richardson extrapolation estimates and reduces leading error

If (T_h) is the trapezoidal result with spacing (h) and (T_{h/2}) uses half that spacing, their leading errors differ by a factor of approximately four. An estimate of the finer-grid error is:

I−Th/2≈Th/2−Th3I-T_{h/2} \approx \frac{T_{h/2}-T_h}{3}

Combining the two results gives the Richardson-extrapolated estimate:

R=Th/2+Th/2−Th3R =T_{h/2} +\frac{T_{h/2}-T_h}{3}

For a smooth function, this combination is the basis of Simpson-type improvement and cancels the leading (h^2) error term. The estimate is unreliable when the grids are not nested, the function is not sufficiently smooth or other errors dominate.

Simpson's rule and adaptive methods can improve accuracy

Simpson's rule replaces pairs of straight-line segments with a quadratic interpolant and can be much more accurate for smooth functions. Gaussian quadrature selects nodes and weights to integrate polynomial structure efficiently. Adaptive quadrature subdivides regions where an error estimate indicates greater difficulty.

MethodStrengthImportant requirement
Trapezoidal ruleSimple and works directly with tabulated valuesLinear interpolation between points is acceptable
Simpson's ruleHigher order for smooth functionsStandard composite form needs an even number of equal subintervals
Gaussian quadratureHigh accuracy with few function evaluationsFunction can be evaluated at chosen nodes
Adaptive quadratureConcentrates effort where curvature is greatestReliable local error estimation and function access

More sophisticated integration does not improve accuracy when the limiting problem is sparse or biased observed data rather than numerical evaluation.

Area under a survival curve gives restricted mean survival

For a survival function (S(t)), restricted mean survival time through horizon (\tau) is:

RMST⁡(τ)=∫0τS(t) dt\operatorname{RMST}(\tau) =\int_0^{\tau}S(t)\,dt

If survival probabilities are available at times (t_0,\ldots,t_n), a trapezoidal approximation is:

RMST⁡^(τ)≈∑i=0n−1ti+1−ti2[S^(ti)+S^(ti+1)]\widehat{\operatorname{RMST}}(\tau) \approx \sum_{i=0}^{n-1} \frac{t_{i+1}-t_i}{2} \left[\widehat{S}(t_i)+\widehat{S}(t_{i+1})\right]

Applying linear interpolation to a Kaplan–Meier step function is not identical to integrating the step function exactly. If the event-time steps are available, direct step-function integration preserves the estimator's form. Trapezoidal integration may instead be appropriate for a smooth fitted survival curve or for regularly reported survival values when linear interpolation is the intended approximation.

A survival example shows the time units

Suppose estimated survival is 1.00 at month 0, 0.90 at month 6 and 0.75 at month 12. The trapezoidal area through 12 months is:

RMST⁡^(12)≈62(1.00+0.90)+62(0.90+0.75)\widehat{\operatorname{RMST}}(12) \approx \frac{6}{2}(1.00+0.90) +\frac{6}{2}(0.90+0.75) =5.70+4.95=10.65 months=5.70+4.95=10.65\text{ months}

The output has units of time because a dimensionless survival probability is integrated over months. It should be divided by 12 if the downstream model requires years and the conversion convention is one year per 12 months.

QALYs can be approximated from utility over time

Quality-adjusted life-years are the integral of health-related utility over time. When utility (u(t)) is observed at discrete times in years, the trapezoidal estimate is:

QALY⁡^=∑i=0n−1ti+1−ti2[u(ti)+u(ti+1)]\widehat{\operatorname{QALY}} = \sum_{i=0}^{n-1} \frac{t_{i+1}-t_i}{2} \left[u(t_i)+u(t_{i+1})\right]

This is often called area under the curve. The interpretation assumes linear utility change between observations. If health changes abruptly at a known event, a step or event-based model may better represent the trajectory.

Discounting also changes the integrand. With continuous discount rate (r), discounted QALYs are:

QALY⁡disc=∫0Tu(t)e−rt dt\operatorname{QALY}_{\text{disc}} = \int_0^T u(t)e^{-rt}\,dt

The trapezoidal rule should be applied to the discounted function values (u(t_i)e^{-rt_i}), or to another discretisation derived consistently from the chosen discount convention.

A QALY example requires consistent time units

Suppose utility is 0.80 at baseline, 0.70 at six months and 0.60 at twelve months. Converting time to years gives intervals of 0.5 years. The estimated QALYs during the year are:

QALY⁡^=0.52(0.80+0.70)+0.52(0.70+0.60)\widehat{\operatorname{QALY}} = \frac{0.5}{2}(0.80+0.70) + \frac{0.5}{2}(0.70+0.60) =0.375+0.325=0.700 QALYs=0.375+0.325=0.700\text{ QALYs}

Using widths of six without converting months to years would produce quality-adjusted life-months rather than QALYs. Unit labelling is part of the calculation, not a cosmetic reporting step.

The trapezoidal rule is related to cycle correction but not identical

In a cohort state-transition model, rewards calculated only at cycle boundaries can misrepresent events occurring within cycles. The trapezoidal approximation averages occupancy or reward at the beginning and end of each cycle, which is closely related to a half-cycle correction under certain assumptions. The concepts should not be treated as universally interchangeable.

A trapezoidal state-reward approximation over cycle length (\Delta t) is:

R≈∑i=0n−1Δt2[r(ti)+r(ti+1)]R \approx \sum_{i=0}^{n-1} \frac{\Delta t}{2} \left[r(t_i)+r(t_{i+1})\right]

Its adequacy depends on how transitions and rewards occur within the cycle. More precise within-cycle correction may be needed when hazards change rapidly, events cluster near boundaries or rewards accrue discontinuously.

Missing observations are not solved by numerical integration

The trapezoidal rule requires values at the endpoints of every included interval. If an outcome is missing, silently joining the nearest available observations asserts a long linear trajectory across the gap. That is an imputation assumption, not merely an integration step.

Analysts should distinguish:

  • Interpolation between observed points within a supported interval.
  • Imputation of an unobserved measurement.
  • Extrapolation beyond the last observation.
  • Censoring caused by dropout or death.
  • Structural rules, such as assigning utility after death.

Missing-data methods and sensitivity analyses should address why observations are absent and how that absence relates to outcomes.

Uncertainty in input values should be propagated

The trapezoidal rule itself returns a deterministic weighted sum for fixed inputs. When function values are estimated, the integrated area is also uncertain. Correlation among repeated measurements or adjacent survival estimates means that treating every point as independent can misstate variance.

For weights (w) and estimated values (y), a trapezoidal area can be written as:

T=wTyT=w^{\mathsf T}y

If (\operatorname{Cov}(y)=\Sigma), then:

Var⁡(T)=wTΣw\operatorname{Var}(T) =w^{\mathsf T}\Sigma w

Bootstrap, multiple-imputation or model-based simulation can propagate uncertainty when the covariance is complex or the area is part of a larger analysis. Numerical integration error and statistical sampling uncertainty should be reported separately where both matter.

Spreadsheet implementation is transparent and auditable

A spreadsheet can calculate one row per interval with columns for left time, right time, width, left value, right value and trapezoid area. The interval formula is:

=(RightTime-LeftTime)*(LeftValue+RightValue)/2

The total integral is the sum of interval areas. A robust sheet should flag unsorted time points, duplicate times, missing endpoints, negative interval widths and inconsistent units. The first and last integration limits should be displayed explicitly rather than inferred from hidden rows.

Common errors change the area materially

The simplicity of the formula can hide assumptions about ordering, interpolation, units and endpoints. These assumptions should be visible whenever the result affects a health-economic decision.

  • Applying the equal-spacing formula to irregular observations assigns the wrong interval weights.
  • Sorting function values without sorting their corresponding times pairs the wrong points.
  • Omitting or double-counting an endpoint changes the integral.
  • Using months as if they were years changes QALYs or annual costs by a factor of 12.
  • Integrating percentages as whole numbers rather than proportions changes results by a factor of 100.
  • Extending the last observed value beyond follow-up is extrapolation, not trapezoidal integration.
  • Integrating a Kaplan–Meier curve by straight lines differs from exact step-function integration.
  • Rounding each interval before summation can accumulate avoidable error.
  • Treating denser sampling as proof of unbiased measurement confuses discretisation with data quality.
  • Reporting an area without its limits and units makes the result uninterpretable.

A defensible trapezoidal-rule workflow

A reliable calculation makes the integration target, grid, units and interpolation assumption explicit. Validation should compare the result with known functions or finer grids before the method is relied upon in a model.

  1. Define the integral: State the function, lower and upper limits, and required output units.
  2. Inspect the grid: Sort paired observations, check duplicates, confirm spacing and identify missing intervals.
  3. Choose the interpolation: Confirm that straight-line change between points is scientifically reasonable.
  4. Calculate interval areas: Use the actual width and average endpoint value for every interval.
  5. Verify endpoints: Confirm that the first and last observations match the intended integration limits.
  6. Check units: Convert time, percentages, currencies and outcome scales before summation.
  7. Assess numerical error: Compare with a finer grid, exact benchmark, Richardson estimate or alternative quadrature where possible.
  8. Address data uncertainty: Propagate sampling, censoring and missing-data uncertainty separately from discretisation error.
  9. Test decision impact: Examine whether plausible interpolation or extrapolation alternatives change the economic conclusion.
  10. Document assumptions: Record the data source, grid, method, horizon, discounting, missing-data handling and precision retained.

The trapezoidal rule is most defensible when the observed points are sufficiently dense for linear interpolation and the integration horizon is supported by the data. Its transparency is a strength only when the assumptions between those points are equally transparent.

Library

Publications

1
  • Journal article

    Modeling Good Research Practices — Overview: A Report of the ISPOR-SMDM Modeling Good Research Practices Task Force-1 — Caro, Briggs, Siebert & Kuntz, Task Force Report 1 ed., 2012 (Value in Health / Medical Decision Making)

    The overview paper of the seven-part ISPOR-SMDM modelling good-practice series, setting out best-practice recommendations across model design, technique selection, implementation, validation, parameterisation, uncertainty and use in decision making.

Frequently Asked Questions (6)

  • What is the trapezoidal rule?

    A numerical integration technique approximating a definite integral by dividing the area under a curve into trapezoids and summing their areas.

    Source: Press et al. 2007

  • When is the trapezoidal rule adequate despite its simplicity?

    The trapezoidal rule joins successive data points with straight lines and sums the areas of the trapezoids beneath them, which is simpler than fitting curves but less exact for a bending function. It is adequate where the function is nearly straight between points, or where the points are close enough together that little curvature is missed in each step. For smooth data sampled finely, its error becomes small and its simplicity is an advantage. Where accuracy matters more, a curve-fitting method is preferred. Press and colleagues (2007) describe it.

    Source: Press et al. 2007

  • How does the trapezoidal rule work?

    The trapezoidal rule works by dividing the integration interval into subintervals, evaluating the function at the endpoints of each, and approximating the area over each subinterval as a trapezoid with those endpoint values as its parallel sides. The areas of the trapezoids are summed to estimate the integral. Because it connects adjacent points with straight lines, the rule is straightforward to apply, needing only the function values at the chosen points, and its accuracy improves as more subintervals are used.

    Source: Press et al. 2007

  • How does the trapezoidal rule compare with Simpson's rule?

    The trapezoidal rule and Simpson's rule are both numerical integration methods but differ in how they approximate the function: the trapezoidal rule uses straight-line segments, forming trapezoids, while Simpson's rule uses parabolas over pairs of intervals. Because parabolas capture curvature that straight lines miss, Simpson's rule is generally more accurate for smooth functions with the same number of points. The trapezoidal rule is simpler but less accurate, so it suits situations where its simplicity suffices or the function is not smooth.

    Source: Press et al. 2007

  • Where is the trapezoidal rule used?

    The trapezoidal rule is used to approximate integrals in statistics and modelling where an analytical solution is unavailable, such as computing the area under a curve, which arises in estimating mean survival from a survival curve, calculating quality-adjusted life years, or integrating over a distribution. Its simplicity makes it convenient, and it is often applied to data given at discrete points. For smooth functions where greater accuracy is wanted, methods such as Simpson's rule may be preferred, but the trapezoidal rule remains widely used.

    Source: Press et al. 2007

  • What are the limitations of the trapezoidal rule?

    The trapezoidal rule's main limitation is that its straight-line approximation between points introduces error where the function curves, so it is less accurate than methods using curved segments, and it can systematically over- or underestimate for convex or concave functions unless many subintervals are used. Its accuracy improves with more points but at greater computation. For smooth functions, more accurate methods exist, so the trapezoidal rule is chosen where its simplicity is adequate or the data suit a linear approximation between points.

    Source: Press et al. 2007

Trust Record

Verified by Dr Darrin Baines

British health economist

Professional identity: darrinbaines.org

Verification date: 22 Sep 2026

Content version: 1.0.0

Canonical Identity

Term code
HE-EM-MV-085

Stable URI · Machine-readable · Resolvable · CC BY 4.0