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.sce25
1 files changed, 25 insertions, 0 deletions
diff --git a/75/CH5/EX5.7/ex_7.sce b/75/CH5/EX5.7/ex_7.sce
new file mode 100755
index 000000000..a1608ff35
--- /dev/null
+++ b/75/CH5/EX5.7/ex_7.sce
@@ -0,0 +1,25 @@
+ // PG (277)
+
+deff('[y]=f(x)','y=exp(x)*cos(x)')
+x0=0;
+x1=%pi;
+
+
+// True value
+I = integrate('exp(x)*cos(x)','x',x0,x1)
+
+// Using Gaussian Quadrature
+
+// For n=2, w=1
+
+n=2;
+p = legendrepol(n,'x')
+xr = roots(p);
+A = [];
+
+for j = 1:2
+ pd = derivat(p)
+ A = [A 2/((1-xr(j)^2)*(horner(pd,xr(j)))^2)]
+end
+
+tr = ((x1-x0)/2.*xr)+((x1+x0)/2) \ No newline at end of file