Symbolic Simplification
MathHook provides comprehensive symbolic simplification for mathematical expressions, with full support for noncommutative algebra (matrices, operators, quaternions). The simplification system implements canonical forms and mathematical identities to reduce expressions to their simplest equivalent representation.
📐
Mathematical Definition
Power Rule:
Noncommutative Algebra: For noncommutative symbols (matrices, operators): - in general - (4 terms, not 3)
Rational Arithmetic: - Exact representation: stays as rational, not float - Automatic simplification: Reduces fractions to lowest terms
Code Examples
Basic Simplification
Identity elements and constant folding
use mathhook::prelude::*;
let x = symbol!(x);
// Identity elements
let expr = expr!((x + 0) * 1);
let simplified = expr.simplify();
// Result: x
// Constant folding
let expr = expr!(2 + 3);
let simplified = expr.simplify();
// Result: 5
Power Rule
Combine like powers with same base
use mathhook::prelude::*;
let x = symbol!(x);
// Combine like powers
let expr = expr!((x^2) * (x^3));
let simplified = expr.simplify();
// Result: x^5
// Multiple powers
let expr = expr!((x^2) * (x^3) * (x^4));
let simplified = expr.simplify();
// Result: x^9
Noncommutative Matrices
Matrix multiplication does NOT commute
use mathhook::prelude::*;
let A = symbol!(A; matrix);
let B = symbol!(B; matrix);
// Matrix multiplication does NOT commute
let expr = expr!(A * B);
// Simplification preserves order: A*B ≠ B*A