summaryrefslogtreecommitdiff
path: root/243/CH12/EX12.1/12_01.sce
diff options
context:
space:
mode:
Diffstat (limited to '243/CH12/EX12.1/12_01.sce')
-rwxr-xr-x243/CH12/EX12.1/12_01.sce29
1 files changed, 29 insertions, 0 deletions
diff --git a/243/CH12/EX12.1/12_01.sce b/243/CH12/EX12.1/12_01.sce
new file mode 100755
index 000000000..215443ee7
--- /dev/null
+++ b/243/CH12/EX12.1/12_01.sce
@@ -0,0 +1,29 @@
+//Example No. 12_01
+//Trapezoidal Rule
+//Pg No. 373
+clear ;close ;clc ;
+
+x = poly(0,"x");
+deff('F = f(x)','F = x^3 + 1');
+
+//case(a)
+a = 1;
+b = 2 ;
+h = b - a ;
+It = (b-a)*(f(a)+f(b))/2
+d2f = derivat(derivat( f(x) ))
+Ett = h^3*horner(d2f,2)/12
+Iexact = intg(1,2,f)
+Trueerror = It - Iexact
+disp(Trueerror,'True error = ',Iexact,'Iexact = ',Ett,'Ett = ',It,'It = ','case(a)')
+disp('Here Error bound is an overestimate of true error')
+
+//case(b)
+a = 1;
+b = 1.5 ;
+h = b - a ;
+It = (b-a)*(f(a)+f(b))/2
+Ett = h^3*horner(d2f,1.5)/12
+Iexact = intg(1,1.5,f)
+Trueerror = It - Iexact
+disp(Trueerror,'True error = ',Iexact,'Iexact = ',Ett,'Ett = ',It,'It = ','case(b)') \ No newline at end of file