Fractional (real and complex) tetration via Kneser's method, plus the map-generic fractional iteration engine underneath it.
Tetration b ^^ x extends the tower b^b^…^b to non-integer heights. It is the
continuous solution of
sexp(0) = 1, sexp(x + 1) = base ** sexp(x)
so sexp(1) = base, sexp(2) = base**base, and so on. There are infinitely many
smooth interpolations; Kneser's is the unique one that is real-analytic.
This package builds it for any base > e^(1/e) ≈ 1.4447, to ~1e-14 by default.
from kneser import sexp, slog, tet
sexp(0.5) # 1.6463542337512 (Kneser half-iterate, base e)
sexp(2) # 15.1542... (= e ** e, exact)
slog(sexp(0.3)) # 0.3 (round-trips to ~1e-10)
tet(2, base=2) # 4.0 (= 2 ^^ 2, exact)CLI:
$ kneser-tet 0.5 # e ^^ 0.5
1.6463542337512065
$ kneser-tet 2 --base 2 # 2 ^^ 2
4.0
$ kneser-tet 100 --slog # super-logarithm
2.421477412919369pip install kneser-iteration # the import name is `kneser`For a development environment:
uv sync # dev environment (numpy; pytest dev group)
uv run kneser-tet 0.5 # run the CLIThe only runtime dependency is NumPy. matplotlib is an optional extra
(uv sync --extra plot).
Kneser's method is genuinely a piece of complex analysis; the steps below mirror the modules.
-
Fixed point & regular super-function (
_super.py). Forbase > e^(1/e)the mapf(z) = base**zhas no real fixed point but a complex-conjugate pairL, L̄. Linearisingfabout the principal one gives the regular super-functionE— a Schröder power series int = λ^z(withλ = f'(L),|λ| > 1) satisfyingE(z+1) = f(E(z))andE → LasIm z → +∞. This part is exact to ~1e-13 (verified in the tests). -
Realification (
_realify.py).Eis complex on the real axis. Kneser's insight: any 1-periodic holomorphic reparametrisationz ↦ kappa(z) = z + θ(z)preserves the Abel equation, so we chooseθto bendE's image onto the real line. ThenF(z) = E(kappa(z))is the real-analytic super-function.Two subtleties make this the hard part of Kneser's method, and both are handled explicitly:
kappamaps the real axis onto a short healthy arc of real-value preimages, which we trace directly as a level set ofIm E(invertingEhits spurious branches).- the integer tetration values are critical values of
E(its downward orbit… → 1 → 0 → −∞reaches the log-singularity), sokappahas square-root branch points at every integer. A plain Fourierθcannot represent that, so we add singular basis functions(1 − e^{2πiz})^{k+1/2}— exactly the right√behaviour at every integer — and fit the smooth remainder with a Fourier series, by Gauss–Newton.
-
Contour-integral refinement (
_cauchy.py, the default backend). The welding fit tops out near1e-5because its singular basis is an incomplete model ofθ. To reach machine precision we switch to Kouznetsov's contour-integral method (Math. Comp. 2009), using the welding result as a warm start. SampleFon the imaginary axis,E_n = F(i y_n), at Gauss–Legendre nodes. Cauchy's formula on the width-2 rectangle|Re z| ≤ 1, |Im z| ≤ AexpressesFat an interior point from its boundary alone: the right edge carriesbase**E, the left edgelog_base(E)(both via the functional equation), and the top/bottom edges contribute the constantsL, L̄analytically. Evaluating that formula on the imaginary axis gives a well-posed second-kind equation forE— crucially not the rank-deficient on-boundary (Plemelj) equation — solved by an under-relaxed Gauss–Seidel iteration that enforcesE(−y) = conj(E(y))(soFis real on the reals) and gains 1–2 digits per sweep. Result:~1e-14. -
Tetration wrapper (
tetration.py). AnchorsFtosexp(0) = 1, returns exact values at integers, and uses the functional equation to evaluate the whole real line from a single well-fit period.Tetration(base, method="cauchy")(default) uses the contour backend;method="welding"uses the welding fit alone (lower precision, but the route used by the map-generic engine). Bases extremely close toe^(1/e)fall back to welding automatically if the contour iteration does not converge.
Nothing above is specific to base**z. The engine KneserIterator builds real
continuous iterates f**t(x) of any analytic map whose relevant fixed point
is a complex-conjugate pair with |f'(L)| > 1:
import numpy as np
from kneser import KneserIterator
ki = KneserIterator(lambda z: np.exp(z), seed=0.3 + 1.3j) # f = exp
ki.iterate(1.0, 0.5) # exp^[0.5](1) — the half-iterate of exp, = sexp(0.5)
ki.iterate(2.0, 0.0) # 2.0 — f**0 = identityiterate(x, t) is F(t + abel(x)) with f**0 = id, f**1 = f. Maps with a real
or parabolic fixed point fall outside Kneser's regime and raise RegimeError
(use regular iteration instead).
With the default contour backend, fractional values reach near machine precision; integer values are exact.
| quantity | method="cauchy" (default) |
method="welding" |
|---|---|---|
sexp(0.5) base e |
~1e-13 (= 1.6463542337512) | ~1e-5 |
| fractional values | ~1e-12 | ~1e-5 relative |
slog / sexp inverse |
~1e-10 | ~1e-5 |
| integer values | exact | exact |
sexp(x+1)=b**sexp(x) |
~1e-12 | ~1e-9 |
The contour solver uses A=24, N=1024 Gauss–Legendre nodes by default
(Tetration(base, cauchy_A=…, cauchy_N=…)); the welding warm start is tuned via
n_modes=…, n_singular=…, grid=…, iters=…. The published reference value
1.6463542337512 is from Kouznetsov (2009) Table 2 and reproduced here to
~1e-13 — note an older constant 1.6463542337308158 that circulates is wrong
beyond ~10 digits.
A related survey, arXiv:2509.24049, sets Kneser's method aside as "computationally expensive, requiring complex contour integration" and offers cheaper real-axis approximations whose half-iterate differs from Kneser's. This package implements the canonical (real-analytic) Kneser solution instead — and the contour integration takes only a few seconds.
uv run pytestcovers the contour backend against Kouznetsov's published F(x) and F(iy)
tables (~1e-11), the regular super-function's functional equation (~1e-10),
integer towers, monotonicity, high-precision sexp/slog inversion, several
bases, the welding backend and near-threshold fallback, regime rejection, and
the generic engine reproducing tetration from f = exp.
- H. Kneser, Reelle analytische Lösungen der Gleichung φ(φ(x)) = eˣ …, J. reine angew. Math. 187 (1950).
- D. Kouznetsov, Solution of F(z+1)=exp(F(z)) in complex z-plane, Math. Comp. 78 (2009).
- W. Paulsen & S. Cowgill, Solving F(z+1)=b^{F(z)} in the complex plane, Adv. Comput. Math. 43 (2017).
MIT