I. Find the region of integration
syms x
x0 = eval(solve(x^2/3 -2*x)); % stores limits of outer integrals
x0
x0 =
0 6
x = linspace(x0(1),x0(2),100);
y1 = x.^2/3;
y2 = 2*x;
plot(x,y1,x,y2,'LineWidth',2)
% to display grid and fill region with color, use
hold on
grid on
fill([x x(end:-1:1)],[y1 y2(end:-1:1)],'r')
hold off
%area under integration
a = trapz(x,y2)-trapz(x,y1)
a = 11.9988
syms x
x0 = eval(solve(-x - x*(2 - x)));
x = linspace(x0(1),x0(2),100);
y1 = -x;
y2 = x .* (2-x);
plot(x,y1,x,y2,'LineWidth',2)
%area under integration
a = trapz(x,y2)-trapz(x,y1)
a = 4.4995
syms x
x0 = eval(solve(sin(x) - cos(x)));
x = linspace(0,x0(1),100);
y1 = sin(x);
y2 = cos(x);
plot(x,y1,x,y2,'LineWidth',2)
%area under integration
a = trapz(x,y2)-trapz(x,y1)
a = 0.4142
syms x
x0 = eval(solve(x^2 - (x+2))); % stores limits of outer integrals
x = linspace(x0(1),x0(2),100);
y1 = x.^2;
y2 = x+2;
plot(x,y1,x,y2,'LineWidth',2)
%area under integration
a = trapz(x,y2)-trapz(x,y1)
a = 4.4995
syms x
x0 = eval(solve(-2*x - (1-x))); % stores limits of outer integrals
x = linspace(x0(1),0,100);
y1 = -2.*x;
y2 = 1-x;
plot(x,y1,x,y2,'LineWidth',2)
%area under integration
a1 = trapz(x,y2)-trapz(x,y1);
hold on
grid on
syms x
x0 = eval(solve(-x/2 - (1-x))); % stores limits of outer integrals
x = linspace(0,x0(1),100);
y1 = -x./2;
y2 = 1-x;
plot(x,y1,x,y2,'LineWidth',2)
hold off
%area under integration
a2 = trapz(x,y2)-trapz(x,y1);
a3 = a1+ a2
a3 = 1.5000
syms x
x0 = eval(solve(x^2 - 4 -x)); % stores limits of outer integrals
x = linspace(x0(1),x0(2),100);
y1 = x.^2 -4;
y2 = x;
plot(x,y1,x,y2,'LineWidth',2)
%area under integration
a1 = trapz(x,y2)-trapz(x,y1);
hold on
grid on
syms x
x0 = eval(solve(x-sqrt(x))); % stores limits of outer integrals
x = linspace(x0(1),x0(2),100);
y1 = x;
y2 = sqrt(x);
plot(x,y1,x,y2,'LineWidth',2)
%area under integration
a2 = trapz(x,y2)-trapz(x,y1);
a3 = a1+ a2
a3 = 11.8474
II. Evaluate the following integrals
f = @(x,y) y ./ (x.^2 + y.^2);
ans1 = integral2(f,0,1,@(x) x, 1)
ans1 = 0.7854
f = @(x,y) x ./ (x.^2 + y.^2);
ans2 = integral2(f,0,1,0,@(x) x/2)
ans2 = 0.4636
f = @(x,y) y ./ sqrt(x.^2 + y.^2);
ans3 = integral2(f,0,1,@(y) -y/3,@(y) y/3)
ans3 = -4.4994e-18
f = @(x,y) sqrt(x+y);
ans4 = integral2(f,0,1,@(y) y,@(y) 2-y)
ans4 = 1.1314
III. Evaluate the following integrals
f = @(x,y,z) x.^2+y.^2+z.^2;
a1=integral3(f,0,1,0,1,0,1)
a1 = 1.0000
f = @(x,y,z) 1./(x .* y .* z);
a2=integral3(f,1,exp(3),1,exp(2),1,exp(1))
a2 = 6.0000
f = @(x,y,z) y .* sin(z);
a3=integral3(f,-2,3,0,1,0,pi/6)
a3 = 0.3349
f = @(x,y,z) x + y + z;
a4=integral3(f,0,1,0,2,-1,1)
a4 = 6.0000
f = @(x,y,z) x ;
a5=integral3(f,0,1,0,@(x) 1 - x.^2,3,@(x,y) 4-x.^2-y)
a5 = 0.0833