use crate::algebra::simplification::registry::SIMPLIFICATION_REGISTRY;
use crate::core::Expression;
use std::slice::from_ref;
impl Expression {
pub(super) fn compute_factorial(&self, arg: &Expression) -> Expression {
SIMPLIFICATION_REGISTRY.simplify_function("factorial", from_ref(arg))
}
pub(super) fn simplify_log_function(&self, args: &[Expression]) -> Expression {
SIMPLIFICATION_REGISTRY.simplify_function("log", args)
}
pub(super) fn simplify_ln_function(&self, args: &[Expression]) -> Expression {
SIMPLIFICATION_REGISTRY.simplify_function("ln", args)
}
pub(super) fn is_trig_function(&self, name: &str) -> bool {
matches!(
name,
"sin"
| "cos"
| "tan"
| "csc"
| "sec"
| "cot"
| "asin"
| "acos"
| "atan"
| "sinh"
| "cosh"
| "tanh"
)
}
pub(super) fn simplify_trig_function(&self, name: &str, args: &[Expression]) -> Expression {
SIMPLIFICATION_REGISTRY.simplify_function(name, args)
}
pub(super) fn simplify_sqrt(&self, args: &[Expression]) -> Expression {
SIMPLIFICATION_REGISTRY.simplify_function("sqrt", args)
}
pub(super) fn simplify_abs(&self, args: &[Expression]) -> Expression {
SIMPLIFICATION_REGISTRY.simplify_function("abs", args)
}
pub(super) fn simplify_exp(&self, args: &[Expression]) -> Expression {
SIMPLIFICATION_REGISTRY.simplify_function("exp", args)
}
pub(super) fn simplify_gamma(&self, args: &[Expression]) -> Expression {
SIMPLIFICATION_REGISTRY.simplify_function("gamma", args)
}
pub fn factorial(arg: Expression) -> Expression {
Expression::function("factorial", vec![arg])
}
pub fn ln(arg: Expression) -> Expression {
Expression::function("ln", vec![arg])
}
}