mathhook_core/algebra/advanced_simplify/
helpers.rs1use crate::algebra::simplification::registry::SIMPLIFICATION_REGISTRY;
4use crate::core::Expression;
5use std::slice::from_ref;
6
7impl Expression {
8 pub(super) fn compute_factorial(&self, arg: &Expression) -> Expression {
10 SIMPLIFICATION_REGISTRY.simplify_function("factorial", from_ref(arg))
11 }
12
13 pub(super) fn simplify_log_function(&self, args: &[Expression]) -> Expression {
15 SIMPLIFICATION_REGISTRY.simplify_function("log", args)
16 }
17
18 pub(super) fn simplify_ln_function(&self, args: &[Expression]) -> Expression {
20 SIMPLIFICATION_REGISTRY.simplify_function("ln", args)
21 }
22
23 pub(super) fn is_trig_function(&self, name: &str) -> bool {
25 matches!(
26 name,
27 "sin"
28 | "cos"
29 | "tan"
30 | "csc"
31 | "sec"
32 | "cot"
33 | "asin"
34 | "acos"
35 | "atan"
36 | "sinh"
37 | "cosh"
38 | "tanh"
39 )
40 }
41
42 pub(super) fn simplify_trig_function(&self, name: &str, args: &[Expression]) -> Expression {
44 SIMPLIFICATION_REGISTRY.simplify_function(name, args)
45 }
46
47 pub(super) fn simplify_sqrt(&self, args: &[Expression]) -> Expression {
49 SIMPLIFICATION_REGISTRY.simplify_function("sqrt", args)
50 }
51
52 pub(super) fn simplify_abs(&self, args: &[Expression]) -> Expression {
54 SIMPLIFICATION_REGISTRY.simplify_function("abs", args)
55 }
56
57 pub(super) fn simplify_exp(&self, args: &[Expression]) -> Expression {
59 SIMPLIFICATION_REGISTRY.simplify_function("exp", args)
60 }
61
62 pub(super) fn simplify_gamma(&self, args: &[Expression]) -> Expression {
64 SIMPLIFICATION_REGISTRY.simplify_function("gamma", args)
65 }
66
67 pub fn factorial(arg: Expression) -> Expression {
69 Expression::function("factorial", vec![arg])
70 }
71
72 pub fn ln(arg: Expression) -> Expression {
74 Expression::function("ln", vec![arg])
75 }
76}