Math Lab Project
Math Lab Project
CALCULUS 2 REPORT
MATHLAB PROJECT
LECTURERS: Lê Thái Thanh-Lê Xuân Đại
CLASS: CC11
Group members:
1. Đinh Quang Hiển – 2252221
2. Lê Hữu Trí – 2252841
3. Huỳnh Ngọc Hân – 2252198
4. Nguyễn Ngọc Như Quỳnh – 2252704
5. Lê Hoàng Phi – 2252609
1
I/ THEORY
2
3
4
5
6
Surface integrals
7
DOUBLE INTERGRAL
If f(x) is defined for 𝑎 ≤ x ≤ b, we start by dividing the interval [a,b] into n sub intervals
[xi-1, xi ] of equal width ∆x = (𝑏 − 𝑎)/𝑛 and we choose sample points xi* in these sub
intervals. Then we form the Riemann sum
8
and take the limit of such sums as n → ∞ to obtain the definite integral of f from a to b
In the special case where f(x) ≥ 0, the Riemann sum can be interpreted as the sum of the
𝑏
areas of the approximating rectangles in Figure 1, ∫𝑎 𝑓(𝑥) represents the area under the
curve y = f(x) from a to b
and suppose that f(x,y) ≥ 0. The graph of f is a surface with equation z = f(x,y) .
Let S be the solid that lies above R and under the graph of f, that is,
Dividing the rectangle R into sub rectangles. We accomplish this by dividing the interval
[a,b] into m sub intervals [xi-1, xi] of equal width ∆x = (𝑏 − 𝑎)/m and dividing [c,d] into
[yi-1, yi ] sub intervals of equal width ∆y = (d − 𝑐)/n. By drawing lines parallel to the
coordinate axes through the endpoints of these sub intervals, as in Figure below, we form
the sub rectangles
9
If we follow this procedure for all the rectangles and add the volumes of the
corresponding
boxes, we get an approximation to the total volume of S
Using a double Riemann sum to approximate the double integral, where the sample point
(xij*, yij*) in Rij is chosen to be the center of Rij . In other words, is the midpoint of [xi-
1, xi ] and is the midpoint of [yi-1, yi ].
Average Value
Defining the average value of a function f of two variables defined on a rectangle R to be,
says that the box with base R and height fave has the same volume as the solid that lies
under the graph of f .
Intergrated Intergrals
Suppose that f is a function of two variables that is integrable on the rectangle R = [a,b] x
𝑑
[c,d]. We use the notation ∫𝑐 𝑓(𝑥, 𝑦)𝑑𝑦 to mean that x is held fixed and 𝑓(𝑥, 𝑦) is
integrated with respect to y from y = c to y = d. This procedure is called partial
intergration with respect to y.
The integral on the right side of Equation 1 is called an intergrated intergrals . Usually the
brackets are omitted.
10
The fubini’s theorem: If f is continuous on the rectangle
A plane region is said to be of Type I if it lies between the graphs of two continuous
functions of x, that is,
11
Double integrals in polar coordinates
Equipped with the double integral, we can consider a lamina with variable density.
Suppose the lamina occupies a region D of the xy -plane and its density (in units of mass
per unit area) at a point ( x,y) in
D is given by p(x,y) , where p is a continuous function on D . This means that
Where ∆m and ∆A are the mass and area of a small rectangle that contains and the limit
is taken as the dimensions of the rectangle approach 0.
Other types of density that can be treated in the same manner, if an electric charge is
distributed over a region D and the charge density (in units of charge per unit area) is
given by σ = (x, y) at a point (x, y) in D , then the total charge Q is given by:
12
Moment and center of mass
The coordinates of the center of mass of a lamina occupying the region D and having
density function p(x,y) are
Moment of inertia
The moment inertia of a particle of mass m about an axis is defined to be mr2 , where is
the distance r from the particle to the axis. We extend this concept to a lamina with
density function ρ = ( x, y) and occupying a region by proceeding as we did for ordinary
moments.
TRIPLE INTERGRAL
𝜎𝑛 = ∑ 𝑓(𝑥𝑘 , 𝑦𝑘 , 𝑧𝑘 )∆𝑉𝑘
𝑘=1
If there exists the limit:
𝐼 = lim 𝜎𝑛
𝑛→∞
such that λ → 0 when n → ∞, then the value I is called the triple integral of f on V and is
denoted by:
13
In particular, if the projection of onto the -plane is a type I plane region, then:
𝑎≤𝑥≤𝑏
𝐸 = {(𝑥, 𝑦, 𝑧)| 𝑔1 (𝑥) ≤ 𝑦 ≤ 𝑔2 (𝑥) }
ℎ1 (𝑥, 𝑦) ≤ 𝑧 ≤ ℎ2 (𝑥, 𝑦)
14
𝑐≤𝑦≤𝑑
𝐸 = {(𝑥, 𝑦, 𝑧)| 𝑢1 (𝑥, 𝑦) ≤ 𝑧 ≤ 𝑢2 (𝑥, 𝑦)}
ℎ1 (𝑦) ≤ 𝑥 ≤ ℎ2 (𝑦)
• Applications in Mechanic
All the applications of double integrals in mechanics can be immediately extended to
triple integrals. For example, if the density function of a solid object that occupies the
region V is ρ(x, y, z), in units of mass per unit volume, at any given point (x, y, z), then
its mass is
15
While:
16
• Triple Integrals in Spherical Coordinates
ρ ⩾ 0, 0 ⩽ θ ⩽ 2π, 0 ⩽ ϕ ⩽ π
𝝆𝟐 = 𝒙𝟐 + 𝒚𝟐 + 𝒛𝟐
17
With:
18
II/ SOLUTION AND CODE
1/ Find the extreme values of the function f(x, y) = x^2 + 2y^2 on the circle x^2 +y^2
= 1. Sketch the given surface and show the extreme values
● HOW TO SOLVE:
We will use Lagrange multipliers to find the extreme values of the function f(x, y)
subject to the constraint x^2 + y^2 = 1.
Now, we need to find the critical points of L(x, y, λ), which means finding the values of x,
y, and λ that satisfy the following system of equations:
∂L/∂x = 2x - 2λx = 0
∂L/∂y = 4y - 2λy = 0
From the first two equations, we can see that either x = 0 or y = 0 or λ = 1. If λ = 1, then
we have x^2 + y^2 - 1 = 0, which satisfies the third equation as well.
Now, we need to check the values of f(x, y) at these critical points to find the maximum
and minimum values. We have:
19
f(-1, 0) = 1
f(1, 0) = 1
f(0, -1) = 2
f(0, 1) = 2
So, the minimum value of f(x, y) is 1 and the maximum value is 2. These extreme values
are achieved at the points (-1, 0) and (0, ±1) for the minimum value, and (0, ±1) for the
maximum value.
Matlab code:
x = linspace(-1, 1, 100);
y = linspace(-1, 1, 100);
Z = X.^2 + 2*Y.^2;
surf(X, Y, Z);
This will create a 3D plot of the surface of the function, where the height of the surface
represents the value of the function at each point.
Graph
20
To find the extreme values of the function on the circle x^2 + y^2 = 1, we can use
MATLAB's fmincon function. Here's the code:
21
[x_min, f_min] = fmincon(fun, [0; 1], [], [], [], [], [], [], nonlcon, options);
[x_max, f_max] = fmincon(@(x) -fun(x), [0; 1], [], [], [], [], [], [], nonlcon, options);
2/ Find the extreme values of the function f(x, y) = x^2 y on the curve x 2+2y^2 = 6.
● HOW TO SOLVE:
To find the extreme values of the function f(x, y) = x^2 y on the curve x^2 + 2y^2 = 6,
we can use the method of Lagrange multipliers. This method involves finding the critical
points of the function subject to the constraint.
First, we define the Lagrangian function L(x, y, λ) = x^2 y + λ(x^2 + 2y^2 - 6). Then, we
find the partial derivatives of L with respect to x, y, and λ:
Setting each partial derivative equal to zero and solving the resulting system of
equations gives us the critical points:
22
2xy + 2λx = 0
x^2 + 4λy = 0
x^2 + 2y^2 = 6
From the first equation, we get y = -λ. Substituting into the second equation, we get x^2
- 4λ^2 = 0. Solving for λ, we get λ = ±x/2. Substituting this into the equation y = -λ, we
get y = ±x/2.
Substituting these values of x and y into the equation x^2 + 2y^2 = 6, we get x^2 +
x^2/2 = 6, which simplifies to 3x^2 = 12, or x = ±2. Substituting these values of x into
the equation y = ±x/2, we get y = ±1.
Therefore, the critical points are (2, 1), (2, -1), (-2, 1), and (-2, -1). To determine which
of these points give the maximum and minimum values of the function f(x, y), we
evaluate the function at each point:
f(2, 1) = 4
f(2, -1) = -4
f(-2, 1) = -4
f(-2, -1) = 4
Thus, the maximum value of f(x, y) is 4, and the minimum value is -4.
Matlab code
f = @(x,y) x.^2 .* y;
23
% Create a grid of x and y values
x = linspace(-3, 3, 100);
y = linspace(-3, 3, 100);
Z = f(X, Y);
figure;
surf(X, Y, Z);
xlabel('x');
ylabel('y');
zlabel('f(x,y)');
[xmin, fmin] = fmincon(f, x0, [], [], [], [], [], [], c, options);
[xmax, fmax] = fmincon(@(x) -f(x(1), x(2)), x0, [], [], [], [], [], [], c, options);
24
Graph
● HOW TO SOLVE:
f(x,y)=6 − 5𝑥 − 4𝑦
g(x,y)=𝑥 2 + 𝑦 2 = 9
f= g
𝑥2 + 𝑦2 = 9
25
-5 = 2𝑥
⇔ −4 = 2y
𝑥2 + 𝑦2 = 9
12 12
𝑦 = √41 𝑜𝑟 𝑦 = − √41
15 15
⇔ 𝑥 = √41or 𝑥 = − √41
12 15
f(√41,√41) = 6 − 3√41
12 15 246−27√41
We have f (√41,-√41) = 41
12 15 246+27√41
f(-√41,√41) = 41
12 15
f(-√41,-√41) = 6 + 3√41
clc;
close all;
format compact
syms x y l d t result;
f = @(x,y) 6-5*x-4*y;
fx = diff(f, x);
fy = diff(f, y);
e1 = h(x,y) == 9;
e2 = fx == l*diff(h,x);
e3 = fy == l*diff(h,y);
26
for i=1:numel(a)
result(i) = f(a(i),b(i));
end
sor = sort(result);
figure
subplot(1,2,1);
fsurf(f);
hold on;
fsurf(cos(t),sin(t),d,[0 2*pi]);
● RESULT
● GRAPH
27
f(x,y)=1 − 4𝑥 − 8𝑦
g(x,y)=𝑥 2 + 8𝑦 2 = 8
𝑔(𝑥, 𝑦) =< 𝑓𝑥(𝑥, 𝑦), 𝑓𝑦(𝑥, 𝑦) > = < 2𝑥, 16𝑦 >
-4 = 2𝑥
⇔ −8 = 16y
𝑥 2 + 8𝑦 2 = 8
1 1
𝑦 = √3 𝑜𝑟 𝑦 = − √3
4 4
⇔ 𝑥 = √3or 𝑥 = − √3
1 4
f(√3,√3) = 1 − 8√3
1 4 3−8√3
We have f (√3,-√3) = 3
1 4 3+8√3
f(- , ) =
√3 √3 3
1 4
f(-√3,-√3) = 1 + 8√3
● MATLAB CODE:
clc;
close all;
format compact
syms x y l d t result;
f = @(x,y) 1-4*x-8*y;
h = @(x,y) x^2 +8*y^2;
28
fx = diff(f, x);
fy = diff(f, y);
e1 = h(x,y) == 8;
e2 = fx == l*diff(h,x);
e3 = fy == l*diff(h,y);
[a,b,c] = solve ([e1, e2, e3], [x,y,l]);
for i=1:numel(a)
result(i) = f(a(i),b(i));
end
sor = sort(result);
fprintf('+ Global maximum values is %f\n',sor(numel(sor)));
fprintf('+ Global minimum values is %f\n',sor(1));
figure
subplot(1,2,1);
fsurf(f);
hold on;
fsurf(cos(t),sin(t),d,[0 2*pi]);
● RESULT
● GRAPH
29
f(x,y)= 𝑥 2 + 𝑦 2 + 𝑥𝑦
g(x,y)=𝑥 2 + 2𝑦 2 = 1
2𝑥 + 𝑦 = 2𝑥
⇔ 2𝑦 + 𝑥 = 4y
𝑥 2 + 2𝑦 2 = 1
1 1
𝑦 = √3 𝑜𝑟 𝑦 = − √3
1 1
⇔ 𝑥 = √3or 𝑥 = − √3
1 1
f(√3,√3) = 1
1 1 1
We have f (√3,-√3) = 3
1 1 1
f(- , )=3
√3 √3
1 1
f(- ,- ) = 1
√3 √3
● MATLAB CODE:
clc;
close all;
format compact
syms x y l d t result;
f = @(x,y) x^2+y^2+x*y;
h = @(x,y) x^2 +2*y^2;
fx = diff(f, x);
30
fy = diff(f, y);
e1 = h(x,y) == 1;
e2 = fx == l*diff(h,x);
e3 = fy == l*diff(h,y);
[a,b,c] = solve ([e1, e2, e3], [x,y,l]);
for i=1:numel(a)
result(i) = f(a(i),b(i));
end
sor = sort(result);
fprintf('+ Global maximum values is %f\n',sor(numel(sor)));
fprintf('+ Global minimum values is %f\n',sor(1));
figure
subplot(1,2,1);
fsurf(f);
hold on;
fsurf(cos(t),sin(t),d,[0 2*pi]);
● GRAPH
6/ Finnd the extreme values of the function f(x, y) = 2𝒙𝟐 + 12xy +𝒚𝟐 on the
curve 𝒙𝟐 + 4𝒚𝟐 = 25. Sketch the given surface and show the extreme values
● HOW TO SOLVE
f(x,y)=<fx(x,y),fy(x,y)> = <-4x+12y,12x+2y>
31
g(x,y) = <gx(x,y),gy(x,y)> = <2x,16y>
f(3.61,1.73)≈106.25
f(-3.61,1.73)≈-50
Thus, the function f(x,y) = 2𝑥 2 + 12xy +𝑦 2 has a maximum value of 106.25 and a
minimum value of -50 on the curve 𝑥 2 + 4𝑦 2 = 25.
● RESULT
● GRAPH
32
7/ Find the extreme values of the function f(x, y) = x2+y2 on the plane x/2+
y/3=1. Sketch the given surface and show the extreme values
● HOW TO SOLVE
f(x,y)=<fx(x,y),fy(x,y)> = <2x,2y>
Thus, the function f(x,y) = x^2+y^2 has a maximum value of 2.76 and a minimum
value of 2.76 on the plane x/2+y/3=1.
● MATLAB CODE;
clc;
close all;
format compact
syms x y l d t result;
f = @(x,y) x^2+y^2;
h = @(x,y) x/2 + y/3;
fx = diff(f, x);
fy = diff(f, y);
e1 = h(x,y) == 1;
e2 = fx == l*diff(h,x);
e3 = fy == l*diff(h,y);
[a,b,c] = solve ([e1, e2, e3], [x,y,l]);
for i=1:numel(a)
result(i) = f(a(i),b(i));
end
sor = sort(result);
fprintf('+ Global maximum values is %f\n',sor(numel(sor)));
fprintf('+ Global minimum values is %f\n',sor(1));
figure
subplot(1,2,1);
fsurf(f);
hold on;
fsurf(cos(t),sin(t),d,[0 2*pi]);
● RESULT
33
● GRAPH
8.Find the local maximum and minimum values and saddle points of f(x, y) =𝒙𝟒 + 𝒚𝟒 −
2𝒙𝟐 + 4xy − 2𝒚𝟐 . Sketch the given surface and show the extreme values.
● HOW TO SOLVE
𝑓𝑥 = 4𝑥 3 − 4𝑥 + 4𝑦 = 0 (1)
𝑓𝑦 = 4𝑦 3 + 4𝑥 − 4𝑦 = 0 (2)
From (1) and (2) => Critical point (0; 0),(√2, −√2),(−√2,√2)
⇨ 𝑓(0; 0) = 04 + 04 − 2 ∗ 02 + 4𝑥𝑦 − 2𝑦 2 = 0
𝑓𝑥𝑥 = 12𝑥 2 − 4
𝑓𝑥𝑥 (0; 0) = −4 < 0
𝑓𝑦𝑦 = 12𝑦 2 − 4
𝑓𝑥𝑦 = 4
𝐷(0; 0) = -4 × −4 − 42 = 0
if(x,y)=(√2, −√2)or(−√2,√2) =>𝑓𝑥𝑥 =20,𝑓𝑦𝑦 = 20, 𝑓𝑥𝑦 = 4
𝑓𝑥𝑥 *𝑓𝑥𝑦 − 𝑓𝑥𝑦 2 = 384 > 0
● CODE
clc;
34
close all;
syms x y;
f = @(x,y)(x^4 + y^4 - 2*x^2 + 4*x*y - 2*y^2);
fx = diff(f,x);
fy = diff(f,y);
[xc,yc] = solve(fx,fy,x,y,'real',true);
[m,n] = size([xc,yc]);
fxx = diff(fx,x);
fyy = diff(fy,y);
fxy = diff(fx,y);
D = fxx*fyy - fxy^2;
%print
for i = 1:m
if subs(D,{x,y},{xc(i),yc(i)}) > 0
if subs(fxx,{x,y},{xc(i),yc(i)}) > 0
fprintf('(%f,%f,%f) is local minimum\n',xc(i),yc(i),f(xc(i),yc(i)));
else
fprintf('(%f,%f,%f) is local maximum\n',xc(i),yc(i),f(xc(i),yc(i)));
end
elseif subs(D,{x,y},{xc(1),yc(1)}) < 0
fprintf('(%f,%f,%f) is saddle point\n',xc(i),yc(i),f(xc(i),yc(i)));
else
fprintf('(%f,%f,%f) is unknown\n',xc(i),yc(i),f(xc(i),yc(i)));
end
%Sketch
xx = linspace(0, 1, 30);
yy = linspace(-1.5, -0.5, 30);
[X,Y] = meshgrid(xx, yy);
fplot = (X+Y.^2+Y.*2).*exp(X.*2);
figure
surf(X, Y, fplot)
hold on
for i = 1:m
plot3(xc(i),yc(i),f(xc(i),yc(i)),'r*')
end
● RESULT
● GRAPH
35
9. Find the local maximum and minimum values and saddle points of f(x, y) =𝟐𝒙𝟒 + 𝒚𝟒
− 𝒙𝟐 − 2𝒚𝟐 . Sketch the given surface and show the extreme values
● HOW TO SOLVE
𝑓𝑥 = 8𝑥 3 − 2𝑥 = (1)
𝑓𝑦 = 4𝑦 3 − 4𝑦 = 0 (2)
From (1) and (2) => The critical points are: (0, 0), (-1, 0), (1, 0), (0, -1), and (0, 1).
To classify these points, we need to use the second partial derivative test. The Hessian
matrix of f(x, y) is:
One eigenvalue is positive and one is negative, so the point corresponds to a saddle
point.
36
One eigenvalue is positive and one is negative, so the point corresponds to a saddle
point.
One eigenvalue is positive and one is negative, so the point corresponds to a saddle
point.
One eigenvalue is positive and one is negative, so the point corresponds to a saddle
point.
● MATLAB CODE
clc;
close all;
syms x y;
f = @(x,y)(2*x^4 + y^4 - x^2 - 2*y^2);
fx = diff(f,x);
fy = diff(f,y);
[xc,yc] = solve(fx,fy,x,y,'real',true);
[m,n] = size([xc,yc]);
fxx = diff(fx,x);
fyy = diff(fy,y);
fxy = diff(fx,y);
D = fxx*fyy - fxy^2;
%print
for i = 1:m
if subs(D,{x,y},{xc(i),yc(i)}) > 0
if subs(fxx,{x,y},{xc(i),yc(i)}) > 0
fprintf('(%f,%f,%f) is local minimum\n',xc(i),yc(i),f(xc(i),yc(i)));
else
fprintf('(%f,%f,%f) is local maximum\n',xc(i),yc(i),f(xc(i),yc(i)));
end
elseif subs(D,{x,y},{xc(1),yc(1)}) < 0
fprintf('(%f,%f,%f) is saddle point\n',xc(i),yc(i),f(xc(i),yc(i)));
else
fprintf('(%f,%f,%f) is unknown\n',xc(i),yc(i),f(xc(i),yc(i)));
end
end
%Sketch
xx = linspace(0, 1, 30);
yy = linspace(-1.5, -0.5, 30);
[X,Y] = meshgrid(xx, yy);
fplot = (X+Y^2+Y*2).*exp(X*2);
37
figure
surf(X, Y, fplot)
hold on
for i = 1:m
plot3(xc(i),yc(i),f(xc(i),yc(i)),'r*')
end
● RESULT
● GRAPH
10.Find the local maximum and minimum values and saddle points of f(x, y) =
(x^2 − 2y^2)e^(x−y). Sketch the given surface and show the extreme values.
● HOW TO SOLVE
𝑓𝑥 = (2𝑥 − 2𝑦 − 𝑥^2 + 2𝑦^2)𝑒^𝑥 − 𝑦) = 0 (1)
𝑓𝑦 = (−4𝑦 + 𝑥^2 + 4𝑦^2)𝑒^(𝑥 − 𝑦) = 0 (2)
38
From (1) and (2) => Critical point (0; 0)
⇨ 𝑓(0; 0) = 0
𝑓𝑥𝑥 =(2 -2x-2y+x^2-2y^2)e^(x-y)
𝑓𝑥𝑥 (0,0) = 2 (3)
𝑓𝑥𝑥 =(-4 + 4y - x^2 + 4y^2)e^(x-y)
𝑓𝑦𝑦 (0,0)=-4(4)
● MATLAB CODE
clc
close all
syms x y
f = @(x,y)((x^2 - 2*y^2 )*exp(x-y));
fx = diff(f,x);
fy = diff(f,y);
[xc,yc] = solve(fx,fy,x,y,'real',true);
[m,n] = size([xc,yc]);
fxx = diff(fx,x);
fyy = diff(fy,y);
fxy = diff(fx,y);
D = fxx*fyy - fxy^2;
%print
for i = 1:m
if subs(D,{x,y},{xc(i),yc(i)}) > 0
if subs(fxx,{x,y},{xc(i),yc(i)}) > 0
fprintf('(%f,%f,%f) is local minimum\n',xc(i),yc(i),f(xc(i),yc(i)));
else
fprintf('(%f,%f,%f) is local maximum\n',xc(i),yc(i),f(xc(i),yc(i)));
end
elseif subs(D,{x,y},{xc(1),yc(1)}) < 0
fprintf('(%f,%f,%f) is saddle point\n',xc(i),yc(i),f(xc(i),yc(i)));
else
fprintf('(%f,%f,%f) is unknown\n',xc(i),yc(i),f(xc(i),yc(i)));
end
end
%Sketch
39
xx = linspace(0, 1, 30);
yy = linspace(-1.5, -0.5, 30);
[X,Y] = meshgrid(xx, yy);
fplot = (X+Y.^2+Y.*2).*exp(X.*2);
figure
surf(X, Y, fplot)
hold on
for i = 1:m
plot3(xc(i),yc(i),f(xc(i),yc(i)),'r*')
end
● RESULT
● GRAPH
11. Find the local maximum and minimum values and saddle points of f(x, y) = (x + y2
+ 2y)e2x. Sketch the given surface and show the extreme values.
● HOW TO SOLVE
Fy=e2x(2y+2)
Fy=0-> 2y+2=0->y=-1
40
Substituting y=-1 for (1) we have x+1-2=- -> x=
A:fxx=2e2x +2[e2x+2(x+y2+2y)e2x]
B:fxy= 2e2x(2y+2)
C:fyy=2e2x
Substituing point M for A B C we have A=2e;B=0;C=2e->AC-B2=4e2>0
● MATLAB CODE
% Init
clc;
close all;
syms x y z;
fx = diff(f,x);
fy = diff(f,y);
41
for i=1:numel(a)
if delta(a(i),b(i)) < 0
else
end
end
figure(1);
fsurf(f);
hold on;
for i=1:numel(a)
scatter3(a(i),b(i),f(a(i),b(i)),'MarkerEdgeColor','k','MarkerFaceColor','r');
if delta(a(i),b(i)) < 0
else
42
end
end
figure(2);
Z = f(X,Y);
contour(X, Y, Z);
hold on;
for i=1:numel(a)
scatter(a(i),b(i),'MarkerEdgeColor','k','MarkerFaceColor','r');
if delta(a(i),b(i)) < 0
else
end
end
● GRAPH
43
12. Find the local maximum and minimum values and saddle points of f(x, y) = (x + y2 )
. Sketch the given surface and show the extreme values
● HOW TO SOLVE
Fx= + (x+y2 )
Fy= 2y
Fy=0-> 2y=0->y=0
Substituing y=0 for (1) we have x+0=-2->x=-2
We have point M(-2;0)
A:fxx= + [ + (x+y2) ]
B:fxy= y
C:fyy=2
% Init
clc;
close all;
syms x y z;
44
f = @(x,y) ((x + y.^2 ) * exp(x/2))
fx = diff(f,x);
fy = diff(f,y);
for i=1:numel(a)
if delta(a(i),b(i)) < 0
else
end
end
45
figure(1);
fsurf(f);
hold on;
for i=1:numel(a)
scatter3(a(i),b(i),f(a(i),b(i)),'MarkerEdgeColor','k','MarkerFaceColor','r');
if delta(a(i),b(i)) < 0
else
end
end
figure(2);
Z = f(X,Y);
contour(X, Y, Z);
hold on;
for i=1:numel(a)
scatter(a(i),b(i),'MarkerEdgeColor','k','MarkerFaceColor','r');
46
if delta(a(i),b(i)) < 0
else
end
end
● GRAPH
13. Find the local maximum and minimum values and saddle points of f(x, y) = (x2 + y2
)( − 1). Sketch the given surface and show the extreme values.
● HOW TO SOLVE
47
Substituing point M(0;0) for A B C we have A=0;B=0;C=0->AC-B2=0
if x2 + >0 then – 1<0 which make f(x,y)<0 -> M(0,0) is the local maximum.
● MATLAB CODE
% Init
clc;
close all;
syms x y z;
fx = diff(f,x);
fy = diff(f,y);
for i=1:numel(a)
if delta(a(i),b(i)) < 0
48
fprintf('\nSaddle point: (%s,%s,%s)%f',a(i),b(i),f(a(i),b(i)));
else
end
end
figure(1);
fsurf(f);
hold on;
for i=1:numel(a)
scatter3(a(i),b(i),f(a(i),b(i)),'MarkerEdgeColor','k','MarkerFaceColor','r');
if delta(a(i),b(i)) < 0
else
end
end
49
% Plot the contour lines
figure(2);
Z = f(X,Y);
contour(X, Y, Z);
hold on;
for i=1:numel(a)
scatter(a(i),b(i),'MarkerEdgeColor','k','MarkerFaceColor','r');
if delta(a(i),b(i)) < 0
else
end
end
● GRAPH
14. Find the local maximum and minimum values and saddle points of f(x, y) = 3x2 − x 3
+ 2y 2 + 4y. Sketch the given surface and show the extreme values.
50
● HOW TO SOLVE
Fx= 6x-3x2
Fy=4y+4
A:fxx=6-6x
B:fxy=0
C:fyy=4
● MATLAB CODE
% Init
clc;
close all;
syms x y z;
fx = diff(f,x);
fy = diff(f,y);
51
fxx(x,y) = diff(fx, x);
for i=1:numel(a)
if delta(a(i),b(i)) < 0
else
end
end
figure(1);
fsurf(f);
hold on;
52
for i=1:numel(a)
scatter3(a(i),b(i),f(a(i),b(i)),'MarkerEdgeColor','k','MarkerFaceColor','r');
if delta(a(i),b(i)) < 0
else
end
end
figure(2);
Z = f(X,Y);
contour(X, Y, Z);
hold on;
for i=1:numel(a)
scatter(a(i),b(i),'MarkerEdgeColor','k','MarkerFaceColor','r');
if delta(a(i),b(i)) < 0
53
else
end
end
● GRAPH
15. Find the local maximum and minimum values and saddle points of f(x, y) = x 3 + 3xy
+ y 3. Sketch the given surface and show the extreme values.
● HOW TO SOLVE
Fx=3x2+3y
Fy=3y2+3x
Fx=0 ->y=-x2
Fy=0 ->x=-y2
A:fxx=6x
B:fxy=3
C:fyy=6y
54
Substituing point N(0;0) for A B C we have A=0;B=3;C=0->AC-B2=-3<0
% Init
clc;
close all;
syms x y z;
fx = diff(f,x);
fy = diff(f,y);
for i=1:numel(a)
if delta(a(i),b(i)) < 0
55
else
end
end
figure(1);
fsurf(f);
hold on;
for i=1:numel(a)
scatter3(a(i),b(i),f(a(i),b(i)),'MarkerEdgeColor','k','MarkerFaceColor','r');
if delta(a(i),b(i)) < 0
else
end
end
figure(2);
56
[X, Y] = meshgrid(-10:0.1:10, -10:0.1:10);
Z = f(X,Y);
contour(X, Y, Z);
hold on;
for i=1:numel(a)
scatter(a(i),b(i),'MarkerEdgeColor','k','MarkerFaceColor','r');
if delta(a(i),b(i)) < 0
else
end
end
● GRAPH
16. Find the local maximum and minimum values and saddle points of f(x, y) = 4xy − x4
− y 4 . Sketch the given surface and show the extreme values.
● HOW TO SOLVE
57
Fx= 4y-4x3
Fy=4x-4y3
A:fxx=-12x2
B:fxy=4
C:fyy=-12y2
% Init
clc;
close all;
syms x y z;
fx = diff(f,x);
58
fy = diff(f,y);
for i=1:numel(a)
if delta(a(i),b(i)) < 0
else
end
end
figure(1);
fsurf(f);
59
hold on;
for i=1:numel(a)
scatter3(a(i),b(i),f(a(i),b(i)),'MarkerEdgeColor','k','MarkerFaceColor','r');
if delta(a(i),b(i)) < 0
else
end
end
figure(2);
Z = f(X,Y);
contour(X, Y, Z);
hold on;
for i=1:numel(a)
scatter(a(i),b(i),'MarkerEdgeColor','k','MarkerFaceColor','r');
if delta(a(i),b(i)) < 0
60
text(a(i),b(i),'\leftarrow Local Min','Color','r');
else
end
end
● GRAPH
17. Find the local maximum and minimum values and saddle points of f(x, y) = x 3 + 2y 3
− 3x 2 − 6y. Sketch the given surface and show the extreme values.
● HOW TO SOLVE
Fy=6y2 -6
61
➔ We have point M(0;1), N(0;-1) ,point P(2;1) ,point Q(2;-1)
A:fxx=6x-6
B:fxy=0
C:fyy=12y
% Init
clc;
close all;
syms x y z;
fx = diff(f,x);
fy = diff(f,y);
62
fyy(x,y) = diff(fy, y);
for i=1:numel(a)
if delta(a(i),b(i)) < 0
else
end
end
figure(1);
fsurf(f);
hold on;
for i=1:numel(a)
scatter3(a(i),b(i),f(a(i),b(i)),'MarkerEdgeColor','k','MarkerFaceColor','r');
if delta(a(i),b(i)) < 0
63
text(a(i),b(i),f(a(i),b(i)),'\leftarrow Saddle point','Color','r');
else
end
end
figure(2);
Z = f(X,Y);
contour(X, Y, Z);
hold on;
for i=1:numel(a)
scatter(a(i),b(i),'MarkerEdgeColor','k','MarkerFaceColor','r');
if delta(a(i),b(i)) < 0
else
end
end
● GRAPH
64
18. Find the surface area of the part of the sphere x2 + y2 + z2 = 4 that lies inside the
cylinder x 2 + y 2 = 2y. Sketch the given surface.
● HOW TO SOLVE
Z=
The Cylinder function can be written as which is a circle with the
center point(0,1) on the xy-plane and the radius of 1, thus show that it lies on the path
from 0 to π.
S=
=2
=2 =4 =4 =9,1327
● MATLAB CODE
syms r theta v;
f=sqrt(1+(r.^2)/4-r.^2);
65
i1= int(f*r, r, 0, 2*sin(theta));
disp(i2)
ezsurf(cos(theta), 1+ sin(theta),v)
hold on
grid on
x=x*2;
y=y*2;
z=z*2;
figure
surf(x,y,z);
xlabel('X');
ylabel('Y');
zlabel('Z');
8*pi-16
● GRAPH
66
19. Find the surface area of the sphere x 2 + y 2 + z 2 = 9. Sketch the given surface
● HOW TO SOLVE
z= =
S= =6 =36π
● MATLAB CODE
r = 2;
[x, y, z] = sphere(25);
x = r * x;
y = r * y;
z = r * z;
surf(x, y, z)
● GRAPH
67
20. Find the surface area of the part of the sphere x 2 + y 2 + z 2 = 2 that lies above the
cone z 2 = x 2 + y 2 . Sketch the given surface.
● HOW TO SOLVE
Z=
Zx=
Zy=
( )=<
With
dA= =2
s= =4 (1-
● MATLAB CODE
syms r t;
f = @(r,t) sqrt(2)*r/(sqrt(2-r.^2));
a=int(int(f,r,0,1),t,0,2*pi);
% graphing
[U,V]= meshgrid(-10:0.1:10);
R=2;
x =r* sin(U)*cos(V);
68
y =r* sin(U)*sin(V);
z =r* cos(U);
[x,y,z]= sphere
hold on
syms u v
axis equal;
xlabel('X');
ylabel('Y');
zlabel('Z');
-2*pi*(2^(1/2) - 2)
● GRAPH
Solution
69
1 2𝜋
𝐼 = ∫ ∫ 𝑟√1 + 𝑟 2 𝑑𝜃𝑑𝑟
0 0
1 2𝜋
𝐼 = ∫ 𝑟√1 + 𝑟 2 𝑑𝑟 ∫ 𝑑𝜃
0 0
1
𝐼 = 2𝜋 × ∫ 𝑟√1 + 𝑟 2 𝑑𝑟
0
23/2 − 1
𝐼 = 2𝜋 × ≈ 3,829
3
Code
syms x y Phi r
z=x*y
D=[0<=r<=1;0<=Phi<=2*pi]
%diff(z,x,1)
%diff(z,y,1)
f= (subs((sqrt(1+(diff(z,x,1)).^2+(diff(z,y,1)).^2)),[x,y],[r*cos(Phi),r*sin(Phi)]))*r
%int(f,r,0,2*sin(Phi))
V=(int(int(f,r,0,1),Phi,0,2*pi))
clf
r= linspace(0,1,30);
Phi= linspace(0,2*pi,30);
[r,Phi]=meshgrid(r,Phi);
x=r.*cos(Phi);
y=r.*sin(Phi);
z= x.*(y);
hold on
surfc(x,y,z,"FaceColor",'b',"FaceAlpha",1);
phi=linspace(0,2*pi,30); z2=linspace(-0.5,0.5,30);
[z2 phi ] = meshgrid(z2,phi );
x1=1.*cos(phi); y1=1.*sin(phi);
surf(x1,y1,z2,"FaceAlpha",0.3);
view([6.489 36.949])
xlabel('X-axis');ylabel('Y-axis');zlabel('Z-axis');title('Surface'); grid on;
rotate3d on
Graph
70
Solution
1 2𝜋
𝐼 = ∫0 ∫0 −𝑟(𝑟 2 − 1) 𝑑𝜃𝑑𝑟
1 2𝜋
2
𝐼 = ∫ −𝑟(𝑟 − 1)𝑑𝑟 ∫ 𝑑𝜃
0 0
2 2 𝑟=1
(𝑟 − 1) 𝜋
𝐼 = 2𝜋 × [ ] =
4 𝑟=0
2
Code
syms x y r Phi
z1= 2 - 2*x
z2= (x-1).^2 + y.^2
D=[x.^2 + y.^2 ==1]
D2= [0<=r<=1,0<=Phi<=2*pi]
f= (subs((z1-z2),[x,y],[r*cos(Phi),r*sin(Phi)]))*r
V= int(int(f,r,0,1),Phi,0,2*pi)
clf
71
hold on
phi=linspace(0,2*pi,20);
r=linspace(0,1,20);
[R P]=meshgrid(r,phi);
x= R.*cos(P);
y= R.*sin(P);
z= 2-2.*x;
z1= (x-1).^2 + y.^2;
surf(x,y,z,'FaceColor','r',"FaceAlpha",0.7);
surf(x,y,z1,"FaceAlpha",0.95);
xlabel('X-axis');ylabel('Y-axis');zlabel('Z-axis');title('Surface');
view([150 20]); rotate3d on; grid on
Graph
Solution
72
1 2𝑥
𝐼 = ∫ ∫ (𝑥 2 + 2𝑦 2 − (𝑥 2 + 𝑦 2 )) 𝑑𝑦𝑑𝑥
0 𝑥
1 𝑦=2𝑥
𝑦3
𝐼=∫ [ ] 𝑑𝑥
0 3 𝑦=𝑥
1
7 3 7
𝐼=∫ 𝑥 𝑑𝑥 =
0 3 12
Code
syms x y
y1= x
y2= 2*x
x1= 1
z1= x.^2 + y.^2
z2= x.^2 + 2*(y.^2)
f1= int((z2-z1),y,x,2*x)
V= int(f1,x,0,1)
clf
hold on
x=linspace(0,2,30);
y=linspace(0,2,30);
[x y]=meshgrid(x,y);
z= x.^2 + y.^2;
z4= x.^2 +2.*(y.^2);
x1=linspace(0,1,30); z2=linspace(0,9,30);
[z2 x1 ] = meshgrid(z2,x1 );
y1=x1;
y2=2.*x1;
x3=linspace(1,1,30);
y3=linspace(1,2,30);
z3=linspace(0,10,30);
[y3 z3]=meshgrid(y3,z3);
surf(x,y,z,"FaceColor",'b');
surf(x,y,z4,"FaceColor",'r');
surf(x1,y1,z2,"FaceAlpha",0.8,"FaceColor",'w');
surf(x1,y2,z2,"FaceAlpha",0.8,"FaceColor",'w');
surf(x3,y3,z3,"FaceAlpha",0.1,"FaceColor",'w');
text(0.75,1.75,6,'\leftarrow Solid');
xlabel('X-axis');ylabel('Y-axis');zlabel('Z-axis')
title('Solid')
view([-168.48 23.23]); grid on
73
rotate3d on
Graph
Solution
𝜋/2 2𝑐𝑜𝑠𝜃
𝐼=∫ ∫ 𝑟 2 × 𝑟 𝑑𝑟𝑑𝜃
−𝜋/2 0
𝜋/2 𝑟=2𝑐𝑜𝑠𝜃
𝑟4
𝐼=∫ [ ] 𝑑𝜃
−𝜋/2 4 𝑟=0
𝜋/2
3
𝐼=∫ 4𝑐𝑜𝑠 4 𝜃𝑑𝜃 = 𝜋
−𝜋/2 2
Code
syms x y r Phi
z= x.^2+y.^2
z1= (subs(z,[x,y],[r*cos(Phi),r*sin(Phi)]))*r
74
D1=[0<=r<=2*cos(Phi),0<=Phi<=2*pi]
V=int(int(z1,r,0,2*cos(Phi)),Phi,-pi/2,pi/2)
clf
r= linspace(0,1,30);
Phi= linspace(0,2*pi,30);
[r,Phi]=meshgrid(r,Phi);
x=r.*cos(Phi);
y=r.*sin(Phi);
z= x.^2 + y.^2;
hold on
surf(x,y,z,"FaceColor",'b');
phi=linspace(0,2*pi,30); z2=linspace(0,1.2,30);
[z2 phi ] = meshgrid(z2,phi );
x1=1+1.*cos(phi); y1=1.*sin(phi);
surf(x1,y1,z2,"FaceAlpha",0.3,"FaceColor",'r');
view([6.489 36.949]);
xlabel('X-axis');ylabel('Y-axis');zlabel('Z-axis');title('Solid')
grid on; rotate3d on
Solution
75
1 2𝜋
𝐼 = ∫ ∫ −𝑟(𝑟 2 − 1) 𝑑𝑟𝑑𝜃
0 0
1 2𝜋
𝜋
𝐼 = ∫ −𝑟(𝑟 2 − 1) 𝑑𝑟 ∫ 𝑑𝜃 =
0 0 2
Code
syms x y r Phi
z1=1-x.^2-y.^2
z2=0
D=[0<=r<=1;0<=Phi<=2*pi]
f=(subs((z1-z2),[x,y],[r*cos(Phi),r*sin(Phi)]))*r
V=int(int(f,r,0,1),Phi,0,2*pi)
clf
r= linspace(0,1,30);
Phi= linspace(0,2*pi,30);
[r,Phi]=meshgrid(r,Phi);
x=r.*cos(Phi);
y=r.*sin(Phi);
z= 1- x.^2 - y.^2;
hold on
surf(x,y,z,"FaceColor",'b',"FaceAlpha",0.7);
phi=linspace(0,2*pi,30); z2=linspace(0,0.5,30);
[z2 phi ] = meshgrid(z2,phi );
x1=1.*cos(phi); y1=1.*sin(phi);
surf(x1,y1,z2,"FaceAlpha",0.3,"FaceColor",'w')
view([6.489 36.949]);
xlabel('X-axis');ylabel('Y-axis');zlabel('Z-axis');title('Solid')
rotate3d on; grid on
Graph
76
Solution
2 5
𝐼=∫ ∫ 3𝑥 𝑑𝑦𝑑𝑥
0 1+𝑥 2
2
𝐼 =3× ∫0 𝑥(4 − 𝑥 2 )𝑑𝑥
𝑥=2
(4 − 𝑥 2 )2
𝐼 =3×[ ] = 12
−4 𝑥=0
Code
syms x y
y1= 1+x.^2
y2=5
z1=0
z= 3.*x
V= int(int(z,y,y1,y2),x,0,2)
clf
hold on
x=linspace(0,2,30);
77
y=linspace(1,5,30);
[x y]=meshgrid(x,y);
z=3.*x;
surf(x,y,z,"FaceColor",'r');
x1=linspace(0,2,30); z2=linspace(0,6,30);
[z2 x1 ] = meshgrid(z2,x1 );
y1=1+(x1).^2;
surf(x1,y1,z2,"FaceAlpha",0.4,"FaceColor",'w');
x3=linspace(0,2,30);
y3=linspace(5,5,30);
z3=linspace(0,6,30);
[y3 z3]=meshgrid(y3,z3);
surf(x3,y3,z3,"FaceColor",'b',"EdgeAlpha",0.1);
text(1.5,2,1,'\rightarrow Solid');
xlabel('X-axis');ylabel('Y-axis');zlabel('Z-axis');
title('Solid')
view([66.23 11.04]); grid on
rotate3d on
Grap
78
Solution
1 1−𝑥/2
𝐼=∫ ∫ 2 − 𝑥 − 2𝑦 𝑑𝑦 𝑑𝑥
0 𝑥/2
1
𝑦=1−𝑥/2
𝐼 = ∫ [2𝑦 − 𝑥𝑦 − 𝑦 2 ]𝑦=𝑥/2 𝑑𝑥
0
1 𝑥=1
2
𝑥3 12
𝐼 = ∫ 1 − 2𝑥 + 𝑥 𝑑𝑥 = [𝑥 − 𝑥 + ] =
0 3 𝑥=0 3
Code
syms x y
y1= x/2
y2= 1-(x/2)
z1= 2-x-2*y
V= int(int((z1),y,y1,y2),x,0,1)
clf
hold on
x=linspace(0,1,30);
y=linspace(0,1,30);
[x y]=meshgrid(x,y);
z=2-x-2.*(y);
surf(x,y,z,"FaceColor",'r',"EdgeAlpha",0);
x1=linspace(0,1,30); z2=linspace(0,2,30);
[z2 x1 ] = meshgrid(z2,x1 );
y1=(x1/2);
surf(x1,y1,z2,"FaceAlpha",0.4,"FaceColor",'w')
x3=linspace(0,0,30);
y3=linspace(0,1,30);
z3=linspace(0,5,30);
[y3 z3]=meshgrid(y3,z3);
surf(x3,y3,z3,"EdgeAlpha",0);
xlabel('X-axis');ylabel('Y-axis');zlabel('Z-axis');
title('Solid');
axis([0 1 0 1 0 2]); grid on
view([26.77 14.29]);
rotate3d on
Graph
79
Solution
𝜋/4 𝑐𝑜𝑠2𝜃
𝐼=∫ ∫ 𝑟 𝑑𝑟 𝑑𝜃
−𝜋/4 0
𝜋/4 2
𝑐𝑜𝑠 (2𝜃) 𝜋
𝐼=∫ 𝑑𝜃 =
−𝜋/4 2 8
Code
syms Phi r
z=r
D=[0<=r<=cos(2*Phi);-pi/4<=Phi<=pi/4]
V=(int(int(z,r,0,cos(2*Phi)),Phi,-pi/4,pi/4))
clf
phi=linspace(0,pi/4,30);
phi1=linspace(-pi/4,0,30);
r=cos(2.*phi);
r1=cos(2.*phi1);
80
hold on
[x y]=pol2cart(phi,r);
[x1 y1]=pol2cart(phi1,r1);
area(x,y,"FaceColor",'b'); area(x1,y1,"FaceColor",'b');
text(0.7,0.2,'r=cos(2*Phi)',"FontSize",10);
text(0.5,0,'Region D',"FontSize",20);
xlabel('X-axis');ylabel('Y-axis');zlabel('Z-axis');
title('Region');grid on
Graph
Solution
𝑦 0
3
𝐷1 = ∫ ∫ 𝑑𝑦 𝑑𝑥 =
𝑦−𝑦 3 −1 4
𝑥 0
1
𝐷2 = ∫ ∫ 𝑑𝑥 𝑑𝑦 =
(𝑥+1)2 −1 3
81
𝑦 1
1
𝐷3 = ∫ ∫ 𝑑𝑦 𝑑𝑥 =
−(𝑦−𝑦 3 ) 0 4
4
𝐷 = 𝐷1 + 𝐷2 + 𝐷3 =
3
Code
syms x y
x3=-1+sqrt(y)
x1= y - y.^3
x2= -1
y2= -1
y1= (x+1).^2
[y3]=solve((x3==x1),y)
D1= 1-abs(int(x1,y,y2,0))
D2= int(y1,x,x2,0)
D3= int(x1,y,0,y3)
D= D1 + D2 + D3
clf
x=[-1:0.1:0];
y1=[-1:0.1:1];
%y1=linspace(1,1,2)
%x1=linspace(0,1,2)
y=(x+1).^2;
x1=(y1-y1.^3);
hold on
plot(x1,y1,"Color",'r');
plot(x,y,"Color",'b',"MarkerFaceColor","auto");
xlabel('X-axis');ylabel('Y-axis');zlabel('Z-axis');
title('The region');
text(-0.6,-0.2,'D',"FontSize",40);
text(-0.6,0.4,'y=(x+1)^2',"FontSize",15);
text(0,-0.05,'\leftarrow x=y-y.^3',"FontSize",15);
grid on
82
Graph
Solution
6𝑐𝑜𝑠𝜃 𝜋/4
𝐼=∫ ∫ 2𝑟 2 𝑐𝑜𝑠𝜃 𝑑𝜃 𝑑𝑟
2𝑐𝑜𝑠𝜃 −𝜋/2
6𝑐𝑜𝑠𝜃 𝜋/4
104
𝐼=∫ 2𝑟 2 𝑑𝑟 ∫ 𝑐𝑜𝑠𝜃 𝑑𝜃 = 39𝜋 +
2𝑐𝑜𝑠𝜃 −𝜋/2 3
Code
syms x y r Phi
f= 2*x
f1= (2*r*cos(Phi))*r
D=[2*x<=x.^2+y.^2<=6*x;y<=x]
D1=[2*cos(Phi)<=r<=6*cos(Phi)]
%int(f1,r,2*cos(Phi),6*cos(Phi));
V=int(int(f1,r,2*cos(Phi),6*cos(Phi)),Phi,-pi/2,pi/4)
clf
83
phi=linspace(-pi/2,pi/4,30);
phi1=linspace(-pi/2,pi/4,30);
x2=linspace(0,4,20);
r=6.*cos(phi);
r1=2.*cos(phi1);
y2=x2;
hold on
[x y]=pol2cart(phi,r);
[x1 y1]=pol2cart(phi1,r1);
plot(x,y); patch([x fliplr(x2)], [y fliplr(y2)], 'r')
patch([x1 fliplr(x2)], [y1 fliplr(y2)], 'w');
text(0.7,0.2,'r=2*cos(phi)',"FontSize",12);
text(5,2.3,'r=6*cos(phi)',"FontSize",12);
text(3,0,'Region D',"FontSize",20);
xlabel('X-axis');ylabel('Y-axis');zlabel('Z-axis')
title('Region');grid on
Graph
84
Problems 31:
x + y2 = 1 y=1
SOLUTION: { 𝑦 − 𝑥 = 1 → { y = −2
𝑥=0 x=0
0 1 9
I = ∬y−1 dxdy = ∫−2 −(𝑦 − 1)𝑑𝑦 = 2
CODE:
syms x y
x1=y-1
x2=1-y.^2
solve((x1==x2),y)
int((x2-x1),y,-2,1)
clf
y=[-2:0.1:1];
x=1-y.^2;
x1=y-1;
hold on
plot(x1,y);
plot(x,y);
patch([x fliplr(x1)], [y fliplr(y)], 'r');
text(-1,-0.5,'Region D',"FontSize",20);
text(-1.5,0,'x=y-1',"FontSize",20);
text(-1,-1.5,'x=1-y.^2',"FontSize",20);
xlabel('X-axis');ylabel('Y-axis');zlabel('Z-axis')
axis([-3 0 -2 1])
title('Region'); grid on
85
Problems 32:
1≤𝑟≤2
SOLUTION: {−𝜋 ≤ 𝜃 ≤ 𝜋
4 2
𝜋
2
7
2
I = ∬ (r cos θ + r sin θ)rdr 𝑑𝜃 = ∫ (cos θ + sin θ) 𝑑𝜃
−𝜋 3
1
4
CODE:
syms x y r Phi
f1= x + y
D=[1<= x.^2 + y.^2 <= 4;x>=0;y>=0;y>=x]
%r == sqrt(x.^2 + y.^2)
f2= (subs(f1,[x,y],[r*cos(Phi),r*sin(Phi)]))*r
%x1= r*cos(Phi)
%y1= r*sin(Phi)
D2=[1<=r<=2;pi/4<=Phi<=pi/2]
V= int(int(f2,r,1,2),Phi,pi/4,pi/2)
clf
r= 1;
r2 =2;
x3 =[0:0.1:2.2];
Phi= [pi/4:0.1:pi];
x= r.*cos(Phi);
y= r.*sin(Phi);
x2= r2.*cos(Phi);
86
y2= r2.*sin(Phi);
y3= x3;
hold on
area(x2,y2,"FaceColor",'r',"EdgeColor","flat");
area(x,y,"FaceColor",'w');
area(x3,y3,"FaceColor",'w');
xlabel('X-axis');ylabel('Y-axis');title('Region D')
text(0.3,1.6,'Region D')
text(0.3,2,'x.^2+y.^x=4')
text(0.4,1,'x.^2+y.^x=1')
text(1,1,'y=x')
axis([0 2 0 2])
grid on
Problems 33:
1≤𝑟≤2
SOLUTION: {
0≤𝜃≤𝜋
2 𝜋
15
I = ∬ (3r cos θ + 4r 2 sin θ2 )rdr 𝑑𝜃 = ∫ (7 cos 𝜃 + 15 sin2 𝜃) 𝑑𝜃 =
1 0 2
CODE:
87
syms x y r Phi
f1= 3*x + 4*y.^2
D=[1<= x.^2 + y.^2 <= 4;y>=0]
r == sqrt(x.^2 + y.^2)
x1= r*cos(Phi)
y1= r*sin(Phi)
f2= (3*x1 + 4*(y1.^2))*r
D2=[1<=r<=2;0<=Phi<=pi]
V= int(int(f2,r,1,2),Phi,0,pi)
clf
r= 2;
r1= 1;
Phi= [0:0.1:pi];
x= r.*cos(Phi);
y= r.*sin(Phi);
x1= r1.*cos(Phi);
y1= r1.*sin(Phi);
hold on
area(x,y,"FaceColor",'B');
area(x1,y1,"FaceColor",'w');
xlabel('X-axis');ylabel('Y-axis');title('Region D')
text(0.3,1.6,'Region D',"FontSize",20)
text(0.3,2,'x.^2+y.^x=4')
text(0.4,1,'x.^2+y.^x=1')
grid on
88
Problems 34:
SOLUTION:
x 2 1 2 𝑒−1
I = ∬0 e 𝑥 𝑑𝑦 𝑑𝑥 = ∫0 𝑥𝑒 𝑥 dx = 2
CODE:
syms x y
f=exp(x.^2)
V=int(int(f,x,y,1),y,0,1)
clf
x=[0:0.1:1];
x1=linspace(1,1,20);
y1=linspace(0,1,20);
y=x;
hold on
plot(x1,y1);;
area(x,y,"FaceColor",'r')
text(0.3,0.5,'x=y',"FontSize",20);
text(0.7,0.3,'Region D',"FontSize",20);
xlabel('X-axis');ylabel('Y-axis');zlabel('Z-axis')
title('Region')
grid on
89
Problems 35:
SOLUTION:
y2 x 1
1
I = ∬ ey dxdy = ∫ y(ey − 1) 𝑑𝑦 =
0 0 2
CODE:
syms x y z
f= exp(x/y)
f1= int(f,x,0,y.^2)
V= int(f1,y,0,1)
clf
y=[0:0.1:1];
y1=linspace(1,1,2);
x1=linspace(0,1,2);
x=y.^2;
hold on
area(x1,y1,"FaceColor",'r',"FaceAlpha",0.8);
area(x,y,"FaceColor",'w');
xlabel('X-axis');ylabel('Y-axis');zlabel('Z-axis');
title('The region');
text(0.3,0.8,'Region D')
90
Problems 36:
SOLUTION:
1 1 y=1 1 1
I = ∬ x dA = ∬0 xy𝑑𝑥 = ∫0 [𝑥𝑦] 1y = 0dx = ∫0 𝑥𝑑𝑥 = 2
CODE:
syms x y z
f= @(x,y) x
f1= int(f,y,x,1)
V= int(f1,x,0,1)
clf
x=[0 1 0];
y=[0 1 1];
x1=[0 1 1];
y1=[0 1 0];
hold on
area(x,y);
area(x1,y1,"FaceColor",'w');
xlabel('X-axis');ylabel('Y-axis');title('Region D')
text(0.3,0.8,'The region D')
91
Problems 37:
SOLUTION:
π π π π
y=
I = ∬ sinx. cosy dA = ∬02 sinx. cosy. dydx = ∫02 [sinx. siny]1y = 02 𝑑𝑥 = ∫02 sinx 𝑑𝑥 = -1.
CODE:
syms x y
f= @(x,y) sin(x).*cos(y)
V= integral2(f,0,(pi/2),0,(pi/2))
rectangle('Position',[0 0 (pi/2) (pi/2)],"FaceColor",'r')
axis([0 3 0 3])
title('Region')
xlabel('X axis')
ylabel('Yaxis')
grid on
text(0.6,0.75,'Region D')
92
Problems 38:
SOLUTION:
2 2 y=2 2
I = ∬(3𝑦 2-x) 𝑑𝐴 = ∬1 (3𝑦 2-x)𝑑𝑦 𝑑𝑥 = ∫0 [y 3 − xy]1y = 1 = ∫0 (7 − 𝑥)𝑑𝑥 = 12
CODE:
syms x y
I = @(x,y) 3*y.^2 - x
V=integral2(I,0,2,1,2)
rectangle('Position',[1 1 2 1],"FaceColor",'r')
axis([0 5 0 5])
title('Region')
xlabel('X axis')
ylabel('Yaxis'); grid on
text(2,1.5,'Region D')
93
Problems 39:
SOLUTION:
2 𝑧3 2 1 9 y=2 27
I = ∭ xyz 2 dA = ∬−1[𝑥𝑦 3 ]1zz = 3 2
= 0 dydx = ∬−1 9𝑥𝑦𝑑𝑦𝑑𝑥 = ∫0 [2 𝑥𝑦 ]1y = −1 dx = 4
CODE:
syms x y z
f= @(x,y,z) x.*y.*(z.^2)
V= integral3(f,0,1,-1,2,0,3)
clf
patch([1,1,0,0],[-1,2,2,-1],[0,0,0,0],'r')
patch([1,1,0,0],[-1,2,2,-1],[3,3,3,3],'r')
patch([1,1,0,0],[-1,-1,-1,-1],[0,3,3,0],'blue')
patch([1,0,0,1],[2,2,2,2],[0,0,3,3],'blue')
patch([1,1,1,1],[-1,-1,2,2],[0,3,3,0],'g')
patch([0,0,0,0],[-1,-1,2,2],[0,3,3,0],'g')
xlabel('X-axis');ylabel('Y-axis');zlabel('Z-axis');title('Solid')
hold on;grid on
view([53 54])
rotate3d on
94
Problems 40:
SOLUTION:
x2 1 y = x2 1 2
I = ∭(x + 2y)dV = ∬x (x 2 +2xy)dydx = ∫0 [x 2 y+xy 2 ]1y = x = ∫0 𝑥 5 + 𝑥 4 − 2𝑥 2 = 15
CODE:
syms x y z
f=x + 2*y
Omega=[x.^2<=y<=x;0<=z<=x]
solve((x.^2==x),x)
V=int(int(int(f,z,0,x),y,x.^2,x),x,0,1)
clf
hold on
x=linspace(0,1,30);
y=linspace(0,1,30);
[x y]=meshgrid(x,y);
z= x;
x1=linspace(0,1,30); z2=linspace(0,1,30);
[z2 x1 ] = meshgrid(z2,x1 );
y1=x1;
y2=x1.^2;
surf(x,y,z,"FaceColor",'b')
surf(x1,y1,z2,"FaceAlpha",0.8,"FaceColor",'r')
95
surf(x1,y2,z2,"FaceAlpha",0.3,"FaceColor",'w')
text(0.9,0.4,0.2,'\rightarrow Solid')
xlabel('X-axis');ylabel('Y-axis');zlabel('Z-axis')
title('Solid')
view([-254.311 2.907]); grid on
rotate3d on
SOLUTION
4
I = ∬ [∫𝑥 2+𝑧 2 √𝑥 2 + 𝑧 2 𝑑𝑦] dA
96
= ∬(4−𝑥 2 − 𝑧 2 ) × √𝑥 2 + 𝑧 2 )dA
2𝜋 2
= ∫0 𝑑𝜃 ∫0 (4 − 𝑟 2 ) × 𝑟 × 𝑟 𝑑𝑟
4 1 𝑟=2 128𝜋
= 2𝜋 × [3 × 𝑟 3 − 5 × 𝑟 5 ] =
𝑟=0 15
CODE
clc
clf
syms x y z
xmin=-2;
xmax=2;
ymin= @(x,z) x.^2+z.^2;
ymax= 4;
zmin= @(x)-(4-x.^2).^(1/2);
zmax= @(x) (4-x.^2).^(1/2);
f= @(x,z,y) (x.^2+z.^2).^(1/2);
I=integral3(f,xmin,xmax,zmin,zmax,ymin,ymax);fprintf('I=%f\n',I);
%sketch the given region
Z= @(x,y) (y-x^2)^(1/2);
fsurf(Z, [-2 2 0 4]);
hold on;
Z= @(x,y) -(y-x^2)^(1/2);
fsurf(Z, [-2 2 0 4]);
xlabel('x-axis');
ylabel('y-axis');
zlabel('z-axis');
97
SOLUTION
0≤𝑧≤𝑥
𝑉 = {0 ≤ 𝑥 ≤ √4 − 𝑦 2
0≤𝑦≤2
2 √4−𝑦 2 𝑥
I = ∫0 ∫0 ∫0 2𝑥 𝑑𝑧 𝑑𝑥 𝑑𝑦
2 √4−𝑦2
= ∫0 ∫0 2𝑥𝑧|0𝑥 𝑑𝑥 𝑑𝑦
2 √4−𝑦2
= ∫0 ∫0 2𝑥 2 𝑑𝑥 𝑑𝑦
𝑥=√4−𝑦2
2 2𝑥 3
= ∫0 [ 3 ] 𝑑𝑦
𝑥=0
3
2
2 2(√4−𝑦 )
= ∫0 𝑑𝑦 = 2𝜋
3
CODE
clc
clf
f=@(theta,r,z) 2.*r.*cos(theta).*r;
zmax=@(theta,r)r.*cos(theta);
I= integral3(f,0,pi/2,0,2,0,zmax);
fprintf('I=%f\n',I)
98
Y3(Z2>X2)=NaN;
surf(X2,Y3,Z2,'FaceColor','r','FaceAlpha',0.5,'EdgeColor','none');
xlabel('x-axis');
ylabel('y-axis');
zlabel('z-axis');
SOLUTION
𝑟 2 ≤ 𝑧 ≤ 𝑟 2 𝑐𝑜𝑠 2 𝜃 + 𝑟 2 𝑥 = 𝑟𝑐𝑜𝑠𝜃
𝑉={ 0≤𝑟≤1 {
𝑦 = 𝑟𝑠𝑖𝑛𝜃
0 ≤ 𝜃 ≤ 2𝜋
2𝜋 1 𝑟 2 𝑐𝑜𝑠2 𝜃+𝑟 2
I = ∭ 𝑧 𝑑𝑉 = ∫0 ∫0 ∫𝑟 2 𝑧𝑟 𝑑𝑧 𝑑𝑟 𝑑𝜃
𝑟 2 𝑐𝑜𝑠2 𝜃+𝑟 2
2𝜋 1 𝑧2
= ∫0 ∫0 𝑟 [ 2 ] 𝑑𝑟 𝑑𝜃
𝑟2
2
2𝜋 1 𝑟(𝑟 2 𝑐𝑜𝑠2 𝜃+𝑟 2 ) 𝑟5
= ∫0 ∫0 ( − ) 𝑑𝑟 𝑑𝜃
2 2
99
2𝜋 1 𝑟 5 𝑐𝑜𝑠4 𝜃+2𝑟 5 𝑐𝑜𝑠2 𝜃+𝑟 5 −𝑟 5
= ∫0 ∫0 𝑑𝑟 𝑑𝜃
2
𝑟=1
2𝜋 𝑟 6 𝑐𝑜𝑠4 𝜃 𝑟 6 𝑐𝑜𝑠2 𝜃
= ∫0 [ + ] 𝑑𝜃
12 6 𝑟=0
2𝜋 𝑐𝑜𝑠4 𝜃 𝑐𝑜𝑠2 𝜃 11
= ∫0 ( + ) 𝑑𝜃 = 48 𝜋
12 6
CODE
clc
clf
f= @(theta,r,z) z.*r;
zmin=@(theta,r)r.^2;
zmax=@(theta,r) r.^2.*cos(theta).^2+r.^2;
I= integral3(f,0,2*pi,0,1,zmin,zmax);
fprintf('I=%f\n',I)
100
SOLUTION
1
𝐼=∭ 𝑑𝑉
𝑥2
+ 𝑦2
𝜋 1 𝑟𝑠𝑖𝑛𝜃
1
=∫ ∫ ∫ 𝑟 𝑑𝑧 𝑑𝑟 𝑑𝜃
0 0 0 𝑟2
𝜋 1
1 𝑧=𝑟𝑠𝑖𝑛𝜃
= ∫ ∫ [ 𝑧] 𝑑𝑟 𝑑𝜃
0 0 𝑟 𝑧=0
𝜋 1
1
= ∫ ∫ . 𝑟𝑠𝑖𝑛𝜃 𝑑𝑟 𝑑𝜃
0 0 𝑟
101
𝜋
= ∫ 𝑟𝑠𝑖𝑛𝜃|10 𝑑𝜃
0
𝜋
= ∫ 𝑠𝑖𝑛𝜃 𝑑𝜃 = 2
0
CODE
clc
clf
f= @(theta,r,z) 1./r;
zmax=@(theta,r)r.*sin(theta);
I= integral3 (f,0,pi,0,1,0,zmax);
fprintf('I=%f\n',I)
102
SOLUTION
𝜋
0≤𝜃≤
𝑉={ 2 0 ≤ 𝑦 ≤ √2𝑥 − 𝑥 2 ↔ (𝑥 − 1)2 + 𝑦 2 ≤ 1
0 ≤ 𝑟 ≤ 2𝑐𝑜𝑠𝜃
0≤𝑧≤1
𝜋/2 2𝑐𝑜𝑠𝜃 1
I= ∫0 ∫0 ∫0 𝑧𝑟 2 𝑑𝑧𝑑𝑟𝑑𝜃
𝜋/2 2𝑐𝑜𝑠𝜃 𝑟 2
= ∫0 ∫0 𝑑𝑟𝑑𝜃
2
3 𝑟=2𝑐𝑜𝑠𝜃
𝜋/2 𝑟
= ∫0 [ 6 ] 𝑑𝜃
𝑟=0
𝜋/2 (2𝑐𝑜𝑠𝜃)3 8
= ∫0 𝑑𝜃 =
6 9
CODE
clc
clf
f= @(theta,r,z) z.*r.^2;
rmax=@(theta)2.*cos(theta);
I= integral3(f,0,pi/2,0,rmax,0,1);
fprintf('I=%f\n',I)
103
xlabel('x-axis');
ylabel('y-axis');
zlabel('z-axis');
SOLUTION
0 ≤ 𝜃 ≤ 2𝜋 𝑧 = 𝜌𝑐𝑜𝑠𝜃
𝑉={0≤∅≤𝜋 {𝑥 = 𝜌𝑠𝑖𝑛∅𝑐𝑜𝑠𝜃 𝑥 2 + 𝑦 2 + 𝑧 2 = 𝜌2
0≤𝜌≤1 𝑦 = 𝜌𝑠𝑖𝑛∅𝑠𝑖𝑛𝜃
I = ∭(𝑥 + 𝑧)𝑑𝑉
2𝜋 𝜋 1
=∫ ∫ ∫ (𝜌𝑠𝑖𝑛𝜙𝑐𝑜𝑠𝜃 + 𝜌𝑐𝑜𝑠𝜃)𝜌2 𝑠𝑖𝑛𝜙 𝑑𝜌𝑑𝜙𝑑𝜃
0 0 0
2𝜋 𝜋 1 3
= ∫0 ∫0 ∫0 (𝜌 𝑠𝑖𝑛2 𝜙𝑐𝑜𝑠𝜃 + 𝜌3 𝑠𝑖𝑛𝜙𝑐𝑜𝑠𝜃) 𝑑𝜌𝑑𝜙𝑑𝜃
2𝜋 𝜋 1 2𝜋 𝜋 1
= ∫0 ∫0 ∫0 (𝜌3 𝑠𝑖𝑛2 𝜙𝑐𝑜𝑠𝜃) 𝑑𝜌𝑑𝜙𝑑𝜃 + ∫0 ∫0 ∫0 (𝜌3 𝑠𝑖𝑛𝜙𝑐𝑜𝑠𝜃) 𝑑𝜌𝑑𝜙𝑑𝜃
2𝜋 𝜋 1 2𝜋 𝜋 1
= ∫0 𝑐𝑜𝑠𝜃𝑑𝜃 ∫0 𝑠𝑖𝑛2 𝜙𝑑𝜙 ∫0 𝜌3 𝑑𝜌 + ∫0 𝑐𝑜𝑠𝜃𝑑𝜃 ∫0 𝑠𝑖𝑛𝜙𝑑𝜙 ∫0 𝜌3 𝑑𝜌 = 0
CODE
104
clc
clf
f= @(theta,phi,p) (p.^3.*sin(phi).^2.*cos(theta)+p.^3.*sin(phi).*cos(theta));
I= integral3(f,0,2*pi,0,pi,0,1);
fprintf('I=%f\n',I)
SOLUTION
0 ≤ 𝜃 ≤ 2𝜋 𝑦 = 𝜌𝑠𝑖𝑛∅𝑠𝑖𝑛𝜃
𝑉 = { 0 ≤ ∅ ≤ 𝜋 ,𝑧 ≥ 0 { 𝑥 = 𝜌𝑠𝑖𝑛∅𝑐𝑜𝑠𝜃
0≤𝜌≤1 → 𝑥 2 + 𝑦 2 = 𝜌2 𝑠𝑖𝑛2 ∅
𝐼 = ∭(𝑥 2 + 𝑦 2 )𝑑𝑉
105
2𝜋 𝜋 1
= ∫0 ∫0 ∫0 (𝜌2 𝑠𝑖𝑛2 𝜙)𝜌2 𝑠𝑖𝑛𝜙 𝑑𝜌𝑑𝜙𝑑𝜃
2𝜋 𝜋 1
= ∫0 ∫0 ∫0 (𝜌4 𝑠𝑖𝑛3 𝜙)𝑑𝜌𝑑𝜙𝑑𝜃
2𝜋 𝜋 1 8𝜋
= ∫0 𝑑𝜃 ∫0 𝑠𝑖𝑛3 𝜙𝑑𝜙 ∫0 𝜌4 𝑑𝜌 = 15
CODE
clc
clf
f= @(theta,phi,p) p.^4.*sin(phi).^3;
I= integral3(f,0,2*pi,0,pi,0,1);
fprintf('I=%f\n',I)
106
SOLUTION
−𝜋 𝜋
≤𝜃≤
4 4
𝑉= 0≤∅≤𝜋
2
{ 1 ≤ 𝜌 ≤ 2
I = ∭(𝑥 2 + 𝑦 2 + 𝑧 2 )𝑑𝑉
𝜋/4 𝜋/2 2
=∫ ∫ ∫ 𝜌2 × 𝜌2 𝑠𝑖𝑛𝜙 𝑑𝜌𝑑𝜙𝑑𝜃
−𝜋/4 0 1
𝜋/4 𝜋/2 2 31𝜋
= ∫−𝜋/4 𝑑𝜃 ∫0 𝑠𝑖𝑛𝜙𝑑𝜙 ∫1 𝜌4 𝑑𝜌 = 10
CODE
clc
clf
f= @(theta,phi,p) p.^4.*sin(phi);
I= integral3 (f,-pi/4,pi/4,0,pi/2,1,2);
fprintf ('I=%f\n',I)
107
surf(X,Y*0,Z,'FaceColor','b','FaceAlpha',0.5,'EdgeColor','none');
surf(Y*0,X,Z,'FaceColor','b','FaceAlpha',0.5,'EdgeColor','none');
surf(X,Z,Y*0,'FaceColor','c','FaceAlpha',0.5,'EdgeColor','none');
xlabel('x-axis');
ylabel('y-axis');
zlabel('z-axis');
SOLUTION
0 ≤ 𝜃 ≤ 2𝜋
𝜋
𝑉 = { 0 ≤ ∅ ≤ 4 , 𝑧 = √𝑥 2 + 𝑦 2
0≤𝜌≤2
1
𝐼=∭ 𝑑𝑉
𝑥2+ 𝑦2 + 𝑧2
2𝜋 𝜋/4 2
1
= ∫ ∫ ∫ 2 𝜌2 𝑠𝑖𝑛𝜙 𝑑𝜌𝑑𝜙𝑑𝜃
0 0 0 𝜌
108
2𝜋 𝜋/4 2
= ∫0 𝑑𝜃 ∫0 𝑠𝑖𝑛𝜙𝑑𝜙 ∫0 𝑑𝜌 = 2𝜋(2 − √2)
CODE
clc
clf
f= @(theta,phi,p) sin(phi);
I=integral3(f,0,2*pi,0,pi/4,0,2);
fprintf('I=%f\n',I)
xlabel('x-axis');
ylabel('y-axis');
zlabel('z-axis');
109
SOLUTION
0 ≤ 𝜃 ≤ 2𝜋
𝜋
𝑉={0≤∅≤ , 𝑥 2 + 𝑦 2 + 𝑧 2 = 𝜌2
2
0≤𝜌≤1
2𝜋 𝜋/2 1
𝐼=∫ ∫ ∫ 𝑒 𝜌 𝜌2 𝑠𝑖𝑛𝜙 𝑑𝜌𝑑𝜙𝑑𝜃
0 0 0
2𝜋 𝜋/2 1
= ∫0 𝑑𝜃 ∫0 𝑠𝑖𝑛𝜙𝑑𝜙 ∫0 𝑒 𝜌 𝜌2 𝑑𝜌 ≈ 4,5131
CODE
clc
clf
f= @(theta,phi,p) exp(p).*p.^2.*sin(phi);
I= integral3(f,0,2*pi,0,pi/2,0,1);
fprintf('I=%f\n',I)
110
SOLUTION
0 ≤ 𝜃 ≤ 2𝜋
𝜋
𝑉={ 0≤∅≤ , 𝑥 2 + 𝑦 2 + 𝑧 2 = 𝑧 → 𝜌 = 𝑐𝑜𝑠∅
4
0 ≤ 𝜌 ≤ 𝑐𝑜𝑠∅
𝜋
2𝜋 𝑐𝑜𝑠𝜙
𝐼 = ∫0 ∫04 ∫0 𝜌2 𝑠𝑖𝑛𝜙 𝑑𝜌𝑑𝜙𝑑𝜃
2𝜋 𝜋/4 𝑐𝑜𝑠𝜙
=∫ 𝑑𝜃 ∫ 𝑠𝑖𝑛𝜙𝑑𝜙 ∫ 𝜌2 𝑑𝜌
0 0 0
2 𝜋/4
= 𝜋 ∫0 𝑠𝑖𝑛𝜙 𝑐𝑜𝑠 3 𝜙𝑑∅
3
𝜋
=
8
111
CODE
clc;
clear;
f1 = @(theta,phi,p) p.^2.*sin(theta);
pmax = @(theta,phi) cos(theta);
V = integral3(f1,0,pi/4,0,2*pi,0,pmax);
fprintf( 'The volume of the solid is %f\n',V);
phi=linspace(0,2*pi,250); theta=linspace(0,pi/2,250);
[p,t]=meshgrid(phi,theta);
x=cos(t).*sin(t).*cos(p); y=cos(t).*sin(t).*sin(p); z=cos(t).*cos(t);
a=linspace(-1,1,500);b=linspace(-1,1,500);
[x1,y1]=meshgrid(a,b);
z1 = sqrt(x1.^2+y1.^2);z1(z1>0.5005)=NaN;
z(z<0.5)=NaN;surf(x,y,z,'FaceColor','r','FaceAlpha',0.2,'EdgeColor','none');hold on;
surf(x1,y1,z1,'FaceColor','g','FaceAlpha',0.2,'EdgeColor','none');
112
REFERENCES
Jame Stewart Calculus 7E
113
INDEX
1. Theory…………………………………………………………………………………………Page 1 – 18
2. Solution and Code………………………………………………………..……………Page 19 – 112
3. References……………………………………………………………………………………Page 113
114