Free lesson · Integral calculus
Numerical integration and a continuous cash-flow building block
Open interactive lessonPractice calculationsExplore labs
Start with the idea
- Many integrals do not have a convenient antiderivative.
- Numerical quadrature approximates the integrand on small intervals and adds the resulting areas.
- The step size controls one source of error, while inaccurate input data create another.
Symbols, units & horizon
- I: exact integral being approximated
- h=(b−a)/n: uniform interval width
- xᵢ=a+ih: sample locations
- n: number of intervals
- PV: present value in currency
- c: constant currency flow per year
- r: continuous discount rate per year
- T: horizon in years
- t: integration time
- At r=0: PV=cT by continuity
When and why to use this
Use a known exact integral to validate an integration routine, then examine step convergence on the target integrand. Separate mathematical approximation error from uncertainty in the inputs.
- The trapezoidal rule joins neighbouring samples with straight lines and integrates those lines.
- For a sufficiently smooth integrand its error decreases quadratically with uniform step size over a fixed interval.
- Halving the step is a useful convergence check, not a cure for discontinuities or biased data.
- As a separate application, a continuous currency flow c(t) discounted at a constant continuously compounded rate r has present value ∫ c(t)exp(−rt)dt.
- This is a model of continuous payments; a discrete coupon schedule should normally be summed at its actual payment dates.
Numerical integration and a continuous cash-flow building block
- One strip has trapezoidal area . Adding strips counts every interior sample twice and each endpoint once, giving the displayed weighted sum.
- For on with , use : . This approximates the exact integral ; it is not an identity for the curved integrand.
- For constant flow and , an antiderivative is . Subtract endpoints: .
- As , the ratio tends to , giving . With dollars/year, per year and years, dollars.
A continuous $100/year flow over 2 years at r=.05 has PV=100(1−exp(−.1))/.05≈$190.325. At zero discount rate it is $200.
An analogy to remember
Surveyors can approximate uneven terrain with many flat-sided strips. Finer strips help if the terrain is adequately sampled; they cannot reveal a feature absent from the data.
How this becomes a building block
Quadrature is a reusable numerical component for expectations, discounting and some option-pricing integrals. The continuous-flow formula is a complete valuation under stated assumptions and also a term in a broader valuation model.
For current applications and implementation limits, see the research checkpoint in Differential Equations.
Research sources, review dates and limitations
Extend the research question
Distinguish accumulated realized funding from extrapolating the most recent quoted rate. Build a time ledger before annualizing an observed return.
Continue with the connected research module →
Python implementation
Self-contained teaching example. Python 3.10+; dependencies and input conventions are shown in the code and notation. Run in your own Python environment.
from math import expm1
def trapezoid(function,a,b,n):
if not isinstance(n,int) or n<1: raise ValueError("Positive integer n required")
h=(b-a)/n
return h*(.5*function(a)+sum(function(a+i*h) for i in range(1,n))+.5*function(b))
def continuous_flow_pv(flow,rate,years):
if years<0: raise ValueError("Nonnegative horizon required")
return flow*years if rate==0 else -flow*expm1(-rate*years)/rate
print(trapezoid(lambda x:x*x,0,1,2),continuous_flow_pv(100,.05,2))Continue learning
Integral Calculus: Accumulation & Area — all lessons- Start with rectangles: rate × time = amount
- Definite integrals: adding many small contributions
- Core integral rules: undo a derivative, then check
- Antiderivatives and the fundamental theorem
- Integration techniques: substitution and integration by parts
- Improper integrals, densities and continuous expectations
- Numerical integration and a continuous cash-flow building block
Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations