summaryrefslogtreecommitdiff
path: root/845/CH7/EX7.13/Ex7_13.sce
blob: bfc8ba495113fad3c3a649ca53a42d9aa366778e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//Example 7.13

clc
clear

function [f] = fun1(x,y)
    f = sqrt(sin(x+y));
endfunction

x = 0:%pi/8:%pi/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 = ")