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:

xaxbxa+bx^a \cdot x^b \rightarrow x^{a+b}

Noncommutative Algebra: For noncommutative symbols (matrices, operators): - ABBAAB \neq BA in general - (A+B)2=A2+AB+BA+B2(A + B)^2 = A^2 + AB + BA + B^2 (4 terms, not 3)

Rational Arithmetic: - Exact representation: 13\frac{1}{3} 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

🔗 Related Topics