X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=legendre_p_tilde.m;fp=legendre_p_tilde.m;h=e5e6f63b39b929731c3c8281f59b4510fbbf494c;hb=ee06b882dfb9a86788d7057cec8ca6d7680c5ca5;hp=0000000000000000000000000000000000000000;hpb=2fbcf94908d646ec62d2f15f7ec35288c6ac1cfe;p=octave.git diff --git a/legendre_p_tilde.m b/legendre_p_tilde.m new file mode 100644 index 0000000..e5e6f63 --- /dev/null +++ b/legendre_p_tilde.m @@ -0,0 +1,24 @@ +function P_tilde = legendre_p_tilde(n, a, b) + ## Return the nth Legendre polynomial scaled to the interval [a,b]. + ## + ## INPUTS: + ## + ## * ``n`` - The index of the polynomial that we want. + ## + ## * ``a`` - The left endpoint of the interval. + ## + ## * ``b`` - The right endpoint of the interval. + ## + ## OUTPUTS: + ## + ## * ``P_tilde`` - A polynomial function of one argument. + ## + if (n < 0) + ## Can't do anything here. Return nothing. + P = NA; + else + ## Compute the Legendre polynomial over [-1,1] and mangle it. + P = legendre_p(n) + P_tilde = @(x) P( (2/(b-a))*x + 1 - (2*b)/(b-a) ) + end +end