]> gitweb.michael.orlitzky.com - octave.git/commitdiff
Add the code for problem 5iii.
authorMichael Orlitzky <michael@orlitzky.com>
Thu, 15 Nov 2012 17:11:20 +0000 (12:11 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Thu, 15 Nov 2012 17:11:20 +0000 (12:11 -0500)
Minor fixes to octave code.
Update the makefile to execute octave scripts.

legendre_p.m
legendre_p_tilde.m

index 276e7407d39f2d410dd38439f389891b11993b8d..0481d47be73d3af8c660b9a195b3fd4a375d16e2 100644 (file)
@@ -1,11 +1,11 @@
 function P = legendre_p(n)
 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.
   ##
   ##
   ##   * ``n`` - The index of the polynomial that we want.
   ##
-  ## OUTPUTS:
+  ## OUTPUT:
   ##
   ##   * ``P`` - A polynomial function of one argument.
   ##
   ##
   ##   * ``P`` - A polynomial function of one argument.
   ##
@@ -19,7 +19,7 @@ function P = legendre_p(n)
     ## The second base case.
     P = @(x) x;
   else
     ## 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) );
     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) );
index 0b3a87ba698dc41c560cc0b38c52b4549a8348e8..2c9d2ab08916107fe11ca42ba863f32e4341117f 100644 (file)
@@ -1,7 +1,7 @@
 function P_tilde = legendre_p_tilde(n, a, b)
 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.
   ##
   ##
   ##   * ``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.
   ##
   ##
   ##   * ``b`` - The right endpoint of the interval.
   ##
-  ## OUTPUTS:
+  ## OUTPUT:
   ##
   ##   * ``P_tilde`` - A polynomial function of one argument.
   ##
   ##
   ##   * ``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
     ## 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
     P = legendre_p(n);
     P_tilde = @(x) P( (2/(b-a)).*x + 1 - (2*b)/(b-a) );
   end