X-Git-Url: http://gitweb.michael.orlitzky.com/?p=octave.git;a=blobdiff_plain;f=legendre_p.m;h=36f67617a453124d1b3992aa7d6f45298333dc98;hp=0481d47be73d3af8c660b9a195b3fd4a375d16e2;hb=b12c6c2a4bf4cef29b2e08b743c92889505c7ed9;hpb=e1b71b4ca7cfa08ac76744a17a3778d4ccfaa7e2 diff --git a/legendre_p.m b/legendre_p.m index 0481d47..36f6761 100644 --- a/legendre_p.m +++ b/legendre_p.m @@ -1,25 +1,25 @@ function P = legendre_p(n) - ## Return the `n`th Legendre polynomial. - ## - ## INPUT: - ## - ## * ``n`` - The index of the polynomial that we want. - ## - ## OUTPUT: - ## - ## * ``P`` - A polynomial function of one argument. - ## + % Return the `n`th Legendre polynomial. + % + % INPUT: + % + % * ``n`` - The index of the polynomial that we want. + % + % OUTPUT: + % + % * ``P`` - A polynomial function of one argument. + % if (n < 0) - ## Can't do anything here. Return nothing. + % Can't do anything here. Return nothing. P = NA; elseif (n == 0) - ## One of our base cases. + % One of our base cases. P = @(x) 1; elseif (n == 1) - ## The second base case. + % The second base case. P = @(x) x; else - ## Not one of the base cases, so use the recursive formula. + % Not one of the base cases, so use the recursive formula. prev = legendre_p(n-1); prev_prev = legendre_p(n-2); P = @(x) (1/n).*( (2*n - 1).*x.*prev(x) - (n-1).*prev_prev(x) );