Algorithm Search⌘K

Proofs: Veltkamp splitting

These are the human proofs of Veltkamp splitting, at full length.

Veltkamp splitting returns an exact split into short parts full

This proof shows: correctness.

Setting. Radix 2, precision pp, round to nearest with a symmetric tie rule (the rounded value of −x-x is the negative of the rounded value of xx), 1≤s≤p−11 \le s \le p - 1, σ=2s\sigma = 2^s, C=σ+1C = \sigma + 1. The input aa is a normal float, and no operation overflows. We use two facts about binary floats.

  • (F1) If UU is a power of two and kk is an integer with ∣k∣≤2p|k| \le 2^p, then kUkU is a float, provided U≥2emin⁡−p+1U \ge 2^{e_{\min} - p + 1} and no overflow occurs.
  • (F2) If xx lies in a binade [2e,2e+1][2^e, 2^{e+1}], every float in that binade is a multiple of 2e−p+12^{e - p + 1}, and rounding to nearest gives the nearest multiple of 2e−p+12^{e-p+1} (ties by the tie rule).

Theorem. Lines L1 to L5 return aha_h and ala_l with ah+al=aa_h + a_l = a, aha_h a multiple of σ ulp(a)\sigma\,\mathrm{ulp}(a), and ∣al∣≤σ2 ulp(a)|a_l| \le \tfrac{\sigma}{2}\,\mathrm{ulp}(a).

Proof. Everything commutes with multiplication by a power of two (as long as nothing underflows or overflows) and with negation (by the symmetric tie rule), so assume 1≤a<21 \le a < 2. Then ulp(a)=q=21−p\mathrm{ulp}(a) = q = 2^{1-p}, and aa is a multiple of qq.

Step 1: γ\gamma is a multiple of σq\sigma q and γ≥σ+1\gamma \ge \sigma + 1. The exact product Ca=σa+aCa = \sigma a + a satisfies σ+1≤Ca<2σ+2\sigma + 1 \le Ca < 2\sigma + 2. If Ca<2σCa < 2\sigma, it lies in [σ,2σ)[\sigma, 2\sigma), where the float spacing is σq\sigma q; otherwise it lies in [2σ,4σ)[2\sigma, 4\sigma), with spacing 2σq2\sigma q. In both cases γ=fl(Ca)\gamma = \mathrm{fl}(Ca) is a multiple of σq\sigma q by (F2). Since σ+1\sigma + 1 is a float (by (F1), as s≤p−1s \le p - 1) and rounding is monotone, γ≥σ+1\gamma \ge \sigma + 1.

Step 2: σ≤γ−a≤2σ\sigma \le \gamma - a \le 2\sigma. Write γ=Ca+ϵ1\gamma = Ca + \epsilon_1, so γ−a=σa+ϵ1\gamma - a = \sigma a + \epsilon_1.

  • Upper bound. If γ≤2σ\gamma \le 2\sigma, then γ−a≤2σ−1\gamma - a \le 2\sigma - 1. If γ>2σ\gamma > 2\sigma, then Ca≥2σCa \ge 2\sigma, because 2σ2\sigma is a float and rounding is monotone; so CaCa lies in [2σ,4σ)[2\sigma, 4\sigma), the spacing there is 2σq2\sigma q, ∣ϵ1∣≤σq|\epsilon_1| \le \sigma q, and γ−a=σa+ϵ1≤σ(2−q)+σq=2σ\gamma - a = \sigma a + \epsilon_1 \le \sigma(2 - q) + \sigma q = 2\sigma.
  • Lower bound. If a=1a = 1, then Ca=σ+1Ca = \sigma + 1 is a float, ϵ1=0\epsilon_1 = 0 and γ−a=σ\gamma - a = \sigma. If a≥1+qa \ge 1 + q and γ<2σ\gamma < 2\sigma, then ∣ϵ1∣≤σq/2|\epsilon_1| \le \sigma q / 2 and γ−a≥σ(1+q)−σq/2>σ\gamma - a \ge \sigma(1 + q) - \sigma q/2 > \sigma. If γ≥2σ\gamma \ge 2\sigma, then γ−a>2σ−2≥σ\gamma - a > 2\sigma - 2 \ge \sigma, since a<2a < 2 and σ≥2\sigma \ge 2.

Step 3: δ=−rndσq(γ−a)\delta = -\mathrm{rnd}_{\sigma q}(\gamma - a). By Step 2, γ−a\gamma - a lies in [σ,2σ][\sigma, 2\sigma]. Every float in that interval is a multiple of σq\sigma q and every multiple of σq\sigma q in it is a float by (F1), so rounding γ−a\gamma - a to nearest is rounding it to the nearest multiple of σq\sigma q. By the symmetric tie rule, δ=fl(a−γ)=−fl(γ−a)\delta = \mathrm{fl}(a - \gamma) = -\mathrm{fl}(\gamma - a) is a multiple of σq\sigma q with ∣δ−(a−γ)∣≤σq/2|\delta - (a - \gamma)| \le \sigma q/2.

Step 4: line L4 is exact and aha_h is aa rounded to a multiple of σq\sigma q. Since γ\gamma is a multiple of σq\sigma q, γ+δ\gamma + \delta is a multiple of σq\sigma q, and γ+δ=a+(δ−(a−γ))\gamma + \delta = a + (\delta - (a - \gamma)), so ∣γ+δ−a∣≤σq/2|\gamma + \delta - a| \le \sigma q / 2. With x=γ−ax = \gamma - a, γ+δ=γ−rndσq(x)\gamma + \delta = \gamma - \mathrm{rnd}_{\sigma q}(x), and since γ\gamma is a multiple of σq\sigma q this is the multiple of σq\sigma q nearest to γ−x=a\gamma - x = a (ties resolved by the tie rule applied to xx). Because 11 and 22 are multiples of σq=2s+1−p≤1\sigma q = 2^{s+1-p} \le 1 and 1≤a<21 \le a < 2, we get 1≤γ+δ≤21 \le \gamma + \delta \le 2, and γ+δ=kσq\gamma + \delta = k\sigma q with ∣k∣≤2/(σq)=2p−s|k| \le 2/(\sigma q) = 2^{p-s}. By (F1) it is a float, so ah=γ+δa_h = \gamma + \delta exactly.

Step 5: line L5 is exact. a−aha - a_h is a multiple of qq with ∣a−ah∣≤σq/2=2s−1q|a - a_h| \le \sigma q / 2 = 2^{s-1} q. Since s−1≤p−2s - 1 \le p - 2, by (F1) it is a float, so al=a−aha_l = a - a_h exactly. Consequently ah+al=aa_h + a_l = a.

Bit counts. ah=kσqa_h = k\sigma q with 2p−s−1≤∣k∣≤2p−s2^{p-s-1} \le |k| \le 2^{p-s}, so aha_h has at most p−sp - s significant bits (when ∣k∣=2p−s|k| = 2^{p-s} it is a power of two). al=mqa_l = mq with ∣m∣≤2s−1|m| \le 2^{s-1}; if ∣m∣=2s−1|m| = 2^{s-1} it is a power of two, otherwise ∣m∣<2s−1|m| < 2^{s-1} and ala_l has at most s−1s - 1 bits. So for s≥2s \ge 2 the low part has at most s−1s - 1 significant bits. □\square

Where the hypotheses are used. Normality of aa and of the intermediate values lets (F1) and (F2) use the binade spacing; overflow of CaCa breaks Step 1. The symmetric tie rule is used in Step 3. Under directed rounding Steps 3 and 4 no longer give the nearest multiple of σq\sigma q, and this proof does not cover that case.

Back to Veltkamp splitting