# Legendre Library

# Legendre Polynomials Library

This library includes:

- Gauss-Legendre Quadrature
- Numerically stable, accurate and efficient calculation of an order n Legendre Polynomial at values -1<=x<=1
- Numerically stable calculation of the derivative of an order n Legendre Polynomial at x.
- Calculation of the zeros of Legendre polynomials.
- Calculation of the Legendre polynomial coefficients.

## Gauss-Legendre Quadrature

Also called Gaussian Quadrature, is commonly used to compute definite integrals of a function F(x) with high accuracy using a small number of points where F(x) is evaluated. The method using n points is exact when F(x) is a polynomial of degree 2*n+1 or less, and is very accurate when F(x) can be accurately approximated by a polynomial of degree n (i.e., by its Taylor series with n terms).

### Function Gauss_Quadrature_Pts(K*, lb, ub*)

The function used to compute a Gauss-Legendre quadrature. To use, supply and index, `K:=1..n`

. The length of `K`

is used for *n*, the number of points used. The function has two return values, both indexed by `K`

:

- The points where you should evaluate your function.
- The weights

The bounds for the integration, «lb» and «ub» default to -1 to 1 if not specified. The following pattern illustrates how this function is used to integrate F(x) from a to b using n points:```
```

```
```

- Index K := 1..n;
`Local (xi,wi) := Gauss_Quadrature(K, a, b) Do Sum( wi * F(xi), K )`

Enable comment auto-refresher