]> gitweb.michael.orlitzky.com - octave.git/blob - legendre_p_tilde.m
Add construct() and its tests.
[octave.git] / legendre_p_tilde.m
1 function P_tilde = legendre_p_tilde(n, a, b)
2 ## Return the `n`th Legendre polynomial scaled to the interval [a,b].
3 ##
4 ## INPUT:
5 ##
6 ## * ``n`` - The index of the polynomial that we want.
7 ##
8 ## * ``a`` - The left endpoint of the interval.
9 ##
10 ## * ``b`` - The right endpoint of the interval.
11 ##
12 ## OUTPUT:
13 ##
14 ## * ``P_tilde`` - A polynomial function of one argument.
15 ##
16 if (n < 0)
17 ## Can't do anything here. Return nothing.
18 P = NA;
19 else
20 ## Compute the Legendre polynomial over [-1,1] and mangle it to fit
21 ## the interval [a,b].
22 P = legendre_p(n);
23 P_tilde = @(x) P( (2/(b-a)).*x + 1 - (2*b)/(b-a) );
24 end
25 end