From ced599db7e03612b31ed7764e5246a56369cd5a0 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 15 Nov 2012 12:11:20 -0500 Subject: [PATCH] Add the code for problem 5iii. Minor fixes to octave code. Update the makefile to execute octave scripts. --- legendre_p.m | 8 ++++---- legendre_p_tilde.m | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) 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) ); diff --git a/legendre_p_tilde.m b/legendre_p_tilde.m index 0b3a87b..2c9d2ab 100644 --- a/legendre_p_tilde.m +++ b/legendre_p_tilde.m @@ -1,7 +1,7 @@ function P_tilde = legendre_p_tilde(n, a, b) - ## Return the nth Legendre polynomial scaled to the interval [a,b]. + ## Return the `n`th Legendre polynomial scaled to the interval [a,b]. ## - ## INPUTS: + ## INPUT: ## ## * ``n`` - The index of the polynomial that we want. ## @@ -9,7 +9,7 @@ function P_tilde = legendre_p_tilde(n, a, b) ## ## * ``b`` - The right endpoint of the interval. ## - ## OUTPUTS: + ## OUTPUT: ## ## * ``P_tilde`` - A polynomial function of one argument. ## @@ -17,7 +17,8 @@ function P_tilde = legendre_p_tilde(n, a, b) ## Can't do anything here. Return nothing. P = NA; else - ## Compute the Legendre polynomial over [-1,1] and mangle it. + ## Compute the Legendre polynomial over [-1,1] and mangle it to fit + ## the interval [a,b]. P = legendre_p(n); P_tilde = @(x) P( (2/(b-a)).*x + 1 - (2*b)/(b-a) ); end -- 2.44.2