mathhook_core/functions/elementary/
trigonometric.rs

1//! Trigonometric Function Intelligence
2//!
3//! Complete mathematical intelligence for all trigonometric functions.
4//! This module combines circular and inverse trigonometric functions.
5
6mod trig_circular;
7mod trig_evaluation;
8mod trig_inverse;
9mod trig_inverse_eval;
10
11pub use trig_circular::CircularTrigIntelligence;
12pub use trig_evaluation::{cos, cos_evaluator, sin, sin_evaluator, tan, tan_evaluator};
13pub use trig_inverse::InverseTrigIntelligence;
14pub use trig_inverse_eval::{arccos, arcsin, arctan};
15
16use crate::functions::properties::FunctionProperties;
17use std::collections::HashMap;
18
19/// Trigonometric Function Intelligence (Combined)
20///
21/// Provides unified access to all trigonometric functions:
22/// circular (sin, cos, tan, cot, sec, csc) and inverse (arcsin, arccos, arctan)
23pub struct TrigonometricIntelligence {
24    circular: CircularTrigIntelligence,
25    inverse: InverseTrigIntelligence,
26}
27
28impl TrigonometricIntelligence {
29    /// Create new trigonometric intelligence system
30    pub fn new() -> Self {
31        Self {
32            circular: CircularTrigIntelligence::new(),
33            inverse: InverseTrigIntelligence::new(),
34        }
35    }
36
37    /// Get all trigonometric function properties
38    pub fn get_properties(&self) -> HashMap<String, FunctionProperties> {
39        let mut props = HashMap::with_capacity(9);
40        props.extend(self.circular.get_properties());
41        props.extend(self.inverse.get_properties());
42        props
43    }
44
45    /// Check if function is trigonometric
46    pub fn has_function(&self, name: &str) -> bool {
47        self.circular.has_function(name) || self.inverse.has_function(name)
48    }
49}
50
51impl Default for TrigonometricIntelligence {
52    fn default() -> Self {
53        Self::new()
54    }
55}
56
57#[cfg(test)]
58mod tests {
59    use super::*;
60
61    #[test]
62    fn test_trigonometric_intelligence() {
63        let trig = TrigonometricIntelligence::new();
64
65        assert!(trig.has_function("sin"));
66        assert!(trig.has_function("cos"));
67        assert!(trig.has_function("tan"));
68        assert!(trig.has_function("arcsin"));
69        assert!(trig.has_function("arccos"));
70        assert!(trig.has_function("arctan"));
71        assert!(!trig.has_function("exp"));
72
73        let properties = trig.get_properties();
74        assert!(properties.contains_key("sin"));
75        assert!(properties.contains_key("cos"));
76        assert!(properties.contains_key("arcsin"));
77        assert!(properties.len() >= 9);
78
79        if let Some(FunctionProperties::Elementary(sin_props)) = properties.get("sin") {
80            assert!(sin_props.derivative_rule.is_some());
81            assert!(!sin_props.special_values.is_empty());
82            assert!(sin_props.periodicity.is_some());
83        }
84    }
85}