summaryrefslogtreecommitdiff
path: root/75/CH5/EX5.7/ex_7.sce
diff options
context:
space:
mode:
Diffstat (limited to '75/CH5/EX5.7/ex_7.sce')
-rwxr-xr-x75/CH5/EX5.7/ex_7.sce29
1 files changed, 29 insertions, 0 deletions
diff --git a/75/CH5/EX5.7/ex_7.sce b/75/CH5/EX5.7/ex_7.sce
index a1608ff35..6eb53781d 100755
--- a/75/CH5/EX5.7/ex_7.sce
+++ b/75/CH5/EX5.7/ex_7.sce
@@ -1,3 +1,32 @@
+function [pL] = legendrepol(n,var)
+
+// Generates the Legendre polynomial
+// of order n in variable var
+
+if n == 0 then
+ cc = [1];
+elseif n == 1 then
+ cc = [0 1];
+else
+ if modulo(n,2) == 0 then
+ M = n/2
+ else
+ M = (n-1)/2
+ end;
+
+ cc = zeros(1,M+1);
+ for m = 0:M
+ k = n-2*m;
+ cc(k+1)=...
+ (-1)^m*gamma(2*n-2*m+1)/(2^n*gamma(m+1)*gamma(n-m+1)*gamma(n-2*m+1));
+ end;
+end;
+
+pL = poly(cc,var,'coeff');
+endfunction
+
+// End function legendrepol
+
// PG (277)
deff('[y]=f(x)','y=exp(x)*cos(x)')