mathhook_core/functions/
elementary.rs

1//! Elementary function intelligence
2//!
3//! Dedicated module for elementary mathematical functions (sin, cos, exp, ln, etc.)
4//! with complete mathematical properties, derivatives, and educational explanations.
5
6pub mod abs;
7pub mod abs_eval;
8pub mod exp_eval;
9pub mod exponential;
10pub mod hyperbolic;
11pub mod hyperbolic_eval;
12pub mod log_eval;
13pub mod logarithmic;
14pub mod rounding;
15pub mod sqrt;
16pub mod sqrt_eval;
17pub mod trigonometric;
18
19use crate::functions::properties::FunctionProperties;
20use std::collections::HashMap;
21
22/// Elementary Function Intelligence Registry
23///
24/// Manages mathematical intelligence for all elementary functions
25/// with proper modular separation by function family.
26pub struct ElementaryIntelligence {
27    /// Absolute value function (abs)
28    absolute_value: abs::AbsoluteValueIntelligence,
29
30    /// Square root function (sqrt)
31    square_root: sqrt::SqrtIntelligence,
32
33    /// Trigonometric functions (sin, cos, tan, etc.)
34    trigonometric: trigonometric::TrigonometricIntelligence,
35
36    /// Exponential functions (exp, etc.)
37    exponential: exponential::ExponentialIntelligence,
38
39    /// Logarithmic functions (ln, log, etc.)
40    logarithmic: logarithmic::LogarithmicIntelligence,
41
42    /// Hyperbolic functions (sinh, cosh, tanh, etc.)
43    hyperbolic: hyperbolic::HyperbolicIntelligence,
44}
45
46impl Default for ElementaryIntelligence {
47    fn default() -> Self {
48        Self::new()
49    }
50}
51
52impl ElementaryIntelligence {
53    /// Create new elementary function intelligence system
54    pub fn new() -> Self {
55        Self {
56            absolute_value: abs::AbsoluteValueIntelligence::new(),
57            square_root: sqrt::SqrtIntelligence::new(),
58            trigonometric: trigonometric::TrigonometricIntelligence::new(),
59            exponential: exponential::ExponentialIntelligence::new(),
60            logarithmic: logarithmic::LogarithmicIntelligence::new(),
61            hyperbolic: hyperbolic::HyperbolicIntelligence::new(),
62        }
63    }
64
65    /// Get all elementary function properties
66    ///
67    /// Returns a HashMap of all elementary functions and their properties
68    /// for integration with the universal registry.
69    pub fn get_all_properties(&self) -> HashMap<String, FunctionProperties> {
70        let mut properties = HashMap::with_capacity(32);
71
72        properties.extend(self.absolute_value.get_properties());
73        properties.extend(self.square_root.get_properties());
74        properties.extend(self.trigonometric.get_properties());
75        properties.extend(self.exponential.get_properties());
76        properties.extend(self.logarithmic.get_properties());
77        properties.extend(self.hyperbolic.get_properties());
78
79        properties
80    }
81
82    /// Check if function is elementary
83    pub fn is_elementary_function(&self, name: &str) -> bool {
84        self.absolute_value.has_function(name)
85            || self.square_root.has_function(name)
86            || self.trigonometric.has_function(name)
87            || self.exponential.has_function(name)
88            || self.logarithmic.has_function(name)
89            || self.hyperbolic.has_function(name)
90    }
91}