summaryrefslogtreecommitdiff
path: root/75/CH5/EX5.7/ex_7.sce
diff options
context:
space:
mode:
authorprashantsinalkar2017-10-10 12:38:01 +0530
committerprashantsinalkar2017-10-10 12:38:01 +0530
commitf35ea80659b6a49d1bb2ce1d7d002583f3f40947 (patch)
treeeb72842d800ac1233e9d890e020eac5fd41b0b1b /75/CH5/EX5.7/ex_7.sce
parent7f60ea012dd2524dae921a2a35adbf7ef21f2bb6 (diff)
downloadScilab-TBC-Uploads-f35ea80659b6a49d1bb2ce1d7d002583f3f40947.tar.gz
Scilab-TBC-Uploads-f35ea80659b6a49d1bb2ce1d7d002583f3f40947.tar.bz2
Scilab-TBC-Uploads-f35ea80659b6a49d1bb2ce1d7d002583f3f40947.zip
updated the code
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)')