# legendre

## Purpose

Associated Legendre functions.

## Synopsis

````P = legendre(n,x)`
```

## Description

`P = legendre(n,x)` computes the associated Legendre functions of degree `n` and order `m = 0,1,...,n`, evaluated at `x`. `n` is an integer less than or equal to 256. `x` is a vector whose elements are real and have absolute value less than or equal to one. `P` is a matrix with `n+1` rows and `length(x)` columns. Each element of the returned matrix, `P(i,j)`, corresponds to the associated Legendre function of degree `n` and order `(i-1)` evaluated at `x(j)`. The first row of `P` is the Legendre polynomial evaluated at `x`.

## Examples

````legendre(2,0:0.1:0.2)`
`          `
`ans =`
`    -0.5000    -0.4850    -0.4400`
`          0    -0.2985    -0.5879`
`     3.0000     2.9700     2.8800`
```
Note that this answer is of the form

````   P(2,0;0)   P(2,0;0.1)   P(2,0;0.2)`
`   P(2,1;0)   P(2,1;0.1)   P(2,1;0.2)`
`   P(2,2;0)   P(2,2;0.1)   P(2,2;0.2)`
```

## Algorithm

The mathematical definition is

where

is the Legendre polynomial of degree n.

(c) Copyright 1994 by The MathWorks, Inc.