Numerical integration estimates a definite integral from a finite set of function values. It turns a continuous accumulation problem into a weighted sum: evaluate the quantity at selected locations, multiply by appropriate weights, and add. Its gold standard is a result whose meaning, units, approximation error and dependence on the available information can all be explained.
A reliable calculation begins before choosing a formula. Integrating a smooth function that can be evaluated anywhere is different from integrating a handful of noisy measurements. A small numerical error estimate does not establish that an instrument baseline is correct, that an important peak was sampled, or that the mathematical model represents the intended quantity. This guide shows how to distinguish those questions and choose useful checks.
The worked cases develop trapezoidal, midpoint, Simpson and Gaussian quadrature, then examine refinement, adaptive sampling, irregular observations, singular endpoints, oscillation and cancellation. All numerical examples are original teaching cases with stated assumptions. You can reproduce their arithmetic with a spreadsheet or a short program.
Use the Gold Standard master to explore the collection, the Education parent to connect understanding with transfer, and the How X Works hub for related mechanisms. Numerical Analysis supplies the broader account of conditioning, approximation and computation. Here the focus is specifically the accumulation represented by an integral and the evidence behind its numerical value.
Choose your numerical integration route
Chapters 1–3: Define the target and basic rules
Chapters 4–6: Improve and check approximations
Chapters 7–9: Choose nodes and work with data
Chapters 10–12: Transform and diagnose difficult integrals
Chapter index
Define the target and basic rules · Chapters 1–3
1. Specify the accumulation before calculating it
Improve and check approximations · Chapters 4–6
4. Combine information with Simpson’s rule
Choose nodes and work with data · Chapters 7–9
7. Choose Gaussian nodes by matching moments
8. Let adaptation find difficulty without trusting it blindly
9. Integrate measured data with their timestamps and baseline
Transform and diagnose difficult integrals · Chapters 10–12
10. Transform singular endpoints and account for tails
Transfer and continue learning · Chapters 13–14
CHAPTER 1 OF 14 · Define the target and basic rules
1. Specify the accumulation before calculating it
Write the target as I = ∫ from a to b of f(x) dx. The interval states where accumulation begins and ends. The function states what accumulates per unit of the horizontal variable. If f is a flow rate in litres per second and x is time in seconds, I is a volume in litres. The units are a quick way to expose a calculation that has averaged readings but forgotten duration.
Suppose a constant flow of 3 litres per second lasts 8 seconds. The integral is 24 litres. Every proposed quadrature rule for this interval should reproduce that answer from constant data. This elementary test checks the total weight: the weights must sum to 8 seconds. If they sum to 1, the calculation may be an average rather than a total.
Signed accumulation and geometric area
An integral retains signs. A velocity of 2 metres per second for one second followed by −2 metres per second for one second produces zero displacement. The distance travelled is 4 metres, obtained by integrating speed, the absolute value of velocity. Changing the integrand changes the question; choosing a more sophisticated integration formula does not resolve that distinction.
Bounds can also encode a substantive decision. A spectral peak integrated over a narrow window omits part of its tails. A force trace integrated after contact has ended includes a different physical interval. Before calculating, explain why the selected boundaries belong to the intended event, rather than merely to the visible part of a graph.
Separate three objects in your notes: the physical quantity you want, the mathematical function used to represent it, and the values supplied to the algorithm. They need not be identical. Measurements may include an offset; a fitted function may smooth away a short event; a simulator may use its own approximate solver. Quadrature controls only one part of this chain. Naming the other parts prevents a highly precise sum from being mistaken for a highly accurate observation.
CHAPTER 2 OF 14 · Define the target and basic rules
2. Build the trapezoidal rule from straight segments
Take sample positions x₀, x₁, …, xₙ in increasing order and corresponding values f₀, f₁, …, fₙ. Replace the curve between adjacent positions by a straight line. The integral of that line is the interval width multiplied by the average of its endpoint heights. Adding these pieces gives T = Σ (xᵢ₊₁ − xᵢ)(fᵢ + fᵢ₊₁)/2.
This construction explains the rule without requiring equal spacing. On a uniform grid with width h = (b − a)/n, shared interior endpoints appear in two neighbouring trapezoids. Their combined weight is h, while the two outer endpoints have weight h/2. Thus Tₙ = h[f₀/2 + f₁ + … + fₙ₋₁ + fₙ/2]. There are n intervals and n + 1 sampled endpoints.
A complete quadratic calculation
For f(x) = x² on [0,1], use n = 2 and h = 1/2. The values are 0, 1/4 and 1. The estimate is T₂ = (1/2)[0/2 + 1/4 + 1/2] = 3/8 = 0.375. Direct integration gives I = 1/3, so the signed error T₂ − I is 1/24, approximately 0.041667.
With n = 4, the values at 0, 1/4, 1/2, 3/4 and 1 are 0, 1/16, 1/4, 9/16 and 1. Now T₄ = (1/4)[1/16 + 1/4 + 9/16 + 1/2] = 11/32 = 0.34375. Its error is 1/96. Halving the spacing divided the error by four in this example.
The overestimate has a geometric explanation: each chord lies above this convex curve. Straight-line interpolation integrates linear functions exactly, but it does not preserve the area under every curved function. That limitation is useful information. It tells us what the algorithm assumed between observations, and why adding information about curvature can improve the estimate.
CHAPTER 3 OF 14 · Define the target and basic rules
3. Use midpoint sampling to see a different error
The midpoint rule replaces each interval by a rectangle whose height is evaluated at the interval centre. For equal spacing, Mₙ = h Σ f(a + (i + 1/2)h), with i running from 0 to n − 1. Unlike the trapezoidal rule, it does not require endpoint values. It does require access to midpoint values, which may be unavailable in a fixed measurement record.
Apply it to the same quadratic on [0,1]. With two intervals, evaluate at 1/4 and 3/4. M₂ = (1/2)[1/16 + 9/16] = 5/16 = 0.3125. The error M₂ − 1/3 is −1/48. With four intervals the estimate is 21/64 = 0.328125, with error −1/192. Once again halving the width divides the error by four, but the error now has the opposite sign.
Derive the curvature effect locally
For a quadratic, write x = m + u within an interval of width h centred at m. Then x² = m² + 2mu + u². The odd term integrates to zero over symmetric limits. The exact local integral is h m² + h³/12. The midpoint rectangle contains only h m², so it misses h³/12 on each interval. Summing n equal intervals over [0,1] gives the exact error −1/(12n²).
This derivation is stronger than simply noticing a pattern in decimals. It identifies the omitted term and the conditions under which the pattern follows. A locally linear function has no quadratic term, which explains midpoint exactness for linear functions as well.
Comparing midpoint and trapezoidal estimates can reveal useful disagreement, but agreement alone proves little about an arbitrary unknown curve. Both could miss the same narrow feature. Also compare their information costs fairly: midpoint values and endpoint values are different evaluations. If a simulator is expensive, retaining values and planning which additional locations to sample can matter more than the arithmetic needed to add them.
CHAPTER 4 OF 14 · Improve and check approximations
4. Combine information with Simpson’s rule
On two equal intervals of width h, Simpson’s rule uses the left endpoint, shared midpoint and right endpoint with weights h/3, 4h/3 and h/3. On [0,1] this is S₂ = [f(0) + 4f(1/2) + f(1)]/6. The weights arise by integrating the quadratic interpolating those three values.
For x², S₂ = [0 + 4(1/4) + 1]/6 = 1/3. The answer is exact. It is also exact for x³: [0 + 4(1/8) + 1]/6 = 1/4. Symmetry cancels the additional cubic contribution that a purely quadratic-interpolation explanation might lead a beginner to overlook.
Exact for some functions, approximate for others
Try x⁴. S₂ = [0 + 4(1/16) + 1]/6 = 5/24, approximately 0.208333. The exact integral is 1/5, leaving an error of 1/120. With four equal intervals, the composite rule gives S₄ = 77/384, approximately 0.200520833. Its error is 1/1920, sixteen times smaller.
For the familiar composite formula, n is even and the interior weights alternate 4 and 2: Sₙ = (h/3)[f₀ + 4f₁ + 2f₂ + … + 4fₙ₋₁ + fₙ]. Adjacent pairs of intervals share endpoints. Count intervals before assigning weights; confusing n points with n intervals can quietly change the whole calculation.
Do not apply this equal-spacing weight pattern to irregular timestamps. A formula that handles unequal spacing is a different construction with different properties. The official SciPy Simpson documentation distinguishes polynomial exactness for equally and unequally spaced samples.
Higher polynomial exactness is valuable when the function has the required regularity and the samples resolve its features. It is not a ranking that makes Simpson’s rule automatically preferable for every dataset. Measurement noise, isolated discontinuities and unavailable midpoint observations all change the decision. The useful question is whether the rule’s local approximation matches the information you actually possess.
CHAPTER 5 OF 14 · Improve and check approximations
5. Separate error bounds from observed differences
An error bound is a mathematical statement under specified assumptions. An error estimate is evidence obtained by a procedure, often by comparing calculations. These are related but distinct. A difference of 0.0001 between two approximations does not, by itself, establish that either lies within 0.0001 of the exact integral.
For a function with a continuous second derivative on [a,b], a standard composite trapezoidal bound is |Tₙ − I| ≤ (b − a)h²K₂/12, where K₂ bounds |f″(x)| throughout the interval. The corresponding midpoint bound has denominator 24. For composite Simpson’s rule, with even n and a continuous fourth derivative, |Sₙ − I| ≤ (b − a)h⁴K₄/180. The derivative bounds and smoothness conditions are essential parts of these statements. NIST’s quadrature reference supplies the standard quadrature formulas and error framework.
Plan a resolution from a defensible bound
For x² on [0,1], K₂ = 2. The trapezoidal bound is 1/(6n²), which is also the exact error here. To make it at most 0.001, require n² ≥ 1/0.006, so n must be at least 13. Twelve intervals give error about 0.0011574; thirteen give about 0.0009862. Rounding the interval count downward would fail the stated requirement.
In a real application, finding a reliable derivative bound may be harder than computing the sum. A derivative estimated from a coarse plot can miss the very curvature that matters. If the required bound is unknown, report that limitation rather than presenting an empirical refinement check as a theorem.
Maintain separate allowances for discretization, imperfect function evaluation, measurement uncertainty and truncation of the domain. If conservative absolute bounds apply to each component, their sum gives a conservative overall bound. If some components are statistical uncertainties, combining them requires their dependence structure. A numerical tolerance should therefore be chosen in relation to the whole task, not copied blindly from a software default.
CHAPTER 6 OF 14 · Improve and check approximations
6. Refine the grid and test the error model
Suppose a quadrature result has the form Q(h) = I + c hᵖ plus smaller terms, with the same leading coefficient c as the spacing changes. Halving h gives Q(h/2) ≈ I + c hᵖ/2ᵖ. Subtracting the two expressions allows the leading error term to be estimated and cancelled.
The resulting extrapolation is R = [2ᵖQ(h/2) − Q(h)]/(2ᵖ − 1). The estimated error magnitude of the finer result is |Q(h/2) − Q(h)|/(2ᵖ − 1). These formulas follow from the assumed expansion; they are not valid merely because two numbers are available.
Recover the quadratic integral
For the trapezoidal quadratic example, p = 2. Using T₂ = 3/8 and T₄ = 11/32 gives R = [4(11/32) − 3/8]/3 = 1/3. The fine-grid error estimate is |11/32 − 3/8|/3 = 1/96, exactly matching the known error. Here the simple expansion contains the complete error, which is why cancellation is exact.
For a smooth problem with leading fourth-order Simpson error, the corresponding divisor is 15. In the x⁴ example, |S₄ − S₂|/15 = 1/1920. Again the exact answer lets us test the procedure rather than merely trust its output.
Use a third resolution to check the proposed order. If successive changes shrink by approximately four for a second-order method, the observations support that regime. If they fluctuate, stall or change sign unpredictably, investigate unresolved structure, a nonsmooth function, rounding or inconsistent evaluations. A constant sequence can mean exactness, but it can also mean every grid missed the same event.
When implementing refinement, reuse old evaluations where grids are nested. For trapezoidal integration, halving the grid requires only the new midpoint values. Keep the function, bounds, units and stopping criteria unchanged during the comparison. Otherwise a difference between runs mixes several effects and no longer tests the discretization model you intended to examine.
CHAPTER 7 OF 14 · Choose nodes and work with data
7. Choose Gaussian nodes by matching moments
Uniform spacing is convenient, but it is not compulsory when you can evaluate a function wherever you choose. Gaussian quadrature chooses nodes and weights to integrate a large family of polynomials exactly. A small two-node example reveals the mechanism directly.
On [−1,1], propose symmetric nodes −c and c with equal weight w. Matching the integral of the constant function gives 2w = 2, so w = 1. Matching x² gives 2c² = 2/3, so c = 1/√3. Odd powers x and x³ integrate to zero and also cancel between the two symmetric nodes. Therefore f(−1/√3) + f(1/√3) integrates every cubic polynomial exactly.
Test the boundary of exactness
For x⁴, the rule gives 2/9, while the exact integral over [−1,1] is 2/5. The rule’s success for cubics does not imply exactness for quartics. Polynomial exactness states precisely which functions are reproduced, not an unconditional error guarantee for all other functions.
To integrate over [a,b], transform x = (a + b)/2 + (b − a)t/2. The transformed integral includes the factor (b − a)/2. On [0,1], the two nodes are (1 − 1/√3)/2 and (1 + 1/√3)/2, each with weight 1/2. Omitting this scale factor would double the result on this interval.
For x² on [0,1], the nodes sum to 1 and their product is 1/6. Their squared values sum to 1 − 2/6 = 2/3. Multiplying by the common weight 1/2 returns 1/3. This provides a compact independent check of both the transformed nodes and the weights.
The official fixed-order Gaussian quadrature documentation describes a callable-function implementation. Such a method cannot simply relocate existing laboratory observations. Interpolating data to Gaussian nodes introduces an additional model; it does not create new measurements. Distinguish freedom to choose evaluation locations from the desire to use a particular formula.
CHAPTER 8 OF 14 · Choose nodes and work with data
8. Let adaptation find difficulty without trusting it blindly
Adaptive integration spends more evaluations where local estimates indicate difficulty. One possible design compares a coarse estimate on an interval with estimates on its two halves, then subdivides intervals whose estimated errors are too large. Smooth, quiet regions can remain coarse while rapidly changing regions receive more attention.
The design still depends on what sampled values reveal. Consider a triangular bump supported only between x = 0.29 and x = 0.31, with height 100 at x = 0.30 and zero elsewhere on [0,1]. Its integral is half the base times the height: (1/2)(0.02)(100) = 1. Samples at 0, 0.25, 0.5, 0.75 and 1 all return zero.
Agreement can conceal a missing event
A coarse Simpson calculation and its first refinement both give zero for this bump. Their difference is also zero. Any stopping procedure based only on that comparison can accept an entirely wrong result. This is an information failure before it is an arithmetic failure: the sampled data do not distinguish the bump from the identically zero function.
Known feature locations should therefore influence the calculation. Split at meaningful boundaries, restrict the domain to a relevant window when justified, or deliberately sample a suspected narrow region. An exploratory plot helps only if its own sampling resolves the feature. A beautifully drawn curve from the same five zero values supplies no independent evidence.
The official SciPy quad documentation describes an estimated absolute error, optional breakpoints for local difficulties, and limitations for sharp features. Treat the returned error as an algorithmic estimate, read convergence messages, and retain diagnostic information when investigating a doubtful result.
A practical acceptance check combines several kinds of evidence: the function’s known structure, a refinement study, an alternative partition or transformation, and a tolerance appropriate to the use. Repeating the same sampling logic with more decimal places tests a different issue. It cannot recover a region that the algorithm never examined.
CHAPTER 9 OF 14 · Choose nodes and work with data
9. Integrate measured data with their timestamps and baseline
When observations are fixed, quadrature must work with the supplied locations. Suppose velocity readings are 0, 2 and 2 metres per second at times 0, 1 and 3 seconds. Piecewise-linear interpolation gives displacement (1)(0 + 2)/2 + (2)(2 + 2)/2 = 1 + 4 = 5 metres. The unequal interval widths are part of the calculation.
Taking the ordinary mean of the three velocities and multiplying by three seconds gives 4 metres instead. That procedure gives each observation equal influence despite unequal time coverage. It represents a different approximation. SciPy’s trapezoid documentation explains supplying sample positions explicitly; it also notes that supplied positions are processed in sequence rather than automatically sorted.
Understand what a baseline contributes
For this example the trapezoidal weights on the three readings are 0.5, 1.5 and 1 second. They sum to 3 seconds. A constant velocity offset of 0.1 metres per second therefore adds 0.3 metres to the displacement estimate. Finer numerical interpolation of the same offset measurements cannot remove that error.
If the three reading errors are independent, each with standard deviation σ = 0.2 metres per second, the weighted-sum variance is σ²(0.5² + 1.5² + 1²) = 0.14 square metres. Its standard deviation is approximately 0.374 metres. This is uncertainty from the stipulated random reading errors, not an estimate of interpolation bias. Correlated errors require covariance terms; a shared offset does not behave like independent noise that averages away.
The existing force-baseline and jump-height case follows this accumulation issue through impulse. The equal-area spectroscopy case distinguishes integrated response from peak height and examines baseline and window choices.
For a measurement report, retain the original timestamps, calibration information, integration interval and interpolation assumption. If a gap in recording is large enough to conceal an important event, label it as missing information. Filling it with a smooth line makes the computational object complete, but does not establish that the line describes what occurred.
CHAPTER 10 OF 14 · Transform and diagnose difficult integrals
10. Transform singular endpoints and account for tails
Some finite integrals have unbounded integrands. For example, ∫ from 0 to 1 of x⁻¹ᐟ² dx equals 2, although the function diverges at zero. Directly requesting its endpoint value in a trapezoidal formula fails. The integral’s existence and the validity of a particular sampling formula are separate questions.
Set x = t². Then dx = 2t dt, and for t > 0 the transformed integrand is (t²)⁻¹ᐟ²(2t) = 2. The transformed interval is [0,1], so the answer is immediately 2. At t = 0, use the limiting value 2 in an implementation. Evaluating the unsimplified product as an infinite value times zero can produce an undefined numerical result even though the transformed function has a removable endpoint issue.
Separate a finite approximation from an infinite domain
For ∫ from 0 to infinity of e⁻ˣ dx, truncating at L leaves a tail exactly equal to e⁻ᴸ. If the allowed tail error is 0.001, choosing L = ln(1000), approximately 6.907755, meets that allowance. The finite-interval quadrature error must still be budgeted separately. Giving both components an allowance of 0.001 permits a combined absolute bound of 0.002, not 0.001.
A slow-decaying tail changes the planning dramatically. For ∫ from 1 to infinity of x⁻² dx, the omitted tail beyond L is 1/L. Achieving the same 0.001 tail allowance requires L ≥ 1000. A window length that works well for an exponential is therefore not transferable without examining the decay.
Mappings can turn infinite domains into finite intervals, but may concentrate difficulty near an endpoint. Always transform the differential as well as the function, check the new bounds, and inspect endpoint behaviour. A change of coordinates is a mathematical reformulation with consequences for smoothness and sampling density. It should be verified on a case with a known answer before being trusted on an unfamiliar integral.
CHAPTER 11 OF 14 · Transform and diagnose difficult integrals
11. Diagnose oscillation, cancellation and dimensional cost
Sampling can systematically hide oscillation. Fix a positive integer m and consider f(x) = 1 − cos(2πmx) on [0,1]. At every grid point x = j/m, the value is zero. A trapezoidal calculation on those m intervals therefore returns zero, although the exact integral is 1. The cosine completes m full cycles, whose signed integral vanishes, leaving the constant contribution.
At the halfway points x = (j + 1/2)/m, however, the value is 2. Refining this particular grid to 2m intervals makes the trapezoidal result equal 1. That repair works because it reveals the hidden oscillation; it does not mean that doubling any grid always suffices. The frequency structure of the integrand should inform resolution or the choice of an oscillatory integration method.
A small signed result can be sensitive
For f(x) = x on [−1,1], positive and negative contributions cancel exactly. Relative error measured against the exact result is undefined because the denominator is zero. An absolute error tolerance is the meaningful starting point. Even for a small nonzero integral, reporting only a percentage can obscure whether the underlying contributions are individually much larger.
If numerical contributions of about one million and minus one million nearly cancel, small absolute errors in either can dominate their residual. Stable summation, symmetry-aware reformulation and higher arithmetic precision may help with rounding. None of those actions corrects a wrong baseline or missing physical term. Diagnose which quantity is uncertain before choosing the repair.
Dimension introduces a different difficulty. A tensor grid with 20 nodes per coordinate needs 400 evaluations in two dimensions, but 20⁸ = 25,600,000,000 in eight dimensions. This exact count explains why a successful one-dimensional recipe can become impractical after adding variables.
Structure can reduce that burden through separability, analytic integration of some variables or other problem-specific simplifications. For sampling-based alternatives, continue to Quasi-Monte Carlo Methods. That sibling root addresses deliberate coverage and randomized replication. Its error assessment should not be confused with the derivative-based deterministic quadrature bounds developed here.
CHAPTER 12 OF 14 · Transform and diagnose difficult integrals
12. Build a diagnostic workflow that identifies the repair
Begin with a written target: integrand, domain, units, desired quantity and acceptable absolute error. State whether you can request new function values or only possess recorded samples. This one distinction rules out several inappropriate methods before any computation begins.
Next perform elementary checks. A constant input should give constant times interval length. A linear input should be exact for the trapezoidal and midpoint rules. Reversing integration bounds should reverse the sign. Splitting a well-behaved integral at an interior point should agree, within the numerical allowance, with the unsplit calculation. These checks expose missing scale factors, endpoint weights and indexing mistakes.
Match symptoms to causes
If the answer changes by a large amount when the interval is split near a known peak, inspect sampling coverage. If equal-spacing and timestamp-aware calculations disagree, inspect interval widths. If refinement stabilizes while a baseline correction changes the result substantially, the dominant issue is likely outside the quadrature discretization. If values become erratic near a singular endpoint, inspect the formula and transformation rather than merely requesting more intervals.
If error decreases predictably and then stops, check floating-point summation and the accuracy of function evaluations. A quadrature rule cannot extract more reliable information than its evaluations contain. For a simulator with an internal stopping tolerance, rerun a few sampled values with stricter internal settings to see whether the integrand itself is stable enough for the requested outer tolerance.
Record function-evaluation count alongside accuracy. Two methods with the same interval count may use different numbers of evaluations and may reuse different amounts of previous work. A fair comparison concerns achieved accuracy for the actual cost, including any expensive preprocessing or simulator calls.
Finish with a reproducible statement: which rule or software routine was used, the bounds and units, resolution or tolerances, any transformation or breakpoint, the result, and the evidence supporting its precision. Distinguish exact arithmetic identities, proven bounds and empirical estimates in that statement. Retain convergence messages and explain unresolved limitations. This makes another reader able to repeat the calculation and understand which change would be needed if the conditions changed.
CHAPTER 13 OF 14 · Transfer and continue learning
13. Test transfer when the observations change
Consider a fictional flow experiment. Recorded times are 0, 1 and 3 seconds, and measured rates are 1, 3 and 3 litres per second. A calibration check establishes a constant additive offset of 0.2 litres per second in all three readings. Assume the true flow varies linearly between the corrected measurements. Find the delivered volume and explain which uncertainty remains if that linear assumption is unverified.
First integrate the uncorrected readings with their actual intervals: (1)(1 + 3)/2 + (2)(3 + 3)/2 = 2 + 6 = 8 litres. The offset contributes 0.2 × 3 = 0.6 litres. Subtracting it gives 7.4 litres. Equivalently, integrate corrected rates 0.8, 2.8 and 2.8 to obtain 1.8 + 5.6 = 7.4 litres.
Change the information, not just the numbers
Now suppose a later inspection suggests an additional triangular flow pulse centred at 2 seconds, entirely within the unobserved interval. Its duration is 0.2 seconds and its excess height above the assumed baseline is 4 litres per second. If this pulse really occurred, it would add (1/2)(0.2)(4) = 0.4 litres, making the total 7.8 litres.
The original three readings cannot determine whether that pulse occurred. Subdividing the straight line between those readings produces the same 7.4-litre interpolation integral; it does not discover the pulse. The appropriate next action is to obtain additional evidence about flow between observations or state the unresolved sampling limitation.
Finally assume each original rate measurement has independent random error with standard deviation 0.1 litres per second, and the offset correction is known exactly. Using weights 0.5, 1.5 and 1 gives volume standard deviation √[0.01(0.25 + 2.25 + 1)] = √0.035, approximately 0.187 litres. This uncertainty calculation does not include the possible pulse. If the offset correction is itself uncertain, its contribution must also be included with appropriate dependence assumptions.
The transfer test is whether you can explain all three answers without treating them as contradictory: 7.4 litres under a stated interpolation model, 7.8 litres under an added-pulse model, and 0.187 litres as a particular random-error standard deviation. They answer different questions about the same sparse record.
CHAPTER 14 OF 14 · Transfer and continue learning
14. Answer common questions and choose a learning route
Which integration rule should I learn first?
Start with the trapezoidal rule because its geometry, weights and treatment of irregular spacing are visible. Then compare midpoint sampling on a function you can evaluate anywhere. Simpson and Gaussian rules become easier to understand once you can explain what information each new set of weights preserves. Learn each method alongside an example where it fails.
Does a tiny reported error mean the answer is correct?
It means the routine has produced a small estimate under its computational model. That estimate can be useful, but it does not certify the physical model, measurement baseline or unobserved regions. Confirm that the result matches known structure and survives a meaningful independent check. A numerical success message is one piece of evidence.
Can I create more data by interpolating?
You can create more values of an interpolating function. That makes the chosen model easier to evaluate, but it does not add observations of the original process. Integrating a finely sampled interpolant can converge very accurately to the interpolant’s area while remaining uncertain about the area of the underlying process.
Why not always request the tightest possible tolerance?
A tighter tolerance may require more evaluations and can encounter rounding or function-evaluation limits. If the measurements carry substantially larger uncertainty, extra quadrature digits may have little practical value. Set a computational allowance small enough for the decision while identifying the other errors separately.
How should I practise and continue?
For a first exercise, reproduce x² and x⁴ using exact fractions, then repeat with decimal arithmetic. For a programming exercise, store coarse and refined estimates, evaluation counts and differences. Test the narrow bump and oscillatory examples deliberately, so that your checks are challenged rather than merely confirmed.
For a measurement exercise, integrate an irregularly sampled trace twice: once with an explicit baseline correction and once without. Explain the difference from the total weights. Use the linked biomechanics and spectroscopy cases to connect that arithmetic with a meaningful measured quantity, then return to the changed-context problem in the previous chapter.
The primary technical references are NIST DLMF §3.5 for quadrature theory and the official SciPy pages for trapezoid, Simpson integration, fixed Gaussian quadrature and adaptive quad for implementation behaviour. Consult the documentation corresponding to the software version you use. A useful final explanation identifies the accumulated quantity, reproduces the weights, and states what the available evidence can and cannot establish about the result.