Affine Arithmetic: Transcendental Functions #
This file implements transcendental functions for Affine Arithmetic using Chebyshev linearization combined with Taylor bounds.
Key Functions #
AffineForm.exp- Exponential functionAffineForm.tanh- Hyperbolic tangent (crucial for GELU)AffineForm.log- Natural logarithm (for LogSumExp)
Linearization Strategy #
For exp(x) on [a, b]:
- The secant line through (a, e^a) and (b, e^b) gives an upper bound
- The tangent at the midpoint gives a lower bound
- We use the midpoint tangent as the linear approximation with error bounds
For tanh(x):
- tanh is bounded in [-1, 1]
- For small x, tanh(x) ≈ x is a good approximation
- For larger x, we use the secant/tangent approach
Exponential Function #
Exponential using interval evaluation (loses correlation).
For tighter bounds, use expChebyshev which preserves linear terms.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Chebyshev linearization for exp(x) on [lo, hi].
Key insight: exp is convex, so the tangent line at any point is a lower bound. We use the tangent at the midpoint m: L(x) = e^m + e^m·(x - m) = e^m·(1 + x - m)
The error is bounded by the difference between the secant and tangent.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Hyperbolic Tangent #
tanh using interval evaluation.
tanh(x) = (e^x - e^{-x}) / (e^x + e^{-x}) Always bounded in (-1, 1).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Chebyshev linearization for tanh(x).
tanh'(x) = 1 - tanh²(x) = sech²(x)
For small x: tanh(x) ≈ x with error O(x³) For large |x|: tanh(x) ≈ ±1
We use the tangent at midpoint as approximation.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Natural Logarithm #
Logarithm using interval evaluation (requires positive input).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Chebyshev linearization for log(x) on [lo, hi] with lo > 0.
log'(x) = 1/x, so tangent at m is: L(x) = log(m) + (x - m)/m
Equations
- One or more equations did not get rendered due to their size.
Instances For
Hyperbolic Functions #
Hyperbolic sine: sinh(x) = (e^x - e^{-x})/2
Computed via interval sinh bounds (no correlation).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Hyperbolic cosine: cosh(x) = (e^x + e^{-x})/2
Computed via interval cosh bounds. Always ≥ 1.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Soundness Theorems #
exp is sound
tanh is sound
sinh is sound
cosh is sound
log is sound for positive inputs