Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Fixed-point Taylor approximation of eze^zez (Harvey–van der Hoeven §2.8)

Definition
IntMul_HvdH_ExpApprox

by xuanji · Oct 11, 2026 · Mathlib 0df444a (Lean v4.33.1)

integer-multiplication

Computable integer approximation of the complex exponential. Gaussian integers a+bia+bia+bi are represented as pairs (a,b)∈Z2(a,b)\in\mathbb Z^2(a,b)∈Z2.

  • expTerm N x y j is the jjj-th Taylor term of 2Nez2^N e^{z}2Nez, z=(x+iy)/2Nz=(x+iy)/2^Nz=(x+iy)/2N, computed by the recurrence t0=2Nt_0=2^Nt0​=2N, tj+1=⌊tj (x+iy)/((j+1)2N)⌋t_{j+1}=\lfloor t_j\,(x+iy)/((j+1)2^N)\rfloortj+1​=⌊tj​(x+iy)/((j+1)2N)⌋ (floor applied to real and imaginary parts).
  • expApprox N K x y =∑j<K=\sum_{j<K}=∑j<K​ expTerm N x y j approximates 2Ne(x+iy)/2N2^N e^{(x+iy)/2^N}2Ne(x+iy)/2N.
  • expBits n x y approximates 2ne(x+iy)/2n2^n e^{(x+iy)/2^n}2ne(x+iy)/2n: it scales the input to precision 2n+92n+92n+9, sums 2n+132n+132n+13 terms, and rounds each component to the nearest multiple of 2n+92^{n+9}2n+9.
Definition code
import Mathlib

/-! Fixed-point approximation of the complex exponential on the unit disc
(Harvey–van der Hoeven §2.8). Gaussian integers are represented as pairs `(re, im) : ℤ × ℤ`. -/

namespace IntMul.HvdH

open Finset

/-- Taylor terms of `2^N exp(z)` for `z = (x + i y) / 2^N`, computed by the recurrence
`t_{j+1} = ⌊t_j · (x + i y) / ((j+1) 2^N)⌋` (floor on each component), starting from `t_0 = 2^N`. -/
def expTerm (N : ℕ) (x y : ℤ) : ℕ → ℤ × ℤ
  | 0 => (2 ^ N, 0)
  | j + 1 =>
    let t := expTerm N x y j
    ((t.1 * x - t.2 * y) / ((j + 1) * 2 ^ N), (t.1 * y + t.2 * x) / ((j + 1) * 2 ^ N))

/-- Sum of the first `K` Taylor terms: an approximation of `2^N exp((x + i y) / 2^N)`. -/
def expApprox (N K : ℕ) (x y : ℤ) : ℤ × ℤ :=
  (∑ j ∈ range K, (expTerm N x y j).1, ∑ j ∈ range K, (expTerm N x y j).2)

/-- `n`-bit approximation of `exp((x + i y) / 2^n)`: work at precision `2n+9` with `2n+13` terms,
then round each component to the nearest multiple of `2^{n+9}`. -/
def expBits (n : ℕ) (x y : ℤ) : ℤ × ℤ :=
  let e := expApprox (2 * n + 9) (2 * n + 13) (x * 2 ^ (n + 9)) (y * 2 ^ (n + 9))
  ((e.1 + 2 ^ (n + 8)) / 2 ^ (n + 9), (e.2 + 2 ^ (n + 8)) / 2 ^ (n + 9))

end IntMul.HvdH
Source
Harvey, van der Hoeven, Integer multiplication in time O(n log n), Annals of Math. 193 (2021), https://hal.science/hal-02070778, Section 2.8 (n-bit approximation of exp(z) for bounded z)

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me