pub fn simplify_abs(arg: &Expression) -> ExpressionExpand description
Simplify absolute value expressions
Applies mathematical simplification rules for absolute value.
§Simplification Rules
- |0| = 0
- |-x| = |x|
- |x²| = x² (squares are always non-negative)
- |ab| = |a||b|
- |a/b| = |a|/|b|
- ||x|| = |x|
§Arguments
arg- The argument to the absolute value function
§Returns
Simplified expression
§Examples
use mathhook_core::core::Expression;
use mathhook_core::functions::elementary::abs::simplify_abs;
let zero = Expression::integer(0);
assert_eq!(simplify_abs(&zero), Expression::integer(0));
let neg_five = Expression::integer(-5);
assert_eq!(simplify_abs(&neg_five), Expression::integer(5));
let squared = Expression::pow(Expression::symbol("x"), Expression::integer(2));
assert_eq!(simplify_abs(&squared), squared);