Skip to content

Calculator Demo

O(1) compute via lookup tables. Every math operation is a single byte-array access.

f64 value embed(π) LUT[F] lift(λ) f64 result

Benchmark Results

Criterion benchmarks on native Rust. Hologram's advantage grows with operation complexity and data size.

Loading benchmark data…

Accuracy Analysis

LUT operations quantize continuous values into 256 levels. The tables below show approximation error from the calculator example.

Sin (Angle Encoding)

Inputf64 sinLUT sinError
0.00000.0000000.0039220.003922
0.50000.4794260.4666670.012759
1.00000.8414710.8431370.001666
2.00000.9092970.9137250.004428
π0.0000000.0039220.003922
5.0000-0.958924-0.9529410.005983

Sqrt (Unsigned Encoding)

Inputf64 sqrtLUT sqrtError
0.00000.0000000.0000000.000000
0.10000.3162280.3137250.002502
0.25000.5000000.4941180.005882
0.50000.7071070.7058820.001224
0.75000.8660250.8666670.000641
1.00001.0000001.0000000.000000

How It Works

Hologram pre-computes a 256-entry lookup table for each mathematical function. At runtime:

  1. Embed — an encoding maps a continuous f64 value to a byte (0-255)
  2. LUT Apply — a single array access table[byte] gives the output byte
  3. Lift — the inverse encoding maps the output byte back to f64

This trades precision (8-bit quantization, ~0.004 typical error) for constant-time O(1) execution regardless of operation complexity. Chains of operations (e.g., sin(cos(x))) are fused into a single 256-byte table at compile time.