Crate mathhook

Crate mathhook 

Source
Expand description

MathHook: High-performance educational computer algebra system

Created by Ahmed Mashhour

MathHook is a modern symbolic mathematics library written in Rust, featuring a hybrid API architecture that combines Expression-centric method chaining with separate solver objects for complex operations.

§Features

  • Memory-optimized: 32-byte Expression enum for maximum cache performance
  • Hybrid API: Expression methods + separate solver objects
  • Multi-format parsing: LaTeX, Wolfram Language, standard notation
  • Language bindings: Python (PyO3) and Node.js (NAPI-RS) support
  • Educational focus: Step-by-step explanations and teaching tools

§Quick Start

use mathhook::prelude::*;

// Expression-centric API (method chaining)
let expr = Expression::add(vec![
    Expression::integer(2),
    Expression::integer(3),
]).simplify();

// Solver object API (stateful operations)
let mut solver = MathSolver::new();
let x = symbol!(x);
let equation = Expression::equation(
    Expression::symbol("x"),
    Expression::integer(5),
);
let result = solver.solve(&equation, &x);

// Parser API (multi-format support)
let parser = Parser::new(&ParserConfig::default());
let parsed = parser.parse("x^2 + 2*x + 1")?;

Re-exports§

pub use mathhook_core as core;

Modules§

prelude
Convenience prelude for common imports

Structs§

MathSolver
Stateful mathematical solver for the hybrid API
Symbol
Mathematical symbol/variable with efficient string sharing

Enums§

Expression
Memory-optimized Expression enum (target: 32 bytes)
MathError
Comprehensive mathematical error type
Number
Unified number type supporting integers, rationals, and floats
ParseError
SolverResult
Result of a solving operation