X-Git-Url: http://gitweb.michael.orlitzky.com/?p=octave.git;a=blobdiff_plain;f=legendre_p.m;h=0481d47be73d3af8c660b9a195b3fd4a375d16e2;hp=276e7407d39f2d410dd38439f389891b11993b8d;hb=48d11337432c25a75eb1d0c72dac604e3cd0b788;hpb=79707c807c6f44eb95ec0eeeaa28f7e98bf8c319 diff --git a/legendre_p.m b/legendre_p.m index 276e740..0481d47 100644 --- a/legendre_p.m +++ b/legendre_p.m @@ -1,11 +1,11 @@ function P = legendre_p(n) - ## Return the nth legendre polynomial. + ## Return the `n`th Legendre polynomial. ## - ## INPUTS: + ## INPUT: ## ## * ``n`` - The index of the polynomial that we want. ## - ## OUTPUTS: + ## OUTPUT: ## ## * ``P`` - A polynomial function of one argument. ## @@ -19,7 +19,7 @@ function P = legendre_p(n) ## The second base case. P = @(x) x; else - ## Compute recursively. + ## 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) );