From b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b Mon Sep 17 00:00:00 2001 From: priyanka Date: Wed, 24 Jun 2015 15:03:17 +0530 Subject: initial commit / add all books --- 845/CH7/EX7.12/Ex7_12.sce | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 845/CH7/EX7.12/Ex7_12.sce (limited to '845/CH7/EX7.12') diff --git a/845/CH7/EX7.12/Ex7_12.sce b/845/CH7/EX7.12/Ex7_12.sce new file mode 100755 index 000000000..bd73dac92 --- /dev/null +++ b/845/CH7/EX7.12/Ex7_12.sce @@ -0,0 +1,39 @@ +//Example 7.12 + +clc +clear + +function [f] = fun1(x,y) + f = 1 / (x+y); +endfunction + +x = 1:0.25:2; +y = x; + +m = length(x); +n = length(y); + +del = %nan*ones(m,n); +for j = 1:n + for i = 1:m + del(i,j) = fun1(x(i),y(j)); + end +end + +hx = x(2) - x(1); +for i = 1:m + I = del(i,1); + for j = 2:n-1 + I = I + 2*del(i,j); + end + Itrap1(i) = hx/2 * (I+del(i,n)); +end +Itrap1 = round(Itrap1*10^4)/10^4; + +hy = y(2) - y(1); +Itrap2 = Itrap1(1) +for i = 2:n-1 + Itrap2 = Itrap2 + 2* Itrap1(i); +end +Itrap2 = round(hy/2*(Itrap2+Itrap1(m))*10^4)/10^4; +disp(Itrap2,"I = ") -- cgit