Engineering prototype
Hybrid symbolic-numeric optimization in a ring substrate
The claim
A practical question is whether simplifying a derivative once reduces the cost of repeated numerical evaluation. This prototype carries algebraic expressions and parameter values through a single implementation.
A ring-algebra substrate with βK-rewrite and autodiff in the same data structures removes the boundary. Symbolic simplification and numerical iteration live on the same expressions. Three applications follow immediately.
Newton-Raphson with simplified gradients
Standard Newton: xk+1 = xk − f(xk)/f'(xk). In a pure numerical framework, f' is computed at each iteration via autodiff or finite differences. Per-iteration cost: O(|f|).
With symbolic βK: compute f' symbolically once, simplify via βK, evaluate the simplified form N times. Per-iteration cost: O(|f'simplified|), amortized.
Measured on three functions:
| f(x) | f' raw size | f' simplified | Reduction | Iterations |
|---|---|---|---|---|
| x² − 2 | 9 | 3 | 67% | 3 → √2 |
| (x² + 0·x) − (x+x−x) | 21 | 5 | 76% | 5 → root 1.0 |
| x³ − 2x − 5 | 25 | 11 | 56% | 3 → 2.0946 |
The recorded derivative-expression sizes fell by 67%, 76% and 56%, respectively. These are node counts. End-to-end time also depends on simplification cost, sharing and numerical evaluation.
Equation discovery from data
Given data (xi, yi) and a hypothesis template with unknown coefficients — say y = a·x² + b·x + c — recover the coefficients.
The template is a symbolic expression with parameter-variables and input-variables:
template: (:add (:add (:mul (:var a) (:mul (:var x) (:var x)))
(:mul (:var b) (:var x)))
(:var c))
For each data point (xi, yi), build the residual squared: (template(xi) − yi)2. Sum over points to get total loss, a symbolic expression in parameters a, b, c.
βK simplifies the loss. Finite-difference gradient on parameters. Gradient descent iterates.
The pipeline: symbolic template → βK simplify → numerical gradient descent. Equation discovery without hand-written solvers.
Implementation present; convergence results pending validation.
Cartpole control
The classic pole-balancing benchmark. State s = [x, ẋ, θ, ω]. Control u ∈ ℝ (horizontal force). Dynamics: second-order ODE linearized around θ = 0. Goal: keep pole upright.
Standard RL approaches use Q-learning (discrete actions) or policy gradient with neural network. The ring substrate does neither. Instead:
The dynamics are symbolic ring-expressions. A rollout symbolically substitutes initial state, iterates the dynamics T times, and evaluates L. Finite-difference gradient on w. Update w. Repeat.
For linear dynamics and a quadratic cost, a Riccati solution gives a reference for the corresponding LQR problem. The prototype updates a symbolic-rollout controller by finite differences. Agreement with the reference requires a matched horizon and terminal cost and has not been demonstrated here.
Implementation present in hecke-lisp/learn/cartpole.lisp. Survival measurements pending validation runs; results will be added to this note when available.
The substrate that enables this
One data type (ring-expression tree) serves three roles:
- Symbolic manipulation: βK applies rewrites (constant folding, identity, η² = 3η, distributivity).
- Symbolic differentiation: chain-rule traversal of the expression tree produces the derivative expression.
- Numerical evaluation: substitute variable values, compute the real-number result.
No context switch. No translation layer. The same tree is manipulated by βK, differentiated by chain rule, and evaluated by numerical substitution. Information moves between symbolic and numeric phases without loss.
Why this matters beyond demos
Cartpole is a toy. But the method generalizes:
- Control with known dynamics. Any system with equations of motion can use a ring-expression rollout + gradient descent on policy. Robotics, chemical-process control, economic-trajectory planning.
- Scientific parameter-fitting. Fit ring-expression models (stoichiometry, kinetic equations, field equations) to data via the discovery pipeline.
- Physics-informed ML. The "known structure" is the ring-expression. The "unknown parameters" are coefficients. The training loop is gradient descent in the same substrate as the physics.
- Auto-simplification of cost functions. When the loss is symbolic, βK finds algebraic cancellations a numeric optimizer misses.
Comparison boundary
The table above compares expression sizes within this prototype. It includes no matched measurement against a computer algebra system or compiled autodifferentiation framework. A timing comparison would require the same expressions, numeric precision, reuse count and convergence tolerance.
Related
The L(x) = K(x | π(x)) framework explains why βK is a valid pre-processor: it preserves π-equivalence while reducing L, which shortens numerical evaluation cost. The auto-discovery paper shows how the algebraic laws exploited by βK can themselves be found without human input — completing the loop from structure-discovery to structure-exploitation.
Cite this page
Richard Hoekstra. Hybrid symbolic-numeric optimization in a ring substrate. https://richardhoekstra.nl/papers/hybrid-substrate.html