summaryrefslogtreecommitdiff
path: root/191/CH6/EX6.5/Example6_5.sce
diff options
context:
space:
mode:
Diffstat (limited to '191/CH6/EX6.5/Example6_5.sce')
-rwxr-xr-x191/CH6/EX6.5/Example6_5.sce66
1 files changed, 33 insertions, 33 deletions
diff --git a/191/CH6/EX6.5/Example6_5.sce b/191/CH6/EX6.5/Example6_5.sce
index 70049cb6b..5939f4518 100755
--- a/191/CH6/EX6.5/Example6_5.sce
+++ b/191/CH6/EX6.5/Example6_5.sce
@@ -1,34 +1,34 @@
-//Trapezoidal Rule
-clc;
-clear;
-close();
-format('v',10);
-funcprot(0);
-disp('Integral 0 to 2 e^x dx');
-disp('based on trapezoidal rule ');
-
-deff('[y]=f(x)','y=exp(x)');
-
-n = [1 2 4 8];
-
-a = 0;
-b = 2;
-h = (ones(:,4)*(b-a))./n;
-
-t(1) = h(1)*(f(a)+f(b))/2;
-disp(t(1),'n=1');
-
-t(2) = h(2)*(f(a)+f(b)+2*f(h(2)))/2;
-disp(t(2),'n=2');
-
-t(3) = h(3)*(f(a)+f(b)+2*(f(h(3))+f(2*h(3))+f(3*h(3))))/2;
-disp(t(3),'n=4');
-
-t(4) = h(4)*(f(a)+f(b)+2*(f(h(4))+f(2*h(4))+f(3*h(4))+f(4*h(4))+f(5*h(4))+f(6*h(4))+f(7*h(4))))/2;
-disp(t(4),'n=8');
-
-exact = integrate('exp(x)','x',0,2);
-disp(exact,'The exact value of intergation is :');
-exact = ones(4)*exact;
-err = exact-t;
+//Trapezoidal Rule
+clc;
+clear;
+close();
+format('v',10);
+funcprot(0);
+disp('Integral 0 to 2 e^x dx');
+disp('based on trapezoidal rule ');
+
+deff('[y]=f(x)','y=exp(x)');
+
+n = [1 2 4 8];
+
+a = 0;
+b = 2;
+h = (ones(1,4)*(b-a))./n;
+
+t(1) = h(1)*(f(a)+f(b))/2;
+disp(t(1),'n=1');
+
+t(2) = h(2)*(f(a)+f(b)+2*f(h(2)))/2;
+disp(t(2),'n=2');
+
+t(3) = h(3)*(f(a)+f(b)+2*(f(h(3))+f(2*h(3))+f(3*h(3))))/2;
+disp(t(3),'n=4');
+
+t(4) = h(4)*(f(a)+f(b)+2*(f(h(4))+f(2*h(4))+f(3*h(4))+f(4*h(4))+f(5*h(4))+f(6*h(4))+f(7*h(4))))/2;
+disp(t(4),'n=8');
+
+exact = integrate('exp(x)','x',0,2);
+disp(exact,'The exact value of intergation is :');
+exact = ones(4)*exact;
+err = exact-t;
disp(err,'thus corresponding errors are : '); \ No newline at end of file