29 #ifndef OOMPH_ORTHPOLY_HEADER
30 #define OOMPH_ORTHPOLY_HEADER
34 #include <oomph-lib-config.h>
52 const double eps = 1.0e-15;
57 inline double legendre(
const unsigned& p,
const double& x)
60 if (p == 0)
return 1.0;
69 double L0 = 1.0, L1 = 1.0, L2 = x;
71 for (
unsigned n = 1; n < p; n++)
77 L2 = ((2 * n + 1) * x * L1 - n * L0) / (n + 1);
102 double L0 = 1.0, L1 = 1.0, L2 = x;
104 for (
unsigned n = 1; n < p; n++)
110 L2 = ((2 * n + 1) * x * L1 - n * L0) / (n + 1);
121 inline double dlegendre(
const unsigned& p,
const double& x)
123 double dL1 = 1.0, dL2 = 3 * x, dL3 = 0.0;
124 if (p == 0)
return 0.0;
131 for (
unsigned n = 2; n < p; n++)
133 dL3 = 1.0 / n * ((2.0 * n + 1.0) * x * dL2 - (n + 1.0) * dL1);
146 double ddL2 = 3.0, ddL3 = 15 * x, ddL4 = 0.0;
147 if (p == 0)
return 0.0;
156 for (
unsigned i = 3;
i < p;
i++)
159 1.0 / (
i - 1.0) * ((2.0 *
i + 1.0) * x * ddL3 - (
i + 2.0) * ddL2);
174 double P1 = 0.5 * (alpha - beta + (alpha + beta + 2.0) * x);
176 if (p == 0)
return P0;
181 for (
unsigned n = 1; n < p; n++)
184 2 * (n + 1) * (n + alpha + beta + 1) * (2 * n + alpha + beta);
186 (2 * n + alpha + beta + 1) * (alpha * alpha - beta * beta);
187 double a3n = (2 * n + alpha + beta) * (2 * n + alpha + beta + 1) *
188 (2 * n + alpha + beta + 2);
190 2 * (n + alpha) * (n + beta) * (2 * n + alpha + beta + 2);
191 P2 = ((a2n + a3n * x) * P1 - a4n * P0) / a1n;
214 polys[1] = 0.5 * (alpha - beta + (alpha + beta + 2.0) * x);
218 double P2 = 0.5 * (alpha - beta + (alpha + beta + 2.0) * x);
220 for (
unsigned n = 1; n < p; n++)
227 2 * (n + 1) * (n + alpha + beta + 1) * (2 * n + alpha + beta);
228 double a2n = (2 * n + alpha + beta + 1) * (alpha * alpha - beta * beta);
229 double a3n = (2 * n + alpha + beta) * (2 * n + alpha + beta + 1) *
230 (2 * n + alpha + beta + 2);
231 double a4n = 2 * (n + alpha) * (n + beta) * (2 * n + alpha + beta + 2);
233 P2 = ((a2n + a3n * x) * P1 - a4n * P0) / a1n;
double dlegendre(const unsigned &p, const double &x)
Calculates first derivative of Legendre polynomial of degree p at x using three term recursive formul...
double ddlegendre(const unsigned &p, const double &x)
Calculates second derivative of Legendre polynomial of degree p at x using three term recursive formu...
void gl_nodes(const unsigned &Nnode, Vector< double > &x)
double legendre(const unsigned &p, const double &x)
Calculates Legendre polynomial of degree p at x using the three term recurrence relation .
void legendre_vector(const unsigned &p, const double &x, Vector< double > &polys)
Calculates Legendre polynomial of degree p at x using three term recursive formula....
void gll_nodes(const unsigned &Nnode, Vector< double > &x)
Calculates the Gauss Lobatto Legendre abscissas for degree p = NNode-1.
double jacobi(const int &alpha, const int &beta, const unsigned &p, const double &x)
Calculate the Jacobi polnomials.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...