diff options
Diffstat (limited to '845/CH7/EX7.12/Ex7_12.sce')
-rwxr-xr-x | 845/CH7/EX7.12/Ex7_12.sce | 39 |
1 files changed, 39 insertions, 0 deletions
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 = ")
|