6#ifndef THEORETICA_POLYN_ORTHOGONAL_H
7#define THEORETICA_POLYN_ORTHOGONAL_H
42 for (
unsigned int l = 2; l <= n; ++l) {
79 return sqrt((2 * n + 1) / 2.0);
84 inline std::function<
real(
real)> assoc_legendre_polynomial(
unsigned int l,
int m) {
95 for (
int i = 0; i < m; ++i)
102 return pow(1 - x * x, m / 2) * L(x) / K;
108 return sqrt(
pow(1 - x * x, m)) * L(x) / K;
115 inline polynomial<real> assoc_legendre_polynomial_even(
unsigned int l,
int m) {
130 for (
int i = 0; i < m; ++i)
176 {1}, {1 + alpha, -1},
258 std::vector<real>
roots;
261 for (
unsigned int i = 1; i <= n; ++i) {
276 const unsigned int n =
roots.size();
279 std::vector<real> weights;
282 for (
unsigned int i = 0; i < n; ++i) {
297 const unsigned int n =
roots.size();
300 std::vector<real> weights;
303 for (
unsigned int i = 0; i < n; ++i) {
318 const unsigned int n =
roots.size();
321 std::vector<real> weights;
324 for (
unsigned int i = 0; i < n; ++i) {
A polynomial of arbitrary order with coefficients of a specified type.
Definition polynomial.h:28
#define TH_MATH_ERROR(F_NAME, VALUE, EXCEPTION)
TH_MATH_ERROR is a macro which throws exceptions or modifies errno (depending on which compilation op...
Definition error.h:219
Main namespace of the library which contains all functions and objects.
Definition algebra.h:27
std::vector< real > hermite_weights(const std::vector< real > &roots)
Hermite weights for Gauss-Hermite quadrature of n-th order.
Definition orthogonal.h:315
polynomial< real > chebyshev1_polynomial(unsigned int n)
Compute the nth Chebyshev polynomial of the first kind.
Definition orthogonal.h:225
polynomial< real > laguerre_polyn_recurr(polynomial< real > L0, polynomial< real > L1, unsigned int i)
Recursion formula for Laguerre polynomials.
Definition orthogonal.h:140
dual2 sqrt(dual2 x)
Compute the square root of a second order dual number.
Definition dual2_functions.h:54
polynomial< real > hermite_polyn_recurr(polynomial< real > H0, polynomial< real > H1, unsigned int i)
Recursion formula for Hermite polynomials.
Definition orthogonal.h:186
polynomial< real > chebyshev2_polynomial(unsigned int n)
Compute the nth Chebyshev polynomial of the second kind.
Definition orthogonal.h:236
double real
A real number, defined as a floating point type.
Definition constants.h:207
constexpr real SQRTPI
The square root of Pi.
Definition constants.h:243
std::vector< real > legendre_weights(const std::vector< real > &roots)
Legendre weights for Gauss-Legendre quadrature of n-th order.
Definition orthogonal.h:273
std::function< polynomial< real >(polynomial< real >, polynomial< real >, unsigned int)> polyn_recurr_formula
Polynomial sequence recurrence formula type Used for computing orthogonal polynomial basis elements.
Definition orthogonal.h:19
std::vector< real > laguerre_weights(const std::vector< real > &roots)
Laguerre weights for Gauss-Laguerre quadrature of n-th order.
Definition orthogonal.h:294
polynomial< real > gen_polyn_recurr(polynomial< real > P0, polynomial< real > P1, polyn_recurr_formula f, unsigned int n)
Generate a polynomial basis using a recursion formula.
Definition orthogonal.h:28
real hermite_polyn_normalization(unsigned int n)
Normalization constant for the nth Hermite polynomial.
Definition orthogonal.h:205
Vector roots(RealFunction f, real a, real b, real tol=OPTIMIZATION_TOL, real steps=10)
Find the roots of a univariate real function inside a given interval, by first searching for candidat...
Definition roots.h:649
TH_CONSTEXPR IntType fact(unsigned int n)
Compute the factorial of n.
Definition real_analysis.h:681
TH_CONSTEXPR T ipow(T x, unsigned int n, T neutral_element=T(1.0))
Compute the n-th positive power of x (where n is natural).
Definition real_analysis.h:654
@ ImpossibleOperation
Mathematically impossible operation.
Definition error.h:30
polynomial< real > general_laguerre_polyn_recurr(polynomial< real > L0, polynomial< real > L1, real alpha, unsigned int i)
Recursion formula for Generalized Laguerre polynomials.
Definition orthogonal.h:161
polynomial< real > general_laguerre_polynomial(real alpha, unsigned int n)
Compute the nth Laguerre polynomial.
Definition orthogonal.h:169
polynomial< real > chebyshev_polyn_recurr(polynomial< real > T0, polynomial< real > T1, unsigned int i)
Recursion formula for Chebyshev polynomials The formula is the same for first and second kind polynom...
Definition orthogonal.h:216
real legendre_polyn_normalization(unsigned int n)
Normalization constant for the nth Legendre polynomial.
Definition orthogonal.h:76
polynomial< real > legendre_polynomial(unsigned int n)
Compute the nth Legendre polynomial.
Definition orthogonal.h:66
polynomial< Field > deriv(const polynomial< Field > &p)
Compute the exact derivative of a polynomial function.
Definition deriv.h:21
dual2 square(dual2 x)
Return the square of a second order dual number.
Definition dual2_functions.h:23
iter_result< real > root_newton(RealFunction f, RealFunction Df, real guess=0.0, real tol=OPTIMIZATION_TOL, unsigned int max_iter=OPTIMIZATION_NEWTON_ITER)
Find a root of a univariate real function using Newton's method.
Definition roots.h:223
std::vector< real > legendre_roots(unsigned int n)
Roots of the n-th Legendre polynomial.
Definition orthogonal.h:248
polynomial< real > legendre_polyn_recurr(polynomial< real > P0, polynomial< real > P1, unsigned int l)
Recursion formula for Legendre polynomials.
Definition orthogonal.h:57
polynomial< real > laguerre_polynomial(unsigned int n)
Compute the nth Laguerre polynomial.
Definition orthogonal.h:148
dual2 pow(dual2 x, int n)
Compute the n-th power of a second order dual number.
Definition dual2_functions.h:41
polynomial< real > hermite_polynomial(unsigned int n)
Compute the nth Hermite polynomial.
Definition orthogonal.h:195
Polynomial storage and manipulation.
Root approximation of real functions.