I built a Gröbner Basis engine that solves 7-variable systems in the browser

5 points by diegoofernandez 15 hours ago

I'm a self-taught developer without formal education. After 3 months of intense study, I built a Gröbner basis engine that runs in the browser.

What it does: - Solves complex 4D systems like w²+x²+y²+z²=1 with symmetric constraints - 5-polynomial basis in 10 iterations - Exact BigInt arithmetic, zero approximations - Pure TypeScript, no dependencies

Why it matters: This makes advanced computational algebra accessible to anyone with a browser - no expensive software licenses needed.

Technical details: - Buchberger algorithm with optimized pair selection - AST architecture with Flyweight/Visitor patterns - Handles up to 7 variables practically

Live demo: https://romimath.pages.dev (Currently Gröbner basis - more features coming this week)

I'd love feedback from the computational math community.

diegoofernandez 14 hours ago

Author here. The journey from fractions to Gröbner in 3 months was brutal but enlightening.

Technical insights for the HN crowd: - Optimized pair selection beats naive Buchberger by 40% - AST memory pooling handles 7-variable polynomial explosion - BigInt precision eliminates numerical stability concerns

For enterprise folks: This solves the "last-mile" problem of mathematical optimization - accessible tools for domain experts.

The 7-variable limit isn't a bug, it's a feature - covers 80% of real business constraints while staying performant.

Demo is live at the link. Code architecture questions welcome.

  • keepamovin 9 hours ago

    I didn't look into the code, but what language did you use? Something to WASM? Or just JS? Or a backend? Also how do you model the symbolic terms?

    • diegoofernandez 5 hours ago

      Hi! Thanks for the excellent questions. It shows you're looking past the demo and into the core architecture.

      Language / Platform: The entire Romimath core engine is built purely in TypeScript, compiled directly to JavaScript (ES6+). It runs 100% client-side in the browser (as you see in the demo) to perform the heavy symbolic computation. We specifically avoided WASM for the core math to ensure maximum portability and maintainability within the JavaScript ecosystem, while still achieving extremely high performance (solving the 4D complex system in approx 2 seconds).

      2. Symbolic Terms Modeling: This is the most critical part, as it ensures the engine's precision:

      Custom AST and BigInt: We use a custom, modular Abstract Syntax Tree (AST) to model polynomials. All coefficients are handled using native JavaScript BigInt and our custom Rational Number class. This is non-negotiable, as it ensures infinite precision and eliminates floating-point error throughout the entire computation.

      Buchberger's Pairs (P_i, P_j): These pairs drive the algorithm's progress. For each pair, we: 1. Compute the S-polynomial (cancel leading terms) 2. Reduce it against the current basis 3. Add non-zero remainders as new constraints

      The speed you see comes from optimized pair selection - we skip pairs where leading terms are relatively prime (gcd=1), as they're guaranteed to reduce to zero. This avoids unnecessary computations while ensuring mathematical correctness.

      The value proposition is simple: Romimath is a full-stack algebraic engine that combines the portability of TypeScript with the mathematical certainty of BigInt for complex symbolic computation running entirely in the browser.

      Thanks for checking it out!

woori 13 hours ago

[dead]