FLINT3.7.0-dev
Algorithm

Error propagation

Cost
Each bound costs O(1) operations on mag_t numbers.

A ball function evaluates its result at the midpoint of the input and adds to the radius a bound for the propagated error: how much the exact function can differ between the midpoint and any other point of the input ball. For a function ff and a ball [x±r][x \pm r], the task is to bound

∣f(x+a)−f(x)∣for all ∣a∣≤r,|f(x + a) - f(x)| \quad \text{for all } |a| \le r,

in terms of ∣x∣|x| and rr. Most bounds below increase with ∣a∣|a|, so they are stated in terms of ∣a∣|a| and applied with ∣a∣=r|a| = r. The rounding error of the midpoint computation is added separately (see Representation of radii and midpoints). All bounds are evaluated with mag_t arithmetic, rounding upward, from upper bounds for the quantities that occur in numerators and lower bounds for those in denominators.

Arithmetic#

Addition is immediate: ∣(x+a)+(y+b)−(x+y)∣≤∣a∣+∣b∣|(x + a) + (y + b) - (x + y)| \le |a| + |b|, so arb_add adds the radii.

Theorem 1 (Product). For x,y,a,b∈Cx, y, a, b \in \mathbb{C},

∣(x+a)(y+b)−xy∣≤∣x∣∣b∣+∣y∣∣a∣+∣a∣∣b∣.|(x + a)(y + b) - xy| \le |x||b| + |y||a| + |a||b|.

Proof. Expand (x+a)(y+b)−xy=xb+ya+ab(x + a)(y + b) - xy = xb + ya + ab and apply the triangle inequality.

The bound is attained for real numbers when all of x,y,a,bx, y, a, b have the same sign, so for real balls it is optimal up to rounding. arb_mul computes the radius ∣mx∣ry+∣my∣rx+rxry|m_x| r_y + |m_y| r_x + r_x r_y with mag_fast_mul and mag_fast_addmul, using upper bounds of ∣mx∣|m_x| and ∣my∣|m_y| obtained from the top 30 bits of the midpoints.

Theorem 2 (Quotient). For x,y,a,b∈Cx, y, a, b \in \mathbb{C} with ∣b∣<∣y∣|b| < |y|,

∣xy−x+ay+b∣≤∣x∣∣b∣+∣y∣∣a∣∣y∣(∣y∣−∣b∣).\left| \frac{x}{y} - \frac{x + a}{y + b} \right| \le \frac{|x||b| + |y||a|}{|y| (|y| - |b|)}.

Proof. We have xy−x+ay+b=x(y+b)−y(x+a)y(y+b)=xb−yay(y+b)\dfrac{x}{y} - \dfrac{x + a}{y + b} = \dfrac{x(y + b) - y(x + a)}{y(y + b)} = \dfrac{xb - ya}{y(y + b)}. The triangle inequality bounds the numerator by ∣x∣∣b∣+∣y∣∣a∣|x||b| + |y||a|, and the reverse triangle inequality gives ∣y+b∣≥∣y∣−∣b∣>0|y + b| \ge |y| - |b| > 0.

When ryr_y is much smaller than ∣my∣|m_y|, arb_div uses the simplified form

∣x∣ry+∣y∣rx∣y∣(∣y∣−ry)≤(1+ε)∣x/y∣ry+rx∣y∣,∣y∣∣y∣−ry≤1+ε,\frac{|x| r_y + |y| r_x}{|y|(|y| - r_y)} \le (1 + \varepsilon) \frac{|x/y| r_y + r_x}{|y|}, \quad \frac{|y|}{|y| - r_y} \le 1 + \varepsilon,

with the computed quotient in place of x/yx/y and a fixed factor 1+2−161 + 2^{-16} for 1+ε1 + \varepsilon, which is valid when the relative accuracy of yy is more than 20 bits. For less accurate input it evaluates the quotient at the endpoints instead, which gives a tighter enclosure.

Roots#

Theorem 3 (Square root). For real xx, aa with 0≤∣a∣≤x0 \le |a| \le x,

∣x+a−x∣≤x(1−1−∣a∣x)≤x2(∣a∣x+∣a∣2x2),|\sqrt{x + a} - \sqrt{x}| \le \sqrt{x} \left(1 - \sqrt{1 - \frac{|a|}{x}}\right) \le \frac{\sqrt{x}}{2} \left( \frac{|a|}{x} + \frac{|a|^2}{x^2} \right),

where the first inequality is an equality for a≤0a \le 0 (and the limit value is 0 when x=a=0x = a = 0).

Proof. Since the square root is concave, a perturbation of size ∣a∣|a| changes it most when it is negative, so the error is at most x−x−∣a∣=x(1−1−t)\sqrt{x} - \sqrt{x - |a|} = \sqrt{x}(1 - \sqrt{1 - t}) with t=∣a∣/x∈[0,1]t = |a|/x \in [0, 1]. For the second inequality we need 1−t≥1−(t+t2)/2\sqrt{1 - t} \ge 1 - (t + t^2)/2. The right side is nonnegative on [0,1][0, 1], and squaring turns the inequality into 1−t≥1−t−t2+(t+t2)2/41 - t \ge 1 - t - t^2 + (t + t^2)^2/4, that is, t2(t+3)(t−1)/4≤0t^2 (t + 3)(t - 1) / 4 \le 0, which holds for 0≤t≤10 \le t \le 1.

Theorem 4 (Reciprocal square root). For real x,ax, a with 0≤∣a∣<x0 \le |a| < x,

∣1x+a−1x∣≤∣a∣2(x−∣a∣)3/2.\left| \frac{1}{\sqrt{x + a}} - \frac{1}{\sqrt{x}} \right| \le \frac{|a|}{2 (x - |a|)^{3/2}}.

Proof. By the mean value theorem the difference is ∣a∣⋅∣f′(ξ)∣|a| \cdot |f'(\xi)| for some ξ\xi between xx and x+ax + a, where f(t)=t−1/2f(t) = t^{-1/2} and ∣f′(t)∣=t−3/2/2|f'(t)| = t^{-3/2}/2 is decreasing, so ∣f′(ξ)∣≤(x−∣a∣)−3/2/2|f'(\xi)| \le (x - |a|)^{-3/2}/2.

Theorem 5 (kk-th root). For k>1k > 1 and real x,ax, a with 0≤∣a∣≤x0 \le |a| \le x,

∣(x+a)1/k−x1/k∣≤x1/kmin⁡(1,1klog⁡(1+∣a∣x−∣a∣)).|(x + a)^{1/k} - x^{1/k}| \le x^{1/k} \min\left(1, \frac{1}{k} \log\left(1 + \frac{|a|}{x - |a|}\right)\right).

Proof. By concavity the error is largest for a=−ra = -r, r=∣a∣r = |a|, and

x1/k−(x−r)1/k=x1/k[1−exp⁡(1klog⁡(1−r/x))]≤x1/kmin⁡(1,−1klog⁡(1−r/x)),x^{1/k} - (x - r)^{1/k} = x^{1/k} \left[1 - \exp\left(\tfrac{1}{k} \log(1 - r/x)\right)\right] \le x^{1/k} \min\left(1, -\tfrac{1}{k} \log(1 - r/x)\right),

using 1−e−u≤min⁡(1,u)1 - e^{-u} \le \min(1, u) for u≥0u \ge 0. Finally −log⁡(1−r/x)=log⁡(1+r/(x−r))-\log(1 - r/x) = \log(1 + r/(x - r)).

Elementary functions#

The following bound is the general principle; the theorems after it are its sharp special cases.

Theorem 6 (Generic first-order bound). Let ff be differentiable on a neighbourhood of the segment from xx to x+ax + a (real or complex). Then

∣f(x+a)−f(x)∣≤min⁡(2C0,C1∣a∣),C0=sup⁡∣t∣≤∣a∣∣f(x+t)∣,C1=sup⁡∣t∣≤∣a∣∣f′(x+t)∣.|f(x + a) - f(x)| \le \min(2 C_0, C_1 |a|), \quad C_0 = \sup_{|t| \le |a|} |f(x + t)|, \quad C_1 = \sup_{|t| \le |a|} |f'(x + t)|.

Proof. The first bound is the triangle inequality, the second the mean value inequality ∣f(x+a)−f(x)∣=∣∫01f′(x+sa) a ds∣≤C1∣a∣|f(x + a) - f(x)| = |\int_0^1 f'(x + sa)\, a\, ds| \le C_1 |a|.

Theorem 7 (Exponential). For real x,ax, a: ∣ex+a−ex∣=ex∣ea−1∣≤ex(e∣a∣−1)|e^{x + a} - e^x| = e^x |e^a - 1| \le e^x (e^{|a|} - 1), with equality if a≥0a \ge 0.

Proof. For a≥0a \ge 0 this is an identity. For a<0a < 0, ∣ea−1∣=1−e−∣a∣≤e∣a∣−1|e^a - 1| = 1 - e^{-|a|} \le e^{|a|} - 1, since eu+e−u≥2e^u + e^{-u} \ge 2.

arb_exp therefore adds em(er−1)e^m (e^r - 1), computed with mag_expm1 and an upper bound for the computed eme^m, to the radius.

Theorem 8 (Logarithm). For real x,ax, a with 0≤∣a∣<x0 \le |a| < x,

∣log⁡(x+a)−log⁡(x)∣≤log⁡(1+∣a∣x−∣a∣),|\log(x + a) - \log(x)| \le \log\left(1 + \frac{|a|}{x - |a|}\right),

with equality if a≤0a \le 0.

Proof. The logarithm is concave and increasing, so the largest change is for a=−∣a∣a = -|a|, where log⁡x−log⁡(x−∣a∣)=log⁡(x/(x−∣a∣))=log⁡(1+∣a∣/(x−∣a∣))\log x - \log(x - |a|) = \log(x/(x - |a|)) = \log(1 + |a|/(x - |a|)).

arb_log uses this bound with mag_log1p when the input has more than about 20 bits of relative accuracy, and otherwise evaluates log⁡\log at both endpoints with the mag_t logarithm bounds.

Theorem 9 (Sine and cosine). For real x,ax, a: ∣sin⁡(x+a)−sin⁡x∣≤min⁡(2,∣a∣,∣cos⁡x∣∣a∣+∣a∣2/2)|\sin(x + a) - \sin x| \le \min(2, |a|, |\cos x| |a| + |a|^2/2), and the same holds for cos⁡\cos with ∣sin⁡x∣|\sin x| in place of ∣cos⁡x∣|\cos x|.

Proof. The bounds 2 and ∣a∣|a| follow from Theorem 6. For the third, Taylor's theorem with the Lagrange remainder gives sin⁡(x+a)=sin⁡x+acos⁡x−a22sin⁡ξ\sin(x + a) = \sin x + a \cos x - \tfrac{a^2}{2} \sin \xi, and ∣sin⁡ξ∣≤1|\sin \xi| \le 1.

arb_sin_cos uses the third form, with ∣cos⁡x∣|\cos x| bounded from an 8-bit table entry, which is much tighter than ∣a∣|a| near the extrema of the sine. Wide balls (radius above about 2−242^{-24}) are instead handled by evaluating at the endpoints and locating the extrema in between (arb_sin_cos_wide).

Theorem 10 (Arctangent). For real x,ax, a,

∣atan⁡(x+a)−atan⁡(x)∣≤min⁡(π,C1∣a∣),C1=sup⁡∣t∣≤∣a∣11+(x+t)2.|\operatorname{atan}(x + a) - \operatorname{atan}(x)| \le \min(\pi, C_1 |a|), \quad C_1 = \sup_{|t| \le |a|} \frac{1}{1 + (x + t)^2}.

If ∣a∣<∣x∣|a| < |x|, one may take C1=(1+(∣x∣−∣a∣)2)−1C_1 = (1 + (|x| - |a|)^2)^{-1}. Exactly, if ∣a∣<∣x∣|a| < |x| or ∣x(x+a)∣<1|x(x + a)| < 1, the difference equals atan⁡(∣a∣/∣1+x(x+a)∣)\operatorname{atan}(|a| / |1 + x(x + a)|) up to the choice of sign.

Proof. The first statement is Theorem 6 with f′=1/(1+t2)f' = 1/(1 + t^2) and the range of atan⁡\operatorname{atan} of length π\pi. If ∣a∣<∣x∣|a| < |x|, every point between xx and x+ax + a has absolute value at least ∣x∣−∣a∣|x| - |a|, which gives the monotone choice of C1C_1. The exact form is the subtraction formula atan⁡u−atan⁡v=atan⁡((u−v)/(1+uv))\operatorname{atan} u - \operatorname{atan} v = \operatorname{atan}((u - v)/(1 + uv)), valid when uv>−1uv > -1.

arb_atan uses ∣a∣/(1+(∣x∣−∣a∣)2)|a| / (1 + (|x| - |a|)^2), capped by π\pi, for accurate input and the endpoints otherwise.

Sums and series#

Many special functions are evaluated by truncating a series. The truncated sum is computed in ball arithmetic, and a bound for the tail is added to the radius. The following bounds are the most common.

Theorem 11 (Geometric bound). If ∣ck∣≤C|c_k| \le C for all k≥Nk \ge N and ∣z∣≤D<1|z| \le D < 1, then

∣∑k=N∞ckzk∣≤CDN1−D.\left| \sum_{k=N}^{\infty} c_k z^k \right| \le \frac{C D^N}{1 - D}.

Proof. Compare termwise with the geometric series ∑k≥NCDk\sum_{k \ge N} C D^k.

Theorem 12 (Integral bound). If ff is nonnegative and decreasing on [N,∞)[N, \infty), then

∫N∞f(t) dt≤∑k=N∞f(k)≤f(N)+∫N∞f(t) dt.\int_N^{\infty} f(t)\, dt \le \sum_{k=N}^{\infty} f(k) \le f(N) + \int_N^{\infty} f(t)\, dt.

Proof. For k≥Nk \ge N, f(k+1)≤∫kk+1f≤f(k)f(k + 1) \le \int_k^{k+1} f \le f(k); sum over kk.

For example, mag_hurwitz_zeta_uiui bounds ζ(s,a)≤a−s+a1−s/(s−1)\zeta(s, a) \le a^{-s} + a^{1-s}/(s - 1) in this way, and mag_exp_tail uses the geometric bound for the exponential series: if N≥2∣x∣N \ge 2|x|, consecutive terms of ∑k≥Nxk/k!\sum_{k \ge N} x^k/k! decrease by a factor at most 1/21/2, so the tail is at most twice its first term.

For analytic functions, the coefficients can be bounded by Cauchy's integral formula. If f(z)=∑k=0∞ckzkf(z) = \sum_{k=0}^{\infty} c_k z^k is analytic on a neighbourhood of the disk ∣z∣≤R|z| \le R, then

ck=12πi∫∣z∣=Rf(z)zk+1 dz,c_k = \frac{1}{2\pi i} \int_{|z| = R} \frac{f(z)}{z^{k+1}}\, dz,

which gives the following two bounds.

Corollary 13 (Cauchy bounds). With C=max⁡∣z∣=R∣f(z)∣C = \max_{|z| = R} |f(z)|, the coefficients satisfy ∣ck∣≤C/Rk|c_k| \le C / R^k, and for 0≤r<R0 \le r < R and ∣z∣≤r|z| \le r,

∣∑k=N∞ckzk∣≤CDN1−D,D=rR.\left| \sum_{k=N}^{\infty} c_k z^k \right| \le \frac{C D^N}{1 - D}, \quad D = \frac{r}{R}.

Proof. Bound the integrand by C/Rk+1C / R^{k+1} on a contour of length 2πR2\pi R; the tail bound is then Theorem 11 applied to ckRk⋅(z/R)kc_k R^k \cdot (z/R)^k.

The Euler-Maclaurin formula and its remainder bounds, used for the zeta function, are discussed in Zeta functions, polylogarithms and L-functions.

Use in FLINT#

void arb_mul(arb_t z, const arb_t x, const arb_t y, slong prec)
void arb_div(arb_t z, const arb_t x, const arb_t y, slong prec)
void arb_sqrt(arb_t z, const arb_t x, slong prec)
void arb_exp(arb_t z, const arb_t x, slong prec)
void arb_log(arb_t z, const arb_t x, slong prec)
void arb_sin_cos(arb_t s, arb_t c, const arb_t x, slong prec)
void arb_atan(arb_t z, const arb_t x, slong prec)

Referenced from#

Cite this page

The FLINT team, “Error propagation,” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/algorithms/ball-arithmetic/error-propagation.html (generated 2026-11-02).