summaryrefslogtreecommitdiff
path: root/75/CH5/EX5.8/ex_8.sce
diff options
context:
space:
mode:
Diffstat (limited to '75/CH5/EX5.8/ex_8.sce')
-rwxr-xr-x75/CH5/EX5.8/ex_8.sce33
1 files changed, 31 insertions, 2 deletions
diff --git a/75/CH5/EX5.8/ex_8.sce b/75/CH5/EX5.8/ex_8.sce
index d0d40fc93..c5baa6329 100755
--- a/75/CH5/EX5.8/ex_8.sce
+++ b/75/CH5/EX5.8/ex_8.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 (278)
deff('[y]=f(x)','y=exp(-x^2)')
@@ -22,7 +51,7 @@ for j = 1:2
A = [A 2/((1-xr(j)^2)*(horner(pd,xr(j)))^2)]
end
-tr = ((x1-x0)/2.*xr)+((x1+x0)/2);
+tr = ((x1-x0)./2.*xr)+((x1+x0)./2);
-s = ((x1-x0)/2)*f(tr)
+s = ((x1-x0)./2).*f(tr)
I = s*A \ No newline at end of file