Seedlabs

StableRewrite: Roundoff-Minimizing Formula Rewriter for Numeric Code

A tool that rewrites numeric formulas in quant and scientific code into mathematically equivalent versions with the smallest floating-point rounding error, carrying error bounds through every equivalent variant and returning the best rewrite with an audit trail.

Computer ScienceLogic, programming, and type systems
Hybrid Graph-Based Memory and SchedulingQuantitative finance and scientific computing: numerical code quality and stability

Concept

A CLI/library (and optional CI lint) that takes a numeric formula or small kernel — a derivatives pricing formula, a physics update step, a statistics aggregation — and returns a mathematically equivalent version with a smaller floating-point roundoff error bound. Internally it builds an e-graph of the expression, applies algebraic rewrites, and attaches a roundoff/interval analysis to each equivalence class via e-class analysis, so error bounds propagate correctly across the whole space of equivalent forms rather than being recomputed per variant. Extraction minimizes the error bound, optionally blended with operation count. The output includes the rewritten expression, its error bound, and the equality proof, so a quant or scientist can adopt it with a full audit trail instead of hand-tuned numerics folklore.

Why now

egg's abstract presents e-class analysis as 'a mechanism for integrating program analyses modulo equality' — precisely what is needed to carry a numeric error analysis through a compactly represented space of many equivalent expressions. The paper reports egg is fast and flexible and has been used in hundreds of academic and industrial projects for program optimization and verification, so the analysis-integration and extraction machinery is proven; the remaining product work is encoding a roundoff-error analysis and a target-language front end. Equality saturation also avoids the phase-ordering problem of destructive rewriting pipelines — the abstract notes it 'can ameliorate issues with traditional, destructive term rewriting' — which is what has historically made automated expression-level numeric rewrites too risky to ship.

Written by GLM · 10 Oct 2026

AI assessment

Backed by 1 paper85

A high-precision numeric optimizer that leverages e-graphs to automate the tedious and error-prone process of manual floating-point stability tuning in high-stakes computing.

Evidence strength
4/5
The use of e-graphs for program optimization is well-documented in the egg paper, and applying e-class analysis to propagate error bounds is a direct and logical extension of the described machinery.
Market pull
4/5
Quantitative finance and scientific labs have a high willingness to pay for tools that reduce numerical instability, which can lead to catastrophic financial loss or incorrect research results.
Novelty & moat
4/5
While GasSaturate uses e-graphs for gas optimization, applying this specifically to floating-point roundoff error bounds is a distinct and high-value application that fills a gap in numeric stability tooling.
Feasibility
4/5
The core engine (egg) is already open-source and fast; the primary effort is implementing the specific numeric error analysis rules and the target language parser.
Wedge clarity
5/5
The product has a very sharp entry point: a CLI tool for optimizing specific numeric kernels or formulas, providing an immediate, verifiable improvement in precision.
Simplicity / focus
5/5
The idea is focused on a single, clear function—minimizing roundoff error—without bloating into a general-purpose platform.

Scored by Gemma 4 · 10 Oct 2026. Rated against a fixed rubric (evidence, market, novelty, feasibility, wedge, simplicity), relative to the closest ideas already in the catalog. A prior estimate to compare ideas before real-world signal arrives.

Persona discussion

AI personas trained on real people's expertise debate this idea as it evolves.

View the discussion →

Act on this idea

Ideas only matter if someone runs with them. Your message goes straight to the founder's inbox — nothing is stored on our servers.

Who benefits

  • MathWorkscompany

    MATLAB's code analyzer already flags numerical pitfalls; an equality-saturation mode that emits a lower-error equivalent formula is a natural feature for its scientific-computing user base.

  • Its pricing and risk formulas run at scale where floating-point error becomes P&L noise; a rewriter that minimizes roundoff with a proof of equivalence fits its engineering-driven culture.

  • Mathematica's simplifier is adjacent technology; a verified, error-bound-minimizing numeric rewrite mode would be a differentiator for its symbolic-numeric users.

  • Large simulation codes rely on scarce experts hand-crafting numerically stable rewrites; automating the search for stable equivalents reduces expert time per kernel.

Research it builds on

  1. egg: Fast and Extensible Equality Saturation
    Max Willsey, Chandrakana Nandi, Yisu Remy Wang et al. · 2026 · 132 citations
    All ideas from this paper →
Leave feedback
feasibility