pub fn evaluate_recurrence(
properties: &PolynomialProperties,
n: usize,
x: f64,
) -> f64Expand description
Evaluate polynomial using three-term recurrence relation
Generic implementation for all orthogonal polynomials that uses the recurrence relation defined in PolynomialProperties. This is mathematically the most stable approach for polynomial evaluation.
§Recurrence Form
For orthogonal polynomials, the three-term recurrence has the form:
P_{n+1}(x) = (alpha_n * x + beta_n) * P_n(x) + gamma_n * P_{n-1}(x)§Arguments
properties- Polynomial properties containing recurrence coefficientsn- Polynomial degree (must be non-negative)x- Evaluation point
§Returns
Numerical value of P_n(x) computed using recurrence relation
§Examples
use mathhook_core::functions::polynomials::evaluation::evaluate_recurrence;
use mathhook_core::functions::polynomials::legendre::LegendreIntelligence;
use mathhook_core::functions::properties::FunctionProperties;
let legendre = LegendreIntelligence::new();
let props = legendre.get_properties();
if let Some(FunctionProperties::Polynomial(legendre_props)) = props.get("legendre_p") {
let result = evaluate_recurrence(legendre_props, 5, 0.5);
assert!((result - 0.08984375).abs() < 1e-10);
}