jacobi.c File Reference

Calculation of Jacobi Polynomials. More...

#include <stdlib.h>
#include <gsl/gsl_math.h>
#include <gsl/gsl_errno.h>
#include "jacobi.h"

Functions

int jac_jacobi_P0_e (double x, double a, double b, gsl_sf_result *result)
 Calculates the Jacobi polynomial of order 0.
int jac_jacobi_P1_e (double x, double a, double b, gsl_sf_result *result)
 Calculates the Jacobi polynomial of order 1.
int jac_jacobi_e (double x, int n, double a, double b, gsl_sf_result *result)
 Calculates the Jacobi polynomial of order n.
double jac_jacobi_P0 (double x, double a, double b)
 Calculates the Jacobi polynomial of order 0.
double jac_jacobi_P1 (double x, double a, double b)
 Calculates the Jacobi polynomial of order 1.
double jac_jacobi (double x, int n, double a, double b)
 Calculates the Jacobi polynomial of order n.
int jac_djacobi_P0_e (double x, double a, double b, gsl_sf_result *result)
 Calculates the derivative of the Jacobi polynomial of order 0.
int jac_djacobi_P1_e (double x, double a, double b, gsl_sf_result *result)
 Calculates the derivative of the Jacobi polynomial of order 1.
int jac_djacobi_e (double x, int n, double a, double b, gsl_sf_result *result)
 Calculates the derivative of the Jacobi polynomial of order n.
double jac_djacobi_P0 (double x, double a, double b)
 Calculates the derivative of the Jacobi polynomial of order 0.
double jac_djacobi_P1 (double x, double a, double b)
 Calculates the derivative of the Jacobi polynomial of order 1.
double jac_djacobi (double x, int n, double a, double b)
 Calculates the derivative of the Jacobi polynomial of order n.
int jac_jacobi_array (int np, const double *x, int n, double *result_array, double a, double b, double *ws)
 Calculates Jacobi polynomials at an array of points.
int jac_djacobi_array (int np, const double *x, int n, double *result_array, double a, double b, double *ws)
 Calculates the derivative of Jacobi polynomials at an array of points.
int jac_jacobi_zeros (double *x, int m, double alpha, double beta)
 Calculates the zeros of Jacobi polynomials in the interval -1 up to 1.

Detailed Description

Calculation of Jacobi Polynomials.

This file implements the function that calculates Jacobi polynomials and its derivatives. It tries to follow the interfaces used in the GNU Scientific library. The estimated errors Have not been implemented yet.

The main sources used to develop this library where:

(1) Abramowitz, Milton and Stegun, Irene (editors); "Handbook of Mathematical functions", Dover Publications 1965.

(2) Karniadakis, George Em and Sherwin, Spencer; "Spectral/hp Element Methods for Computational Fluid Dynamics", Oxford Science Publications, 2nd edition, 2005.

The Jacobi polynomials of order n are defined as follows

\[ P_n^{\alpha,\beta}(x) \]

The calculation uses the recursive definition of the Jacobi polynomial:

\[ a^1_n P_{n+1}^{\alpha,\beta}(x) = (a^2_n + a^3_n x)P_n^{\alpha,\beta}(x) - a^4_n P_{n-1}^{\alpha,\beta}(x) \]

In this function, $-1\le x \le 1$ is the point where the function is to be calculated, n is the order of the polynomial and $a^i_n$ are coefficients given by

\[ a^1_n = 2(n+1)(n+\alpha+\beta+1)(2n+\alpha+\beta) \]

\[ a^2_n = (2n+\alpha+\beta+1)(\alpha^2-\beta^2) \]

\[ a^3_n = (2n + \alpha + \beta)(2n + \alpha + \beta + 1)(2n + \alpha +\beta + 2) \]

\[ a^4_n = 2(n+\alpha)(n+\beta)(2n+\alpha+\beta+2) \]

There is also a recursive definition of the derivative of Jacobi polynomials but in this library, the derivatives of Jacobi polynomials will be defined in terms of Jacobi polynomials:

\[ \frac{d}{dx}P^{\alpha,\beta}_n(x) = \frac{1}{2}(\alpha + \beta + n + 1) P_n^{\alpha+1,\beta+1}(x) \]

Chebychev polynomials are a special case of Jacobi polynomials with $\alpha,\beta=-1/2$:

\[ T_n(x) = \frac{2^{2n}(n!)^2}{(2n)!} P_n^{-1/2,-1/2}(x) \]

Since the Zeros of Chebychev are explicitly known, an iteration using these zeros as initial guess is used to calculate zeros of generic Jacobi polynomials.


Function Documentation

double jac_djacobi ( double  x,
int  n,
double  a,
double  b 
)

Calculates the derivative of the Jacobi polynomial of order n.

Explicit calculation of the derivative of the nth order Jacobi polynomial

Parameters:
x The point where the function should be calculated. $-1\le x \le 1$
n The order of the polynomial
a $\alpha$ parameter of the Jacobi Polynomial
b $\beta$ parameter of the Jacobi Polynomial
Returns:
The calculated value of the Jacobi polynomial

References jac_jacobi().

Referenced by jac_jacobi_zeros(), jac_lagrange_gj(), jac_lagrange_glj(), jac_lagrange_grjm(), and jac_lagrange_grjp().

int jac_djacobi_array ( int  np,
const double *  x,
int  n,
double *  result_array,
double  a,
double  b,
double *  ws 
)

Calculates the derivative of Jacobi polynomials at an array of points.

Calculates the derivative of the nth order Jacobi polynomial at an array of np points given by the vector x. This function needs two workspaces of size np to do its calculation. If the first one (ws1) is NULL, the function will allocate the necessary memory (using malloc) to do the calculation

Parameters:
np Number of points where the polynomial will be calculated
x A vector of length np containing the points where the polynomials should be calculated. $-1\le x_i \le 1$.
n Order of the Jacobi polynomial whose derivative should be calculated
result_array An array of length np where the result will be stored
a $\alpha$ parameter of Jacobi polynomial
b $\beta$ parameter of Jacobi polynomial
ws A pointer to a block of memory 2*np doubles long to be used as workspace. If it is NULL, memory will be allocated using malloc and released at the end
Returns:
Error code defined in gsl_errno.h or GSL_SUCCESS if everything was fine

References jac_jacobi_array().

Referenced by jac_diffmat_gj(), jac_diffmat_glj(), jac_diffmat_grjm(), jac_diffmat_grjp(), and jac_weights_gj().

int jac_djacobi_e ( double  x,
int  n,
double  a,
double  b,
gsl_sf_result *  result 
)

Calculates the derivative of the Jacobi polynomial of order n.

Calculates the derivative of the nth order Jacobi polynomial

Parameters:
x The point where the function should be calculated. $-1\le x \le 1$
n Integer specifying the order of the polynomial
a $\alpha$ parameter of the Jacobi Polynomial
b $\beta$ parameter of the Jacobi Polynomial
result A pointer to a gsl_sf_result structure where the result and estimated error is stored
Returns:
GSL_SUCCESS if successful

References jac_jacobi_e().

double jac_djacobi_P0 ( double  x,
double  a,
double  b 
)

Calculates the derivative of the Jacobi polynomial of order 0.

Explicit calculation of the derivative of the 0th order Jacobi polynomial

Parameters:
x The point where the function should be calculated. $-1\le x \le 1$
a $\alpha$ parameter of the Jacobi Polynomial
b $\beta$ parameter of the Jacobi Polynomial
Returns:
The calculated value of the Jacobi polynomial
int jac_djacobi_P0_e ( double  x,
double  a,
double  b,
gsl_sf_result *  result 
)

Calculates the derivative of the Jacobi polynomial of order 0.

Calculates the derivative of the 0th order Jacobi polynomial

Parameters:
x The point where the function should be calculated. $-1\le x \le 1$
a $\alpha$ parameter of the Jacobi Polynomial
b $\beta$ parameter of the Jacobi Polynomial
result A pointer to a gsl_sf_result structure where the result and estimated error is stored
Returns:
GSL_SUCCESS if successful
double jac_djacobi_P1 ( double  x,
double  a,
double  b 
)

Calculates the derivative of the Jacobi polynomial of order 1.

Explicit calculation of the derivative of the 1st order Jacobi polynomial

Parameters:
x The point where the function should be calculated. $-1\le x \le 1$
a $\alpha$ parameter of the Jacobi Polynomial
b $\beta$ parameter of the Jacobi Polynomial
Returns:
The calculated value of the Jacobi polynomial
int jac_djacobi_P1_e ( double  x,
double  a,
double  b,
gsl_sf_result *  result 
)

Calculates the derivative of the Jacobi polynomial of order 1.

Calculates the derivative of the 1st order Jacobi polynomial

Parameters:
x The point where the function should be calculated. $-1\le x \le 1$
a $\alpha$ parameter of the Jacobi Polynomial
b $\beta$ parameter of the Jacobi Polynomial
result A pointer to a gsl_sf_result structure where the result and estimated error is stored
Returns:
GSL_SUCCESS if successful
double jac_jacobi ( double  x,
int  n,
double  a,
double  b 
)

Calculates the Jacobi polynomial of order n.

Explicit calculation of the nth order Jacobi polynomial

Parameters:
x The point where the function should be calculated. $-1\le x \le 1$
n An integer specifying the order of the polynomial
a $\alpha$ parameter of the Jacobi Polynomial
b $\beta$ parameter of the Jacobi Polynomial
Returns:
The calculated value of the Jacobi polynomial

Referenced by jac_djacobi(), jac_jacobi_zeros(), jac_lagrange_gj(), jac_lagrange_glj(), jac_lagrange_grjm(), and jac_lagrange_grjp().

int jac_jacobi_array ( int  np,
const double *  x,
int  n,
double *  result_array,
double  a,
double  b,
double *  ws 
)

Calculates Jacobi polynomials at an array of points.

Calculates the nth order Jacobi polynomials at an array of np points given by the vector x. This function needs two workspaces of size np to do its calculation. If the first one (ws1) is NULL, the function will allocate the necessary memory (using malloc) to do the calculation

Parameters:
np Number of points where the polynomial will be calculated
x A vector of length np containing the points where the polynomials should be calculated. $-1\le x_i \le 1$.
n Order of Jacobi polynomial to be calculated
result_array An array of length np where the result will be stored
a $\alpha$ parameter of Jacobi polynomial
b $\beta$ parameter of Jacobi polynomial
ws A pointer to a block of memory at least 2*np doubles long to be used as workspace. If it is NULL, memory will be allocated using malloc and released at the end
Returns:
Error code defined in gsl_errno.h or GSL_SUCCESS if everything was fine

Referenced by jac_djacobi_array(), jac_weights_glj(), jac_weights_grjm(), and jac_weights_grjp().

int jac_jacobi_e ( double  x,
int  n,
double  a,
double  b,
gsl_sf_result *  result 
)

Calculates the Jacobi polynomial of order n.

Calculates the nth order Jacobi polynomial

Parameters:
x The point where the function should be calculated. $-1\le x \le 1$
n An integer specifying the order of the polynomial
a $\alpha$ parameter of the Jacobi Polynomial
b $\beta$ parameter of the Jacobi Polynomial
result A pointer to a gsl_sf_result structure where the result and estimated error is stored
Returns:
GSL_SUCCESS if successful

Referenced by jac_djacobi_e().

double jac_jacobi_P0 ( double  x,
double  a,
double  b 
)

Calculates the Jacobi polynomial of order 0.

Explicit calculation of the 0th order Jacobi polynomial

Parameters:
x The point where the function should be calculated. $-1\le x \le 1$
a $\alpha$ parameter of the Jacobi Polynomial
b $\beta$ parameter of the Jacobi Polynomial
Returns:
The calculated value of the Jacobi polynomial
int jac_jacobi_P0_e ( double  x,
double  a,
double  b,
gsl_sf_result *  result 
)

Calculates the Jacobi polynomial of order 0.

Calculates the 0th order Jacobi polynomial

Parameters:
x The point where the function should be calculated. $-1\le x \le 1$
a $\alpha$ parameter of the Jacobi Polynomial
b $\beta$ parameter of the Jacobi Polynomial
result A pointer to a gsl_sf_result structure where the result and estimated error is stored
Returns:
GSL_SUCCESS if successful
double jac_jacobi_P1 ( double  x,
double  a,
double  b 
)

Calculates the Jacobi polynomial of order 1.

Explicit calculation of the 1st order Jacobi polynomial

Parameters:
x The point where the function should be calculated. $-1\le x \le 1$
a $\alpha$ parameter of the Jacobi Polynomial
b $\beta$ parameter of the Jacobi Polynomial
Returns:
The calculated value of the Jacobi polynomial
int jac_jacobi_P1_e ( double  x,
double  a,
double  b,
gsl_sf_result *  result 
)

Calculates the Jacobi polynomial of order 1.

Calculates the 1st order Jacobi polynomial

Parameters:
x The point where the function should be calculated. $-1\le x \le 1$
a $\alpha$ parameter of the Jacobi Polynomial
b $\beta$ parameter of the Jacobi Polynomial
result A pointer to a gsl_sf_result structure where the result and estimated error is stored
Returns:
GSL_SUCCESS if successful
int jac_jacobi_zeros ( double *  x,
int  m,
double  alpha,
double  beta 
)

Calculates the zeros of Jacobi polynomials in the interval -1 up to 1.

This function uses an iteration technique to calculate the zeros of a Jacobi polynomial:

\[ P_m^{\alpha,\beta}(x_i) = 0 \]

The algorithm was adapted from the book by Karniadakis and Sherwin. It uses as an initial guess the zeros of Chebyshev polynomials.

Parameters:
x Pointer to an array where the zeros of the Jacobi polynomial should be stored
m Order of the polynomial
alpha $\alpha$ parameter of the Jacobi polynomial
beta $\beta$ parameter of the Jacobi polynomial

References EPS, jac_djacobi(), and jac_jacobi().

Referenced by jac_zeros_gj(), jac_zeros_glj(), jac_zeros_grjm(), and jac_zeros_grjp().

Generated on Mon Oct 8 18:26:44 2012 for nanomagnFMM by  doxygen 1.6.3