Examples#
This gallery walks through every public feature of mathematicskit.calculus:
finite-difference differentiation and Richardson extrapolation,
quadrature rules, forward- and reverse-mode automatic differentiation,
and Taylor series.
Each script in this gallery is self-contained and can be run directly with
python examples/calculus/<section>/<script>.py.
Sections#
exhaustion – Archimedes’ polygon bounds on pi.
newton_leibniz – the derivative and the integral as limits of difference quotients and sums.
finite_differences – Richardson extrapolation, Fermat’s adequality, and the complex-step derivative.
quadrature – Riemann sums, Simpson’s rule, Gauss-Legendre, Euler-Maclaurin, Romberg, Clenshaw-Curtis, tanh-sinh, and adaptive (QUADPACK) quadrature.
dual_numbers – forward-mode automatic differentiation with no finite-difference truncation error.
autodiff – reverse-mode (backpropagation-style) automatic differentiation for multivariable gradients.
taylor_series – Taylor’s theorem: Taylor polynomials, the Lagrange remainder bound, and radius of convergence.
Reverse-mode autodiff#
A small backpropagation-style engine for multivariable gradients.
Reverse-mode automatic differentiation for multivariable gradients
Dual numbers#
Forward-mode automatic differentiation: exact derivatives with no finite-difference truncation error.
Forward-mode automatic differentiation via dual numbers
Method of exhaustion#
Archimedes’ polygon bounds on pi, the oldest convergent approximation scheme.
Finite differences#
Richardson extrapolation, Fermat’s adequality, and the complex-step derivative.
Richardson extrapolation: cancelling error terms at a fixed step
Fermat’s adequality: maxima from a difference quotient
Newton and Leibniz#
The two central facts of the calculus of Newton and Leibniz: the derivative is a limiting difference quotient, and the definite integral is a limiting sum.
Newton and Leibniz: the derivative and the integral as limits
Quadrature#
Riemann sums, Simpson’s rule, Gauss-Legendre, Euler-Maclaurin, Romberg, Clenshaw-Curtis, tanh-sinh, and QUADPACK-style adaptive quadrature.
Gaussian quadrature: optimal nodes are exact to degree 2n-1
Romberg integration: extrapolating the trapezoidal rule
Tanh-sinh quadrature: integrating endpoint singularities
Adaptive quadrature (QUADPACK): subdividing where it is needed
Taylor series#
Maclaurin series for standard functions, their convergence, and their radius of convergence.
Taylor’s theorem: polynomials, remainder bound, and convergence