Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

kneser-iteration

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.421477412919369

Install

pip 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 CLI

The only runtime dependency is NumPy. matplotlib is an optional extra (uv sync --extra plot).

How it works

Kneser's method is genuinely a piece of complex analysis; the steps below mirror the modules.

  1. Fixed point & regular super-function (_super.py). For base > e^(1/e) the map f(z) = base**z has no real fixed point but a complex-conjugate pair L, L̄. Linearising f about the principal one gives the regular super-function E — a Schröder power series in t = λ^z (with λ = f'(L), |λ| > 1) satisfying E(z+1) = f(E(z)) and E → L as Im z → +∞. This part is exact to ~1e-13 (verified in the tests).

  2. Realification (_realify.py). E is complex on the real axis. Kneser's insight: any 1-periodic holomorphic reparametrisation z ↦ kappa(z) = z + θ(z) preserves the Abel equation, so we choose θ to bend E's image onto the real line. Then F(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:

    • kappa maps the real axis onto a short healthy arc of real-value preimages, which we trace directly as a level set of Im E (inverting E hits spurious branches).
    • the integer tetration values are critical values of E (its downward orbit … → 1 → 0 → −∞ reaches the log-singularity), so kappa has 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.
  3. Contour-integral refinement (_cauchy.py, the default backend). The welding fit tops out near 1e-5 because 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. Sample F on 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| ≤ A expresses F at an interior point from its boundary alone: the right edge carries base**E, the left edge log_base(E) (both via the functional equation), and the top/bottom edges contribute the constants L, L̄ analytically. Evaluating that formula on the imaginary axis gives a well-posed second-kind equation for E — crucially not the rank-deficient on-boundary (Plemelj) equation — solved by an under-relaxed Gauss–Seidel iteration that enforces E(−y) = conj(E(y)) (so F is real on the reals) and gains 1–2 digits per sweep. Result: ~1e-14.

  4. Tetration wrapper (tetration.py). Anchors F to sexp(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 to e^(1/e) fall back to welding automatically if the contour iteration does not converge.

Generic fractional iteration

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 = identity

iterate(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).

Accuracy

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.

Tests

uv run pytest

covers 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.

References

  • 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).

License

MIT

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages