Mehmet Emre Tiryaki
Back to Notes

Floating Point and Conditioning

Floating Point

F={±(1+f)⋅2e},f=∑i=1dbi2−i=2−dz,bi∈{0,1},  z∈{0,1,…,2d−1}\mathbb{F} = \{ \pm (1 + f) \cdot 2^e \}, \qquad f = \sum_{i=1}^{d} b_i 2^{-i} = 2^{-d} z, \quad b_i \in \{0, 1\}, \; z \in \{0, 1, \ldots, 2^d - 1\}

So [2e,2e+1)[2^e, 2^{e+1}) contains 2d2^d evenly spaced numbers with spacing 2e−d2^{e-d}, and εmach=2−d\varepsilon_{\mathrm{mach}} = 2^{-d}. Rounding to the nearest,

∣fl(x)−x∣∣x∣≤2e−d−12e=12εmach,fl(x)=x(1+ϵ),  ∣ϵ∣≤12εmach\frac{|fl(x) - x|}{|x|} \le \frac{2^{e-d-1}}{2^e} = \frac{1}{2}\varepsilon_{\mathrm{mach}}, \qquad fl(x) = x(1 + \epsilon), \; |\epsilon| \le \frac{1}{2}\varepsilon_{\mathrm{mach}}

IEEE 754 double precision: 1 sign bit, 11 exponent bits, d=52d = 52, −1022≤e≤1023-1022 \le e \le 1023, εmach=2−52\varepsilon_{\mathrm{mach}} = 2^{-52}.

Accuracy

Absolute error ∣x~−x∣|\tilde{x} - x|, relative error ∣x~−x∣∣x∣\frac{|\tilde{x} - x|}{|x|}, and accurate digits −log⁡10∣x~−xx∣-\log_{10} \Big| \frac{\tilde{x} - x}{x} \Big|.

Condition Number

The ratio of relative changes in the output and input,

∣f(x)−f(x~)∣ / ∣f(x)∣∣x−x~∣ / ∣x∣  ⟶  κf(x)=∣xf′(x)f(x)∣\frac{|f(x) - f(\tilde{x})| \,/\, |f(x)|}{|x - \tilde{x}| \,/\, |x|} \;\longrightarrow\; \kappa_f(x) = \Big| \frac{x f'(x)}{f(x)} \Big|

as x~→x\tilde{x} \to x. The absolute condition number is ∣f′(x)∣|f'(x)|. For a composition h(x)=f(g(x))h(x) = f(g(x)), κh(x)=κf(g(x))⋅κg(x)\kappa_h(x) = \kappa_f(g(x)) \cdot \kappa_g(x).

If κf≈10d\kappa_f \approx 10^d, about dd digits are lost, and if κf≈1/εmach\kappa_f \approx 1/\varepsilon_{\mathrm{mach}} the result can be off by 100%. If the algorithm's error is larger than the error from conditioning, the algorithm is unstable.