Interval differentiation of arithmetic expressions #
The mean value form, the interval Newton method and the Krawczyk test need enclosures of
derivatives or slopes. This file computes them automatically for arithmetic expressions
(ConvexAnalysis.ArithExpr): the symbolic partial derivative ArithExpr.pderiv i e is again an
arithmetic expression, so its natural interval extension, or any evaluation of it with outward
rounding, encloses the partial derivative of e on a box by the fundamental theorem of interval
arithmetic. With these derivative enclosures the mean value form encloses the range, interval
branch and bound with the mean value form converges, and the interval matrix of the computed
partial derivatives of a system encloses its slopes. So the interval Krawczyk test needs no
hypothesis besides the computed inclusion; the interval Newton test needs in addition that every
matrix of the interval matrix is invertible, and its operator is the exact Newton set, not a
computed hull. The Hansen–Sengupta test (ConvexAnalysis.HansenSengupta) computes an enclosure of
the Newton set and needs no regularity hypothesis.
Main definitions #
ConvexAnalysis.ArithExpr.pderiv i e: the symbolic partial derivative ofewith respect to the variablex i(sum, product, chain and power rules,exp' = exp,log' = x⁻¹,√' = (2 √x)⁻¹,(x⁻¹)' = -(x⁻¹)²), without simplification.ConvexAnalysis.ArithExpr.IsSmoothAt x e: no inverse, logarithm or square root inehas the argument0atx, a syntactic condition sufficient for smoothness.ConvexAnalysis.ArithExpr.intervalGradient e X: the natural interval extensions of the partial derivatives on the boxX, used as derivative enclosures in branch and bound.
Main statements #
ConvexAnalysis.ArithExpr.hasFDerivAt_eval: correctness of the symbolic derivative: whereeis smooth, its real value is differentiable with the partial derivativesArithExpr.pderiv i e(ConvexAnalysis.ArithExpr.fderiv_eval_apply_single,ConvexAnalysis.ArithExpr.hasDerivAt_eval_update); it is even smooth (ConvexAnalysis.ArithExpr.contDiffAt_eval).ConvexAnalysis.ArithExpr.isSmoothAt_of_intervalEval_pderiv_eq_some: if the natural interval extension of a partial derivative is defined on a box, theneis smooth on the box.ConvexAnalysis.ArithExpr.fderiv_eval_apply_single_mem,ConvexAnalysis.ArithExpr.IsRoundedEval.fderiv_eval_apply_single_mem: derivative enclosures: the natural interval extension ofArithExpr.pderiv i eonX, and every rounded evaluation of it, contains the partial derivative ofeat every point ofX.ConvexAnalysis.ArithExpr.exists_length_intervalEval_pderiv_le: the derivative enclosures converge linearly on the subboxes of a box on which they are defined, with no further condition on square roots (ConvexAnalysis.ArithExpr.sqrtArgPos_of_intervalEval_pderiv_eq_some).ConvexAnalysis.ArithExpr.mem_meanValueForm_pderiv: the mean value form with computed derivative enclosures encloses the range;ConvexAnalysis.ArithExpr.exists_meanValueForm_pderiv_approx: it approximates the range quadratically;ConvexAnalysis.BranchAndBound.exists_isMinOn_and_tendsto_meanValue_pderiv: interval branch and bound with it converges.ConvexAnalysis.isSlopeEnclosure_of_isRoundedEval_pderiv: the interval matrix of computed partial derivatives of a systemF : ι → ArithExpr ιencloses the slopes on the box;ConvexAnalysis.existsUnique_eq_zero_of_intervalKrawczyk_pderiv: the interval Krawczyk test with automatically computed slopes and an enclosure ofF(x₀), whose hypotheses besidesx₀ ∈ Xare computed inclusions;ConvexAnalysis.existsUnique_eq_zero_of_intervalNewton_subset_pderiv: the interval Newton test with these slopes, which also assumes that every matrix of the interval matrix is invertible and that the exact Newton set lies in the box.
Implementation notes #
- Symbolic differentiation or automatic differentiation. Forward-mode automatic differentiation
in interval arithmetic ([Ral81]; the recursive differentiation of
Neumaier, Section 2.2; for Taylor coefficients,
Moore–Kearfott–Cloud, Section 9.3) evaluates pairs (value,
derivative) of intervals. The natural interval extension of
ArithExpr.pderiv i ecomputes the same intervals as forward mode with the same differentiation rules, since its subexpressions are those ofeand their derivatives; only the sharing of common subexpressions is lost, which costs time but does not change the results. The symbolic form is used because the derivative is again anArithExpr: the fundamental theorem, inclusion isotonicity, outward rounding (ConvexAnalysis.ArithExpr.IsRoundedEval) and the convergence theory ofConvexAnalysis.IntervalArithmeticapply to it unchanged, with no second evaluator to verify. - No simplification.
ArithExpr.pderivkeeps every subexpression, also those with derivative0(0 · …): then a defined interval extension of a partial derivative certifies thateis smooth on the whole box, which the mean value theorem needs. The price is that, for example,∂/∂x₁ √x₂is defined only where the interval ofx₂is positive. Multiplying by[0, 0]or adding it is exact in interval arithmetic, so no width is lost. - Smoothness.
ArithExpr.evaluses Mathlib's total functions, which are smooth onℝ \ {0}(Real.log x = log |x|,Real.sqrt x = 0forx < 0), soArithExpr.IsSmoothAtonly asks for nonzero arguments; whereeis defined (ArithExpr.IsDefinedAt), this means positive arguments of square roots. On a box with a defined derivative enclosure the arguments of square roots are positive anyway: the interval of(2 √u)⁻¹is defined only if that ofuis. - Derivatives are
fderiv ℝ (fun y ↦ e.eval y) xapplied toPi.single i 1, as in the mean value form ofConvexAnalysis.IntervalArithmetic, and the derivative of the real value isv ↦ ∑ i, ∂ᵢe(x) v i. - Computation.
ArithExpr.intervalEvalhas real endpoints and is not computable; a verified computation needs an evaluator with dyadic or floating-point endpoints whose results areConvexAnalysis.ArithExpr.IsRoundedEval. The theorems withIsRoundedEvalhypotheses are stated for this use;ConvexAnalysis.IntervalDyadicprovides such an evaluator (ConvexAnalysis.RatArithExpr.dyadicEval) and a Krawczyk test evaluated by the kernel (ConvexAnalysis.RatArithExpr.existsUnique_eq_zero_of_krawczykTest). ConvexAnalysis.existsUnique_eq_zero_of_intervalNewton_subset_pderivasks for the inclusion of the exact Newton set and for the invertibility of every matrix of the interval matrix. The computable form is the Hansen–Sengupta operator, one interval Gauss–Seidel sweep, whose test certifies both (ConvexAnalysis.existsUnique_eq_zero_of_hansenSengupta_pderiv, and with dyadic intervalsConvexAnalysis.RatArithExpr.existsUnique_eq_zero_of_hansenSenguptaTest).- Searches on 2026-12-01 (Mathlib
5a27f5e): Mathlib has no automatic or symbolic differentiation of expressions and no derivative enclosures (MvPolynomial.pderivis the algebraic derivative of polynomials); itsinclusiontactic (Mathlib/Tactic/Inclusion) bounds values, not derivatives. No pull request (any state) matches "automatic differentiation", "interval derivative", "derivative enclosure" or "symbolic derivative"; "slope" finds no interval slopes, "interval arithmetic" only theinclusiontactic PRs (#42850, #45638, #46487 merged, #46628 open) and #20636 (closed).
References #
- L. B. Rall, Automatic Differentiation: Techniques and Applications, Lecture Notes in Computer Science 120, Springer, 1981.
- A. Neumaier, Interval Methods for Systems of Equations, Cambridge University Press, 1990, Sections 2.2, 2.3 and 5.1.
- R. E. Moore, R. B. Kearfott, M. J. Cloud, Introduction to Interval Analysis, SIAM, 2009, Section 9.3.
Tags #
automatic differentiation, symbolic differentiation, interval arithmetic, derivative enclosure, slope enclosure, mean value form, interval branch and bound, Krawczyk test, interval Newton method
The symbolic partial derivative of an expression with respect to the variable x i, by
the rules of differentiation: (e₁ e₂)' = e₁' e₂ + e₁ e₂', (e⁻¹)' = -(e' (e⁻¹)²),
(exp e)' = e' exp e, (log e)' = e' e⁻¹, (√e)' = e' (2 √e)⁻¹ and
(e ^ k)' = e' (k e ^ (k - 1)). No simplification is done, so every subexpression of e and its
derivative occur in the result (ArithExpr.isSmoothAt_of_intervalEval_pderiv_eq_some).
Equations
- ConvexAnalysis.ArithExpr.pderiv i (ConvexAnalysis.ArithExpr.const c) = ConvexAnalysis.ArithExpr.const 0
- ConvexAnalysis.ArithExpr.pderiv i (ConvexAnalysis.ArithExpr.var j) = ConvexAnalysis.ArithExpr.const (if j = i then 1 else 0)
- ConvexAnalysis.ArithExpr.pderiv i (e₁.add e₂) = (ConvexAnalysis.ArithExpr.pderiv i e₁).add (ConvexAnalysis.ArithExpr.pderiv i e₂)
- ConvexAnalysis.ArithExpr.pderiv i e.neg = (ConvexAnalysis.ArithExpr.pderiv i e).neg
- ConvexAnalysis.ArithExpr.pderiv i (e₁.mul e₂) = ((ConvexAnalysis.ArithExpr.pderiv i e₁).mul e₂).add (e₁.mul (ConvexAnalysis.ArithExpr.pderiv i e₂))
- ConvexAnalysis.ArithExpr.pderiv i e.inv = ((ConvexAnalysis.ArithExpr.pderiv i e).mul (e.inv.pow 2)).neg
- ConvexAnalysis.ArithExpr.pderiv i e.exp = (ConvexAnalysis.ArithExpr.pderiv i e).mul e.exp
- ConvexAnalysis.ArithExpr.pderiv i e.log = (ConvexAnalysis.ArithExpr.pderiv i e).mul e.inv
- ConvexAnalysis.ArithExpr.pderiv i e.sqrt = (ConvexAnalysis.ArithExpr.pderiv i e).mul ((ConvexAnalysis.ArithExpr.const 2).mul e.sqrt).inv
- ConvexAnalysis.ArithExpr.pderiv i (e.pow k) = (ConvexAnalysis.ArithExpr.pderiv i e).mul ((ConvexAnalysis.ArithExpr.const ↑k).mul (e.pow (k - 1)))
Instances For
e.IsSmoothAt x: every inverse, logarithm and square root in e is applied to a nonzero
number at x. This syntactic condition is sufficient for smoothness, not necessary: then the real
value of e is smooth near x (ArithExpr.contDiffAt_eval), with the partial derivatives given
by ArithExpr.pderiv (ArithExpr.hasFDerivAt_eval), but for example (x - x)⁻¹ is constant and
not IsSmoothAt anywhere. The real
value uses Mathlib's total functions, which are smooth away from 0 (Real.log x = log |x|, and
Real.sqrt x = 0 for x < 0); where e is defined (ArithExpr.IsDefinedAt), the condition says
that every square root has a positive argument.
Equations
- ConvexAnalysis.ArithExpr.IsSmoothAt x (ConvexAnalysis.ArithExpr.const c) = True
- ConvexAnalysis.ArithExpr.IsSmoothAt x (ConvexAnalysis.ArithExpr.var j) = True
- ConvexAnalysis.ArithExpr.IsSmoothAt x (e₁.add e₂) = (ConvexAnalysis.ArithExpr.IsSmoothAt x e₁ ∧ ConvexAnalysis.ArithExpr.IsSmoothAt x e₂)
- ConvexAnalysis.ArithExpr.IsSmoothAt x e.neg = ConvexAnalysis.ArithExpr.IsSmoothAt x e
- ConvexAnalysis.ArithExpr.IsSmoothAt x (e₁.mul e₂) = (ConvexAnalysis.ArithExpr.IsSmoothAt x e₁ ∧ ConvexAnalysis.ArithExpr.IsSmoothAt x e₂)
- ConvexAnalysis.ArithExpr.IsSmoothAt x e.inv = (ConvexAnalysis.ArithExpr.IsSmoothAt x e ∧ ConvexAnalysis.ArithExpr.eval x e ≠ 0)
- ConvexAnalysis.ArithExpr.IsSmoothAt x e.exp = ConvexAnalysis.ArithExpr.IsSmoothAt x e
- ConvexAnalysis.ArithExpr.IsSmoothAt x e.log = (ConvexAnalysis.ArithExpr.IsSmoothAt x e ∧ ConvexAnalysis.ArithExpr.eval x e ≠ 0)
- ConvexAnalysis.ArithExpr.IsSmoothAt x e.sqrt = (ConvexAnalysis.ArithExpr.IsSmoothAt x e ∧ ConvexAnalysis.ArithExpr.eval x e ≠ 0)
- ConvexAnalysis.ArithExpr.IsSmoothAt x (e.pow k) = ConvexAnalysis.ArithExpr.IsSmoothAt x e
Instances For
The real value is smooth where no inverse, logarithm or square root has the argument
0.
Correctness of the symbolic derivative: if no inverse, logarithm or square root in e has
the argument 0 at x, then the real value of e is differentiable at x, and its derivative is
v ↦ ∑ i, ∂ᵢe(x) v i with the partial derivatives ∂ᵢe(x) the values of ArithExpr.pderiv i e.
The partial derivatives of the real value at x are the values of the symbolic partial
derivatives, where e is smooth.
The partial derivative of e in direction i at x, as the derivative of
t ↦ e(x₁, …, t, …, xₙ) at t = x i, is the value of ArithExpr.pderiv i e.
Derivative enclosures #
If the natural interval extension of a partial derivative of e is defined on X, then e
is smooth at every point of X: ArithExpr.pderiv keeps every subexpression of e, and the
interval extensions of the inverses in ArithExpr.pderiv i e exclude the argument 0 of every
inverse, logarithm and square root of e.
If the natural interval extension of a partial derivative of e is defined on X, then every
square root in e and in the derivative has an argument bounded away from 0 on X
(ArithExpr.SqrtArgPos): the derivative (√u)' = u' (2 √u)⁻¹ is defined only if the interval
of u has a positive lower endpoint.
Linear convergence of derivative enclosures: if the natural interval extension of
ArithExpr.pderiv i e is defined on X₀, its length on the subboxes X of X₀ is at most
C · width X. This is ArithExpr.exists_length_intervalEval_le; its condition on square roots
holds by ArithExpr.sqrtArgPos_of_intervalEval_pderiv_eq_some.
Derivative enclosure by interval differentiation: if the natural interval extension
G of ArithExpr.pderiv i e is defined on X, then e is differentiable at every point x
of the box X, and its partial derivative ∂ᵢe(x) lies in G. This is the fundamental theorem
of interval arithmetic (ArithExpr.eval_mem_of_intervalEval_eq_some) for the symbolic
derivative, with ArithExpr.fderiv_eval_apply_single. The same intervals are computed by
forward-mode automatic differentiation in interval arithmetic, the recursive differentiation of
Neumaier, Section 2.2 and [Ral81].
Derivative enclosure with outward rounding: if G is a rounded evaluation of
ArithExpr.pderiv i e on X (ArithExpr.IsRoundedEval, for example an interval computed with
dyadic or floating-point endpoints and directed rounding), then the partial derivative ∂ᵢe(x)
lies in G for every x in the box X.
If a rounded evaluation of a partial derivative of e on X exists, then e is smooth at
every point of the box X.
The mean value form with automatic derivative enclosures #
The mean value form with interval derivatives encloses the range
(Neumaier, Theorem 2.3.3 with derivative enclosures by recursive
differentiation, Neumaier, Section 2.2): if the intervals G i are rounded
evaluations of the partial derivatives ArithExpr.pderiv i e on X (for example their natural
interval extensions, ArithExpr.isRoundedEval_of_intervalEval_eq_some) and c ∈ X, then
e(x) ∈ e(c) + ∑ i, G i · (X i - c i) for all x ∈ X. No condition on e itself is needed:
the derivative enclosures make e differentiable on X.
Quadratic convergence of the mean value form with interval derivatives
(Neumaier, Corollary 2.3.4 for this choice of derivative enclosures): if the
natural interval extensions of the partial derivatives of e are defined on X₀, there is L
such that on every subbox X of X₀ both endpoints of the mean value form with the natural
interval extensions G i of the partial derivatives on X are within n L (width X)² of values
of e on X. The derivative enclosures converge linearly
(ArithExpr.exists_length_intervalEval_pderiv_le), with no condition on square roots.
The natural interval extension of the gradient of e on X: the natural interval
extension of ArithExpr.pderiv i e, and the junk value [0, 0] where it is undefined. It
encloses the partial derivatives of e on X where it is defined
(ArithExpr.fderiv_eval_apply_single_mem).
Equations
Instances For
On the subboxes of a box on which they are defined, the natural interval extensions of the
partial derivatives are ArithExpr.intervalGradient.
Convergence of interval branch and bound with the mean value form and automatic
derivative enclosures: if the natural interval extensions of the partial derivatives of e
are defined on the box Icc a b, then e has a minimizer z on the box, and with the mean
value forms built from the natural interval extensions of the partial derivatives on each box
(ArithExpr.intervalGradient), the lower bounds of the selected boxes and the incumbent values
at their centers tend to e(z). This is
ConvexAnalysis.BranchAndBound.exists_isMinOn_and_tendsto_meanValue; its hypotheses hold by
ArithExpr.fderiv_eval_apply_single_mem and the linear convergence of the derivative
enclosures (ArithExpr.exists_length_intervalEval_pderiv_le).
Slope enclosures and the Krawczyk test with automatic derivatives #
Slope enclosure by interval differentiation: for a system F : ι → ArithExpr ι (the map
x ↦ (F k (x))ₖ), if every M k j is a rounded evaluation on X of the partial derivative
ArithExpr.pderiv j (F k) (for example its natural interval extension,
ArithExpr.isRoundedEval_of_intervalEval_eq_some), then the interval matrix M encloses the
slopes of the map on the box X. This is
ConvexAnalysis.isSlopeEnclosure_matrixIcc_of_hasFDerivWithinAt with the Jacobian enclosure of
ConvexAnalysis.ArithExpr.IsRoundedEval.fderiv_eval_apply_single_mem
(Neumaier, Corollary 5.1.5, with an interval Jacobian computed by recursive
differentiation, Neumaier, Section 2.2).
The map of a system F : ι → ArithExpr ι is continuous on a box on which its partial
derivatives have rounded evaluations.
The interval Krawczyk test with automatic derivatives: let F : ι → ArithExpr ι be a
system of expressions, M k j a rounded evaluation on the box X of the partial derivative
ArithExpr.pderiv j (F k) (for example its natural interval extension), x₀ ∈ X, Fx₀ an
interval vector enclosing F(x₀) (for example rounded evaluations of F k on the point box of
x₀, by ConvexAnalysis.ArithExpr.IsRoundedEval.eval_mem) and Y any matrix. If the interval
Krawczyk operator ConvexAnalysis.intervalKrawczyk with Fx₀ and the interval matrix M lies in
the interior of X, side by side, then the system F x = 0 has exactly one solution in X.
Besides x₀ ∈ X and the computed inclusions, nothing is assumed: differentiability and the
slope enclosure follow (ConvexAnalysis.isSlopeEnclosure_of_isRoundedEval_pderiv). This is the
strict Krawczyk test (Neumaier, Theorem 5.1.8 (iii), see
ConvexAnalysis.existsUnique_eq_zero_of_krawczyk_subset_interior) with the operator in real
interval arithmetic, which is not computable itself; with dyadic endpoints it is computed by
ConvexAnalysis.RatArithExpr.krawczykTest, and
ConvexAnalysis.RatArithExpr.existsUnique_eq_zero_of_krawczykTest is the form for a computed
result.
The interval Newton test with automatic derivatives: with M as in
ConvexAnalysis.existsUnique_eq_zero_of_intervalKrawczyk_pderiv, if every matrix in the interval
matrix M is invertible, x₀ ∈ X and the interval Newton operator
ConvexAnalysis.intervalNewton of M lies in X, then the system F x = 0 has exactly one
solution in X. This is ConvexAnalysis.existsUnique_eq_zero_of_intervalNewton_subset with the
slope enclosure ConvexAnalysis.isSlopeEnclosure_of_isRoundedEval_pderiv. Unlike the Krawczyk
test, the invertibility hunit is a hypothesis, and hN is the inclusion of the exact Newton
set, not of a computed hull. The Hansen–Sengupta test
ConvexAnalysis.existsUnique_eq_zero_of_hansenSengupta_pderiv computes an enclosure of the Newton
set and certifies the invertibility.