use crate::core::{Expression, Symbol};
use crate::functions::properties::*;
use std::collections::HashMap;
use std::sync::Arc;
pub struct HermiteIntelligence {
properties: HashMap<String, FunctionProperties>,
}
impl Default for HermiteIntelligence {
fn default() -> Self {
Self::new()
}
}
impl HermiteIntelligence {
pub fn new() -> Self {
let mut intelligence = Self {
properties: HashMap::with_capacity(4),
};
intelligence.initialize_hermite_polynomials();
intelligence
}
pub fn get_properties(&self) -> HashMap<String, FunctionProperties> {
self.properties.clone()
}
pub fn has_function(&self, name: &str) -> bool {
self.properties.contains_key(name)
}
fn initialize_hermite_polynomials(&mut self) {
self.properties.insert(
"hermite".to_owned(),
FunctionProperties::Polynomial(Box::new(PolynomialProperties {
family: PolynomialFamily::Hermite,
recurrence: ThreeTermRecurrence {
alpha_coeff: Expression::mul(vec![Expression::integer(2), Expression::symbol("x")]),
beta_coeff: Expression::integer(0),
gamma_coeff: Expression::mul(vec![Expression::integer(-2), Expression::symbol("n")]),
initial_conditions: (
Expression::integer(1),
Expression::mul(vec![Expression::integer(2), Expression::symbol("x")])
),
},
orthogonality: Some(OrthogonalityData {
weight_function: Expression::function("gaussian_weight", vec![Expression::symbol("x")]),
interval: (
Expression::mul(vec![Expression::integer(-1), Expression::symbol("∞")]),
Expression::symbol("∞")
),
norm_squared: Expression::function("hermite_norm_squared", vec![Expression::symbol("n")]),
}),
rodrigues_formula: Some(RodriguesFormula {
formula: "H_n(x) = (-1)^n e^{x²} d^n/dx^n e^{-x²}".to_owned(),
normalization: Expression::pow(Expression::integer(-1), Expression::symbol("n")),
weight_function: Expression::function("gaussian_weight", vec![Expression::symbol("x")]),
}),
generating_function: Some(GeneratingFunction {
function: Expression::function("hermite_generating", vec![Expression::symbol("x"), Expression::symbol("t")]),
gf_type: GeneratingFunctionType::Exponential,
}),
special_values: vec![
SpecialValue {
input: "0".to_owned(),
output: Expression::function("hermite_zero_value", vec![Expression::symbol("n")]),
latex_explanation: "H_n(0) = \\begin{cases} (-1)^{n/2} \\frac{n!}{(n/2)!} 2^{-n/2} & \\text{if } n \\text{ even} \\\\ 0 & \\text{if } n \\text{ odd} \\end{cases}".to_owned(),
},
],
evaluation_method: EvaluationMethod::Recurrence,
symbolic_expander: Some(super::super::properties::special::SymbolicExpander::Custom(
super::symbolic::expand_hermite_symbolic
)),
antiderivative_rule: AntiderivativeRule {
rule_type: AntiderivativeRuleType::Custom {
builder: Arc::new(|var: Symbol| {
Expression::integral(
Expression::function("hermite", vec![Expression::symbol(var.clone())]),
var
)
}),
},
result_template: "∫H_n(x) dx (symbolic - orthogonal polynomial integration requires specialized techniques)".to_owned(),
constant_handling: ConstantOfIntegration::AddConstant,
},
wolfram_name: None,
})),
);
}
}