libMesh
Functions
libMesh::JacobiPolynomials Namespace Reference

Functions

Real value (unsigned n, unsigned alpha, unsigned beta, Real x)
 The Jacobi polynomial value and derivative formulas are based on the corresponding Wikipedia article [0]. More...
 
Real deriv (unsigned n, unsigned alpha, unsigned beta, Real x)
 

Function Documentation

◆ deriv()

Real libMesh::JacobiPolynomials::deriv ( unsigned  n,
unsigned  alpha,
unsigned  beta,
Real  x 
)
inline

Definition at line 74 of file jacobi_polynomials.h.

References value().

75 {
76  // Call value() with elevated (alpha, beta) and decremented n.
77  return n == 0 ? 0 : 0.5 * (1 + alpha + beta + n) * value(n-1, alpha+1, beta+1, x);
78 }
static const bool value
Definition: xdr_io.C:54

◆ value()

Real libMesh::JacobiPolynomials::value ( unsigned  n,
unsigned  alpha,
unsigned  beta,
Real  x 
)
inline

The Jacobi polynomial value and derivative formulas are based on the corresponding Wikipedia article [0].

Note that we have shifted the indices used in the recurrence relation, otherwise this is identical to the recurrence relation given in the article. When alpha = beta = 0, the Jacobi polynomials reduce to the Legendre polynomials.

Definition at line 44 of file jacobi_polynomials.h.

References libMesh::Real.

Referenced by deriv().

45 {
46  if (n == 0)
47  return 1.;
48 
49  // Compute constants independent of loop index.
50  unsigned int ab = alpha + beta;
51  unsigned int a2 = alpha * alpha;
52  unsigned int b2 = beta * beta;
53 
54  Real p0 = 1;
55  Real p1 = (alpha + 1) + (ab + 2) * 0.5 * (x - 1);
56 
57  unsigned int i = 1;
58  while (i < n)
59  {
60  // Note: we swap before updating p1, so p0 and p1 appear in
61  // opposite positions than is usual in the update formula.
62  std::swap(p0, p1);
63  p1 = (((2*i + ab + 1) *
64  ((2*i + ab + 2) * (2*i + ab) * x + a2 - b2)) * p0
65  - 2 * (i + alpha) * (i + beta) * (2*i + ab + 2) * p1) /
66  (2 * (i + 1) * (i + 1 + ab) * (2*i + ab));
67 
68  ++i;
69  }
70  return p1;
71 }
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real