Skip to main content

canonical_form

Function canonical_form 

Source
pub fn canonical_form(expr: &Expr) -> Result<Expr, CanonicalizationError>
Expand description

Normalize an expression into its exact canonical sum-of-terms form.

This performs exact symbolic simplification:

  • Flattens nested Add/Mul
  • Merges duplicate additive terms by summing coefficients
  • Merges repeated multiplicative factors into powers
  • Preserves signed coefficients (supports subtraction)
  • Preserves transcendental identities: exp(a)*exp(b)=exp(a+b), etc.
  • Produces deterministic ordering

Does NOT drop terms or constant factors — use big_o_normal_form() for that.