Formula

Formula.html Documentation

Build mathematical applications using our open-source WebAssembly-powered calculation engine.

🚀 Getting Started

1. Install CLI


npm install -g @formula/cli
# Or Yarn
yarn global add @formula/cli

Use the formula init command to create new projects with calculator templates.

2. API Reference

// Example usage const result = Formula.solve('2x^2 + 3x - 5', { x: 4 }); console.log(result); // { value: 15, steps: [...] }

All methods return Promise objects for asynchronous calculations.

🧩 Architecture

Core Components

  • Math Engine

    Rust-based computational core with WebAssembly bindings.

  • Formula Compiler

    Parses mathematical expressions into optimized ASTs.

  • Visualizer

    WebGL-based renderer for function graphs and 3D visualizations.

⚙️ Advanced Usage

Event System

Formula.addEventListener('calculate', (event) => { console.log('Calculation started:', event.detail.expression); }); Formula.addEventListener('error', (event) => { console.error('Math error:', event.detail.message); });

Track calculation progress and handle errors gracefully.

Custom Rules

// Adding domain-specific rules Formula.registerRule('physics', { variables: { g: 9.81, // gravity c: 3e8 // speed of light }, functions: { energy(mass) { return mass * 9000; } } });

Define context-specific constants and functions for specialized domains.