mathhook_core/functions/elementary/
trigonometric.rs1mod 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
19pub struct TrigonometricIntelligence {
24 circular: CircularTrigIntelligence,
25 inverse: InverseTrigIntelligence,
26}
27
28impl TrigonometricIntelligence {
29 pub fn new() -> Self {
31 Self {
32 circular: CircularTrigIntelligence::new(),
33 inverse: InverseTrigIntelligence::new(),
34 }
35 }
36
37 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 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}