0% found this document useful (0 votes)
41 views114 pages

Math Lab Project

The document is a report on a Calculus 2 project conducted by a group of students at Ho Chi Minh City University of Technology. It covers theoretical concepts related to double and triple integrals, including methods for calculating volumes and applications in mechanics. Additionally, it includes a practical example using Lagrange multipliers to find extreme values of a function, along with corresponding MATLAB code for visualization.

Uploaded by

hanhuynhngoc1405
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views114 pages

Math Lab Project

The document is a report on a Calculus 2 project conducted by a group of students at Ho Chi Minh City University of Technology. It covers theoretical concepts related to double and triple integrals, including methods for calculating volumes and applications in mechanics. Additionally, it includes a practical example using Lagrange multipliers to find extreme values of a function, along with corresponding MATLAB code for visualization.

Uploaded by

hanhuynhngoc1405
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 114

HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY-VNU HCMC

OFFICIAL FOR INTERNATIONAL STUDY PROGRAMS

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

Ho Chi Minh, 9th May 2023

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

In a similar manner we consider a function of two variables defined on a closed rectangle

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,

Volume and double integrals

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

each with area ∆A =


∆x ∆y
choosing a sample point in
each , we can approximate
the part of that lies above
each by a thin rectangular
box (or “column”) with
base and height .The
volume of this box is the
height of the box times the
area of the base rectangle:

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

The midpoint rule:

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,

where A(R) is the area of R.


If f(x,y) ≥ 0 , the equation

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.

If we now integrate the function with respect to x from x = a to x = b

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

More generally, this is true if we assume that is bounded on , is discontinuous only on a


infinite number of smooth curves, and the iterated integrals exist.

Double intergrals over general regions:

If F is integrable over R, then we defifine the double integrals of f over D by

A plane region is said to be of Type I if it lies between the graphs of two continuous
functions of x, that is,

We also consider plane regions of Type II , which can be expressed as

11
Double integrals in polar coordinates

In terms of rectangular coordinates is rather complicated, but R is easily described using


polar coordinates.
If f is continuous on a polar rectangle R given by 0 ≤ a ≤ r ≤ b, α ≤ θ ≤ β, where 0 ≤
β − α ≤ 2π
, then

In terms of more complicated type of region, we can use the formula


If is continuous on a polar region of the form

Apply cation of double integrals


Density and mass

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

Let f (x, y, x) be a function defined on the bounded solid V of R 3 . We divide V into n


subsolids V1, V2, . . . , Vn. Suppose ∆Vk be the volume of the subsolid Vk where k = 1, 2, .
. . , n. Denote λ as a maximum diameter of these subsolids. In the subsolid Vk we choose
an arbitrary point (xk , yk , zk ). Compute the sum:
𝑛

𝜎𝑛 = ∑ 𝑓(𝑥𝑘 , 𝑦𝑘 , 𝑧𝑘 )∆𝑉𝑘
𝑘=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:

∭ 𝑓(𝑥, 𝑦, 𝑧)𝑑𝑉 = ∭ 𝑓(𝑥, 𝑦, 𝑧)𝑑𝑥𝑑𝑦𝑑𝑧

• Evaluate Triple Integrals

13
In particular, if the projection of onto the -plane is a type I plane region, then:

𝑎≤𝑥≤𝑏
𝐸 = {(𝑥, 𝑦, 𝑧)| 𝑔1 (𝑥) ≤ 𝑦 ≤ 𝑔2 (𝑥) }
ℎ1 (𝑥, 𝑦) ≤ 𝑧 ≤ ℎ2 (𝑥, 𝑦)

If, on the other hand, is a type II plane region, then:

14
𝑐≤𝑦≤𝑑
𝐸 = {(𝑥, 𝑦, 𝑧)| 𝑢1 (𝑥, 𝑦) ≤ 𝑧 ≤ 𝑢2 (𝑥, 𝑦)}
ℎ1 (𝑦) ≤ 𝑥 ≤ ℎ2 (𝑦)

• Applications of Triple Integrals


𝑏
Recall that if 𝑓(𝑥) ≥ 0 , then the single integral∫𝑎 𝑓(𝑥)𝑑𝑥 represents the area under the
curve
𝑦 = 𝑓(𝑥) from a to b , and if 𝑓(𝑥, 𝑦) ≥ 0 , then the double integral ∬ 𝑓(𝑥, 𝑦)𝑑𝐴 represents
the volume under the surface 𝑧 = 𝑓(𝑥, 𝑦) and above D . The corresponding interpretation
of a triple integral ∭ 𝑓(𝑥, 𝑦, 𝑧)𝑑𝑉 , where 𝑓(𝑥, 𝑦, 𝑧) ≥ 0 , is not very useful because it
would be the “hypervolume” of a four-dimensional object and, of course, that is very
difficult to visualize. (Remember that E is just the domain of the function f ; the graph of f
lies in four-dimensional space.) Nonetheless, the triple integral ∭ 𝑓(𝑥, 𝑦, 𝑧)𝑑𝑉 can be
interpreted in different ways in different physical situations, depending on the physical
interpretations of x,y,z and 𝑓(𝑥, 𝑦, 𝑧) . Let’s begin with the special case where 𝑓(𝑥, 𝑦, 𝑧) =
1 for all points in E . Then the triple integral does represent the volume of E:

• 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

And the coordinates of the center of mass are:

15
While:

• Triples Integrals in Cylindrical Coordinates

In the cylindrical coordinate system, a point P in three-


dimensional space is represented by the ordered triple (r, θ,
z), where r and θ are polar coordinates of the projection of P
onto the xy-plane and z is the directed distance from the xy-
plane to P.
To convert from cylindrical to rectangular coordinates, we
use the equations
x = r cos θ, y = r sin θ, z = z

• Evaluating Triple Integrals with Cylindrical Coordinates

If the solid V is given by :


V = {α ⩽ θ ⩽ β, h1(θ) ⩽ r ⩽ h2(θ), u1(x, y) ⩽ z ⩽ u2(x, y)}

16
• Triple Integrals in Spherical Coordinates

The spherical coordinates (ρ, θ, ϕ) of a point P in


space are shown in Figure, where ρ = |OP| is the
distance from the origin to P, θ is the same angle as
in cylindrical coordinates, and ϕ is the angle
between the positive z-axis and the line segment
OP. Note that

ρ ⩾ 0, 0 ⩽ θ ⩽ 2π, 0 ⩽ ϕ ⩽ π

The spherical coordinate system is especially


useful in problems where there is symmetry about a point, and the origin is placed at
this point. For example, the sphere with center the origin and radius c has the simple
equation ρ = c; this is the reason for the name “spherical” coordinates. The graph of the
equation θ = c is a vertical half-plane, and the equation ϕ = c represents a half-cone
with the z-axis as its axis. The relationship between rectangular and spherical
coordinates is given by x = ρ sin ϕ cos θ, y = ρ sin ϕ sin θ, z = ρ cos θ Also, the distance
formula shows that

𝝆𝟐 = 𝒙𝟐 + 𝒚𝟐 + 𝒛𝟐

Consequently, we have arrived at the following formula for triple integration in


spherical coordinates.

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.

Let's define the Lagrangian function L(x, y, λ) as:

L(x, y, λ) = x^2 + 2y^2 - λ(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

∂L/∂λ = x^2 + y^2 - 1 = 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.

If x = 0, then y^2 = 1, which means y = ±1. Similarly, if y = 0, then x^2 = 1, which


means x = ±1. So, we have four critical points: (-1, 0), (1, 0), (0, -1), and (0, 1).

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:

% Define the range of x and y

x = linspace(-1, 1, 100);

y = linspace(-1, 1, 100);

% Create a meshgrid of x and y

[X, Y] = meshgrid(x, y);

% Calculate the values of f(x, y) for each point in the meshgrid

Z = X.^2 + 2*Y.^2;

% Plot the surface using surf

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:

% Define the objective function

fun = @(x) x(1)^2 + 2*x(2)^2;

% Define the constraint function

nonlcon = @(x) x(1)^2 + x(2)^2 - 1;

% Set the options for fmincon

options = optimoptions('fmincon', 'Display', 'off');

% Find the minimum of the function subject to the constraint

21
[x_min, f_min] = fmincon(fun, [0; 1], [], [], [], [], [], [], nonlcon, options);

% Find the maximum of the function subject to the constraint

[x_max, f_max] = fmincon(@(x) -fun(x), [0; 1], [], [], [], [], [], [], nonlcon, options);

% Print the results

fprintf('Minimum value: %f at (%f, %f)\n', f_min, x_min(1), x_min(2));

fprintf('Maximum value: %f at (%f, %f)\n', -f_max, x_max(1), x_max(2));

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 λ:

∂L/∂x = 2xy + 2λx

∂L/∂y = x^2 + 4λy

∂L/∂λ = x^2 + 2y^2 - 6

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

% Define the function and the constraint

f = @(x,y) x.^2 .* y;

c = @(x,y) x.^2 + 2*y.^2 - 6;

23
% Create a grid of x and y values

x = linspace(-3, 3, 100);

y = linspace(-3, 3, 100);

[X, Y] = meshgrid(x, y);

% Compute the corresponding z values

Z = f(X, Y);

Z(c(X,Y)>0) = NaN; % remove values outside the constraint

% Plot the surface

figure;

surf(X, Y, Z);

xlabel('x');

ylabel('y');

zlabel('f(x,y)');

title('Surface Plot of f(x,y) = x^2 y on x^2 + 2y^2 = 6');

% Find the extreme values

x0 = [0, 0]; % initial guess

options = optimset('Display', 'iter', 'Algorithm', 'active-set');

[xmin, fmin] = fmincon(f, x0, [], [], [], [], [], [], c, options);

[xmax, fmax] = fmincon(@(x) -f(x(1), x(2)), x0, [], [], [], [], [], [], c, options);

fprintf('Minimum value: %f at (%f, %f)\n', fmin, xmin(1), xmin(2));

fprintf('Maximum value: %f at (%f, %f)\n', -fmax, xmax(1), xmax(2));

24
Graph

3/ Find the extreme values of function f(x,y)= 𝟔 − 𝟓𝒙 − 𝟒𝒚 on the circle 𝒙𝟐 + 𝒚𝟐 =


𝟗. Sketch the given surface and show the extreme values.

● HOW TO SOLVE:
f(x,y)=6 − 5𝑥 − 4𝑦
g(x,y)=𝑥 2 + 𝑦 2 = 9

𝑓(𝑥, 𝑦) =< 𝑓𝑥(𝑥, 𝑦), 𝑓𝑦(𝑥, 𝑦) > = < −5, −4 >

𝑔(𝑥, 𝑦) =< 𝑓𝑥(𝑥, 𝑦), 𝑓𝑦(𝑥, 𝑦) > = < 2𝑥, 2𝑦 >

Using the Langrange multiplier:

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

Thus, the function f(x,y) = 6 − 5𝑥 − 4𝑦has a maximum value of 6 + 3√41 and a


minimum value of 6 − 3√41 on the circle 𝑥 2 + 𝑦 2 = 9.
● MATLAB CODE

clc;

close all;

format compact

syms x y l d t result;

f = @(x,y) 6-5*x-4*y;

h = @(x,y) x^2 +y^2;

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);

[a,b,c] = solve ([e1, e2, e3], [x,y,l]);

26
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

4/Find the extreme values of function f(x,y)= 𝟏 − 𝟒𝒙 − 𝟖𝒚 on the circle 𝒙𝟐 + 𝟖𝒚𝟐 =


𝟖. Sketch the given surface and show the extreme values.
● HOW TO SOLVE:

27
f(x,y)=1 − 4𝑥 − 8𝑦
g(x,y)=𝑥 2 + 8𝑦 2 = 8

𝑓(𝑥, 𝑦) =< 𝑓𝑥(𝑥, 𝑦), 𝑓𝑦(𝑥, 𝑦) > = < −4, −8 >

𝑔(𝑥, 𝑦) =< 𝑓𝑥(𝑥, 𝑦), 𝑓𝑦(𝑥, 𝑦) > = < 2𝑥, 16𝑦 >

Using the Langrange multiplier:


f= g and 𝑥 2 + 8𝑦 2 = 8

-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

Thus, the function f(x,y) = 1 − 4𝑥 − 8𝑦has a maximum value of 1 + 8√3 and a


minimum value of 1 − 8√3 on the circle 𝑥 2 + 8𝑦 2 = 8.

● 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

5/ Find the extreme values of function f(x,y)= 𝒙𝟐 + 𝒚𝟐 + 𝒙𝒚 on the circle 𝒙𝟐 +


𝟐𝒚𝟐 = 𝟏. Sketch the given surface and show the extreme values.
● HOW TO SOLVE:

29
f(x,y)= 𝑥 2 + 𝑦 2 + 𝑥𝑦
g(x,y)=𝑥 2 + 2𝑦 2 = 1

𝑓(𝑥, 𝑦) =< 𝑓𝑥(𝑥, 𝑦), 𝑓𝑦(𝑥, 𝑦) > = < 2𝑥 + 𝑦, 2𝑦 + 𝑥 >

𝑔(𝑥, 𝑦) =< 𝑓𝑥(𝑥, 𝑦), 𝑓𝑦(𝑥, 𝑦) > = < 2𝑥, 4𝑦 >

Using the Langrange multiplier:


f= g
𝑥 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

Thus, the function f(x,y) = 𝑥 2 + 𝑦 2 + 𝑥𝑦has a maximum value of 1 and a


1
minimum value of 3 on the circle 𝑥 2 + 2𝑦 2 = 1.

● 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>

Using the Lagrange multiplier:


(1) f= g
(2)𝑥 2 + 4𝑦 2 = 25
⇔-4x+12y= 2x(*)
12x+2y= 12y(**)
2 2
𝑥 + 4𝑦 = 25 (***)
(*)(**)(***)=>x≈3.61 or x≈-3.61
y≈1.73 or y≈-1.73

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>

g(x,y) = <gx(x,y),gy(x,y)> = <1/2,1/3>

Using the Lagrange multiplier:


(1) f= g
(2)x/2 +y/3=1
⇔2x= 1/2(*)
2y= 1/3(**)
x/2 +y/3=1 (***)
(*)(**)(***)=>x≈1.38
y≈0,923
f(1.38,0.923)≈2.76

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

𝐷 = 𝑓𝑥𝑥 × 𝑓𝑦𝑦 − 𝑓𝑥𝑦 2

𝐷(0; 0) = -4 × −4 − 42 = 0
if(x,y)=(√2, −√2)or(−√2,√2) =>𝑓𝑥𝑥 =20,𝑓𝑦𝑦 = 20, 𝑓𝑥𝑦 = 4
𝑓𝑥𝑥 *𝑓𝑥𝑦 − 𝑓𝑥𝑦 2 = 384 > 0

=> 𝑓(𝑥; 𝑦) min at 𝑓(𝑥; 𝑦) = −8 𝑎𝑡 (√2, −√2)and(−√2,√2).

● 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:

H = [[24x^2 - 2, 0], [0, 12y^2 - 4]]

At (0, 0), we have:

H(0, 0) = [[-2, 0], [0, -4]], eigenvalues = [-2, -4]

Both eigenvalues are negative, so the point corresponds to a local maximum.

At (-1, 0), we have:

H(-1, 0) = [[22, 0], [0, 4]], eigenvalues = [22, 4]

One eigenvalue is positive and one is negative, so the point corresponds to a saddle
point.

At (1, 0), we have:

H(1, 0) = [[22, 0], [0, 4]], eigenvalues = [22, 4]

36
One eigenvalue is positive and one is negative, so the point corresponds to a saddle
point.

At (0, -1), we have:

H(0, -1) = [[-2, 0], [0, 8]], eigenvalues = [-2, 8]

One eigenvalue is positive and one is negative, so the point corresponds to a saddle
point.

At (0, 1), we have:

H(0, 1) = [[-2, 0], [0, 8]], eigenvalues = [-2, 8]

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)

(3)(4)=>(0,0) is saddle point.


𝑓𝑥𝑦 = 𝑓𝑥𝑦 (x,y) = (-2 + 4y - 2x)e^(x-y)

𝐷 = 𝑓𝑥𝑥 × 𝑓𝑦𝑦 − 𝑓𝑥𝑦 2 =1.082682

=> 𝑓(𝑥; 𝑦) ≈ 1.082682 max at (𝑥; 𝑦) = (−4; −2)

● 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

Fx= e2x +2(x+y2 +2y)e2x

Fx=0 -> e2x=0(no solution) or 2(x+y2 +2y)=-1-> x+y2+2y=- (1)

Fy=e2x(2y+2)
Fy=0-> 2y+2=0->y=-1

40
Substituting y=-1 for (1) we have x+1-2=- -> x=

We have point M( ;-1)

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

-> point M( ;-1) is a local minimum.

● MATLAB CODE

% Init

clc;

close all;

syms x y z;

f = @(x,y) ((x + y.^2 +2*y) * exp(2*x));

% Compute partial derivatives of f(x,y)

fx = diff(f,x);

fy = diff(f,y);

% Solve for critical points

[a, b] = solve([fx == 0, fy == 0], [x, y]);

% Compute second partial derivatives of f(x,y)

fxx(x,y) = diff(fx, x);

fyy(x,y) = diff(fy, y);

fxy(x,y) = diff(fx, y);

% Compute the discriminant delta(x,y)

delta(x,y) = fxx * fyy - fxy.^2;

% Display critical point information

41
for i=1:numel(a)

if delta(a(i),b(i)) < 0

fprintf('\nSaddle point: (%s,%s,%s)%f',a(i),b(i),f(a(i),b(i)));

elseif fxx(a(i),b(i)) > 0

fprintf('\nLocal minimum: f(%f',a(i)); fprintf(',%f',b(i)); fprintf(') =


%f',f(a(i),b(i)));

else

fprintf('\nLocal maximum: f(%f',a(i)); fprintf(',%f',b(i)); fprintf(') =


%f',f(a(i),b(i)));

end

end

% Plot the surface of f(x,y)

figure(1);

fsurf(f);

axis([-10 10 -10 10 -10 10]);

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

text(a(i),b(i),f(a(i),b(i)),'\leftarrow Saddle point','Color','r');

elseif fxx(a(i),b(i)) > 0

text(a(i),b(i),f(a(i),b(i)),'\leftarrow Local Min','Color','r');

else

text(a(i),b(i),f(a(i),b(i)),'\leftarrow Local Max','Color','r');

42
end

end

% Plot the contour lines

figure(2);

[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

text(a(i),b(i),'\leftarrow Saddle point','Color','r');

elseif fxx(a(i),b(i)) > 0

text(a(i),b(i),'\leftarrow Local Min','Color','r');

else

text(a(i),b(i),'\leftarrow Local Max','Color','r');

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 )

Fx=0 -> (x+y2)=-1-> x+y2=-2 (1)

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

Substituing point M for A B C we have A= ;B=0;C=2e->AC-B2=1>0

-> point M(-2;0) is a local minimum.


● MATLAB CODE

% Init

clc;

close all;

syms x y z;

44
f = @(x,y) ((x + y.^2 ) * exp(x/2))

% Compute partial derivatives of f(x,y)

fx = diff(f,x);

fy = diff(f,y);

% Solve for critical points

[a, b] = solve([fx == 0, fy == 0], [x, y]);

% Compute second partial derivatives of f(x,y)

fxx(x,y) = diff(fx, x);

fyy(x,y) = diff(fy, y);

fxy(x,y) = diff(fx, y);

% Compute the discriminant delta(x,y)

delta(x,y) = fxx * fyy - fxy.^2;

% Display critical point information

for i=1:numel(a)

if delta(a(i),b(i)) < 0

fprintf('\nSaddle point: (%s,%s,%s)%f',a(i),b(i),f(a(i),b(i)));

elseif fxx(a(i),b(i)) > 0

fprintf('\nLocal minimum: f(%f',a(i)); fprintf(',%f',b(i)); fprintf(') =


%f',f(a(i),b(i)));

else

fprintf('\nLocal maximum: f(%f',a(i)); fprintf(',%f',b(i)); fprintf(') =


%f',f(a(i),b(i)));

end

end

% Plot the surface of f(x,y)

45
figure(1);

fsurf(f);

axis([-10 10 -10 10 -10 10]);

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

text(a(i),b(i),f(a(i),b(i)),'\leftarrow Saddle point','Color','r');

elseif fxx(a(i),b(i)) > 0

text(a(i),b(i),f(a(i),b(i)),'\leftarrow Local Min','Color','r');

else

text(a(i),b(i),f(a(i),b(i)),'\leftarrow Local Max','Color','r');

end

end

% Plot the contour lines

figure(2);

[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');

46
if delta(a(i),b(i)) < 0

text(a(i),b(i),'\leftarrow Saddle point','Color','r');

elseif fxx(a(i),b(i)) > 0

text(a(i),b(i),'\leftarrow Local Min','Color','r');

else

text(a(i),b(i),'\leftarrow Local Max','Color','r');

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

Fx= 2x( − 1) - 2x (x2 + y2 ) =-2x ( +x2 + y2 -1)

Fy=2y( − 1) – 2y(x2 + y2 ) =-2y ( +x2 + y2 -1)

Fy=0 ->y ( +x2 + y2 -1)=0

Fx=0 ->x ( +x2 + y2 -1)=0


->x=0,y=0
We have point M(0;0)

A:fxx=-2 ( + x2(5 + 2y2 ) + y2-2x4-1)

B:fxy=4xy (x2 + y2 -2)

C:fyy=-2 ( + y2(5 + 2x2 ) + x2-2y4-1)

47
Substituing point M(0;0) for A B C we have A=0;B=0;C=0->AC-B2=0

Now we look at the function: x2 + y2 this make


So if x2 + =0 ->f(x,y)=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;

f = @(x,y) ((x.^2 + y.^2 ) * (exp(-x.^2-y.^2)-1));

% Compute partial derivatives of f(x,y)

fx = diff(f,x);

fy = diff(f,y);

% Solve for critical points

[a, b] = solve([fx == 0, fy == 0], [x, y]);

% Compute second partial derivatives of f(x,y)

fxx(x,y) = diff(fx, x);

fyy(x,y) = diff(fy, y);

fxy(x,y) = diff(fx, y);

% Compute the discriminant delta(x,y)

delta(x,y) = fxx * fyy - fxy.^2;

% Display critical point information

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)));

elseif fxx(a(i),b(i)) > 0

fprintf('\nLocal minimum: f(%f',a(i)); fprintf(',%f',b(i)); fprintf(') =


%f',f(a(i),b(i)));

else

fprintf('\nLocal maximum: f(%f',a(i)); fprintf(',%f',b(i)); fprintf(') =


%f',f(a(i),b(i)));

end

end

% Plot the surface of f(x,y)

figure(1);

fsurf(f);

axis([-10 10 -10 10 -10 10]);

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

text(a(i),b(i),f(a(i),b(i)),'\leftarrow Saddle point','Color','r');

elseif fxx(a(i),b(i)) > 0

text(a(i),b(i),f(a(i),b(i)),'\leftarrow Local Min','Color','r');

else

text(a(i),b(i),f(a(i),b(i)),'\leftarrow Local Max','Color','r');

end

end

49
% Plot the contour lines

figure(2);

[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

text(a(i),b(i),'\leftarrow Saddle point','Color','r');

elseif fxx(a(i),b(i)) > 0

text(a(i),b(i),'\leftarrow Local Min','Color','r');

else

text(a(i),b(i),'\leftarrow Local Max','Color','r');

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

Fx=0 -> x=0 or x=2

Fy=0 -> y=-1

We have point M(0;-1) and point N(2;-1)

A:fxx=6-6x

B:fxy=0

C:fyy=4

Substituing point M(0;-1) for A B C we have A=6>0;B=0;C=4->AC-B2=24>0

Point M(0;-1) is a local minimum

Substituing point N(2;-1) for A B C we have A=-6<0;B=0;C=4->AC-B2=-24<0

Point N(2;-1) is a saddle point

● MATLAB CODE

% Init

clc;

close all;

syms x y z;

f = @(x,y) (3*x.^2 + 2*y.^2 - x.^3 +4*y);

% Compute partial derivatives of f(x,y)

fx = diff(f,x);

fy = diff(f,y);

% Solve for critical points

[a, b] = solve([fx == 0, fy == 0], [x, y]);

% Compute second partial derivatives of f(x,y)

51
fxx(x,y) = diff(fx, x);

fyy(x,y) = diff(fy, y);

fxy(x,y) = diff(fx, y);

% Compute the discriminant delta(x,y)

delta(x,y) = fxx * fyy - fxy.^2;

% Display critical point information

for i=1:numel(a)

if delta(a(i),b(i)) < 0

fprintf('\nSaddle point: (%s,%s,%s)%f',a(i),b(i),f(a(i),b(i)));

elseif fxx(a(i),b(i)) > 0

fprintf('\nLocal minimum: f(%f',a(i)); fprintf(',%f',b(i)); fprintf(') =


%f',f(a(i),b(i)));

else

fprintf('\nLocal maximum: f(%f',a(i)); fprintf(',%f',b(i)); fprintf(') =


%f',f(a(i),b(i)));

end

end

% Plot the surface of f(x,y)

figure(1);

fsurf(f);

axis([-10 10 -10 10 -10 10]);

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

text(a(i),b(i),f(a(i),b(i)),'\leftarrow Saddle point','Color','r');

elseif fxx(a(i),b(i)) > 0

text(a(i),b(i),f(a(i),b(i)),'\leftarrow Local Min','Color','r');

else

text(a(i),b(i),f(a(i),b(i)),'\leftarrow Local Max','Color','r');

end

end

% Plot the contour lines

figure(2);

[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

text(a(i),b(i),'\leftarrow Saddle point','Color','r');

elseif fxx(a(i),b(i)) > 0

text(a(i),b(i),'\leftarrow Local Min','Color','r');

53
else

text(a(i),b(i),'\leftarrow Local Max','Color','r');

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

Substituing x=-y2 into the equation y=-x2

➔ We have y=-y4 ->y+y4 =0 ->y(1+y3 )=0 ->y=0 or y=-1


➔ y=0 ->x=0
➔ y=-1 ->x=-1
➔ Point M(-1;-1) and point N(0;0)

A:fxx=6x

B:fxy=3

C:fyy=6y

Substituing point M(-1;-1) for A B C we have A=-6<0;B=3;C=-6->AC-B2=36>0

➔ Point M(-1;-1) is a local maximum

54
Substituing point N(0;0) for A B C we have A=0;B=3;C=0->AC-B2=-3<0

➔ Point N(0;0) is a saddle point


● MATLAB CODE

% Init

clc;

close all;

syms x y z;

f = @(x,y) (x.^3 + 3 * x * y + y.^3);

% Compute partial derivatives of f(x,y)

fx = diff(f,x);

fy = diff(f,y);

% Solve for critical points

[a, b] = solve([fx == 0, fy == 0], [x, y]);

% Compute second partial derivatives of f(x,y)

fxx(x,y) = diff(fx, x);

fyy(x,y) = diff(fy, y);

fxy(x,y) = diff(fx, y);

% Compute the discriminant delta(x,y)

delta(x,y) = fxx * fyy - fxy.^2;

% Display critical point information

for i=1:numel(a)

if delta(a(i),b(i)) < 0

fprintf('\nSaddle point: (%s,%s,%s)%f',a(i),b(i),f(a(i),b(i)));

elseif fxx(a(i),b(i)) > 0

fprintf('\nLocal minimum: f(%f',a(i)); fprintf(',%f',b(i)); fprintf(') =


%f',f(a(i),b(i)));

55
else

fprintf('\nLocal maximum: f(%f',a(i)); fprintf(',%f',b(i)); fprintf(') =


%f',f(a(i),b(i)));

end

end

% Plot the surface of f(x,y)

figure(1);

fsurf(f);

axis([-10 10 -10 10 -10 10]);

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

text(a(i),b(i),f(a(i),b(i)),'\leftarrow Saddle point','Color','r');

elseif fxx(a(i),b(i)) > 0

text(a(i),b(i),f(a(i),b(i)),'\leftarrow Local Min','Color','r');

else

text(a(i),b(i),f(a(i),b(i)),'\leftarrow Local Max','Color','r');

end

end

% Plot the contour lines

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

text(a(i),b(i),'\leftarrow Saddle point','Color','r');

elseif fxx(a(i),b(i)) > 0

text(a(i),b(i),'\leftarrow Local Min','Color','r');

else

text(a(i),b(i),'\leftarrow Local Max','Color','r');

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

Fx=0 -> y=x3

Fy=0 -> x=y3

Substituing x=y3 into the equation y=x3

➔ We have y=y9 ->y( y8-1)=0 ->y=0 or y =1 or y=-1


➔ Y=0 -> x=0
➔ Y=1 ->x=1
➔ Y=-1 ->x=-1
➔ We have point M(0;0), point N(-1;-1), point P(1;1)

A:fxx=-12x2

B:fxy=4

C:fyy=-12y2

Substituing point M(0;0) for A B C we have A=0;B=4;C=0->AC-B2=-4<0

➔ Point M(0;0) is a saddle point

Substituing point M(0;0) for A B C we have A=-12<0;B=4;C=-12->AC-B2=140>0

➔ Point N(-1;-1) is a local maximum

Substituing point M(0;0) for A B C we have A=-12<0;B=4;C=-12->AC-B2=140>0

➔ Point N(1;1) is a local maximum


● MATLAB CODE

% Init

clc;

close all;

syms x y z;

f = @(x,y) (-x.^4 + 4 * y * x - y.^4);

% Compute partial derivatives of f(x,y)

fx = diff(f,x);

58
fy = diff(f,y);

% Solve for critical points

[a, b] = solve([fx == 0, fy == 0], [x, y]);

% Compute second partial derivatives of f(x,y)

fxx(x,y) = diff(fx, x);

fyy(x,y) = diff(fy, y);

fxy(x,y) = diff(fx, y);

% Compute the discriminant delta(x,y)

delta(x,y) = fxx * fyy - fxy.^2;

% Display critical point information

for i=1:numel(a)

if delta(a(i),b(i)) < 0

fprintf('\nSaddle point: (%s,%s,%s)%f',a(i),b(i),f(a(i),b(i)));

elseif fxx(a(i),b(i)) > 0

fprintf('\nLocal minimum: f(%f',a(i)); fprintf(',%f',b(i)); fprintf(') =


%f',f(a(i),b(i)));

else

fprintf('\nLocal maximum: f(%f',a(i)); fprintf(',%f',b(i)); fprintf(') =


%f',f(a(i),b(i)));

end

end

% Plot the surface of f(x,y)

figure(1);

fsurf(f);

axis([-10 10 -10 10 -10 10]);

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

text(a(i),b(i),f(a(i),b(i)),'\leftarrow Saddle point','Color','r');

elseif fxx(a(i),b(i)) > 0

text(a(i),b(i),f(a(i),b(i)),'\leftarrow Local Min','Color','r');

else

text(a(i),b(i),f(a(i),b(i)),'\leftarrow Local Max','Color','r');

end

end

% Plot the contour lines

figure(2);

[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

text(a(i),b(i),'\leftarrow Saddle point','Color','r');

elseif fxx(a(i),b(i)) > 0

60
text(a(i),b(i),'\leftarrow Local Min','Color','r');

else

text(a(i),b(i),'\leftarrow Local Max','Color','r');

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

Fx= 3x2 -6x

Fy=6y2 -6

Fx=0 -> x=0 or x=2

Fy=0 -> y=1 or y=-1

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

Substituing point M(0;1) for A B C we have A=-6<0;B=0;C=12->AC-B2=-72<0

➔ Point M(0;1) is a saddle point

Substituing point N(0;-1) for A B C we have A=-6<0;B=0;C=-12->AC-B2=72>0

➔ Point N(0;-1) is a local maximum

Substituing point P(2;1) for A B C we have A=6>0;B=0;C=12->AC-B2=72>0

➔ point (2;1) is a local minimum

Substituing point Q(2;-1) for A B C we have A=6>0;B=0;C=-12->AC-B2=-72<0

➔ Point N(2;-1) is a saddle point


● MATLAB CODE

% Init

clc;

close all;

syms x y z;

f = @(x,y) (x.^3 + 2 * y.^3 - 3 * x.^2 - 6 * y);

% Compute partial derivatives of f(x,y)

fx = diff(f,x);

fy = diff(f,y);

% Solve for critical points

[a, b] = solve([fx == 0, fy == 0], [x, y]);

% Compute second partial derivatives of f(x,y)

fxx(x,y) = diff(fx, x);

62
fyy(x,y) = diff(fy, y);

fxy(x,y) = diff(fx, y);

% Compute the discriminant delta(x,y)

delta(x,y) = fxx * fyy - fxy.^2;

% Display critical point information

for i=1:numel(a)

if delta(a(i),b(i)) < 0

fprintf('\nSaddle point: (%s,%s,%s)%f',a(i),b(i),f(a(i),b(i)));

elseif fxx(a(i),b(i)) > 0

fprintf('\nLocal minimum: f(%f',a(i)); fprintf(',%f',b(i)); fprintf(') =


%f',f(a(i),b(i)));

else

fprintf('\nLocal maximum: f(%f',a(i)); fprintf(',%f',b(i)); fprintf(') =


%f',f(a(i),b(i)));

end

end

% Plot the surface of f(x,y)

figure(1);

fsurf(f);

axis([-10 10 -10 10 -10 10]);

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');

elseif fxx(a(i),b(i)) > 0

text(a(i),b(i),f(a(i),b(i)),'\leftarrow Local Min','Color','r');

else

text(a(i),b(i),f(a(i),b(i)),'\leftarrow Local Max','Color','r');

end

end

% Plot the contour lines

figure(2);

[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

text(a(i),b(i),'\leftarrow Saddle point','Color','r');

elseif fxx(a(i),b(i)) > 0

text(a(i),b(i),'\leftarrow Local Min','Color','r');

else

text(a(i),b(i),'\leftarrow Local Max','Color','r');

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

We have x=rcos ; y=rsin -> 2y=2rsin = -> r=2sin (r ;0 )

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));

i2= 2*int(i1, theta, 0, pi);

disp( 'The surface area:')

disp(i2)

ezsurf(cos(theta), 1+ sin(theta),v)

hold on

grid on

[x, y, z]= sphere;

x=x*2;

y=y*2;

z=z*2;

figure

surf(x,y,z);

xlabel('X');

ylabel('Y');

zlabel('Z');

axis equal; hold off;

the surface area:

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

x 2 + y 2 + z 2 = 9 is the function of a sphere with radius 3


We have x=rcos ; y=rsin (r ;0 )

z= =

S= =6 =36π

● MATLAB CODE

% Define the sphere's radius

r = 2;

% Create a grid of points for the x, y, and z axes

[x, y, z] = sphere(25);

% Scale the grid by the radius

x = r * x;

y = r * y;

z = r * z;

% Plot the sphere

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);

disp('the surrface area is'),disp(a)

% 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

ezsurf(cos(u)*v, sin(u)*v, v, [0 2*pi 0 1,0])

axis equal;

xlabel('X');

ylabel('Y');

zlabel('Z');

the surface area:

-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)

%sketch the given region


[X,Y]=meshgrid(0:0.01:2);
Z=X;
Z(X>(4-Y.^2).^(1/2))=NaN;
surf(X,Y,Z,'FaceColor','c','FaceAlpha',0.5,'EdgeColor','none');
hold on;
surf(X,Y,0*Z,'FaceColor','b','FaceAlpha',0.5,'EdgeColor','none');
[X2,Z2]=meshgrid(0:0.01:2);
Y2=meshgrid(0:0.01:2);
Y2(Z2>X2)=NaN;
surf(X2,0*Y2,Z2,'FaceColor','g','FaceAlpha',0.5,'EdgeColor','none');
Y3= (4-X2.^2).^(1/2);

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)

%sketch the given region


[X,Y]=meshgrid(-1:0.005:1);
Z=X.^2+Y.^2;
Z(X.^2+Y.^2>1)=NaN;
surf(X,Y,Z,'FaceColor','g','FaceAlpha',0.5,'EdgeColor','none');
hold on;
Z2=2*X.^2+Y.^2;
Z2(X.^2+Y.^2>1)=NaN;
surf(X,Y,Z2,'FaceColor','b','FaceAlpha',0.5,'EdgeColor','none');
[X3,Z3]=meshgrid(-1:0.005:1);
Y3=(1-X3.^2).^(1/2);
Z3=Z3+1;
Y3(Z3>2*X3.^2+Y3.^2)=NaN;
Y3(Z3<X3.^2+Y3.^2)=NaN;
surf(X3,Y3,Z3,'FaceColor','g','FaceAlpha',0.5,'EdgeColor','none');
surf(X3,-Y3,Z3,'FaceColor','g','FaceAlpha',0.5,'EdgeColor','none');
xlabel('x-axis');
ylabel('y-axis');
zlabel('z-axis');

100
SOLUTION

0 ≤ 𝑧 ≤ 𝑟𝑠𝑖𝑛𝜃 𝑥 = 𝑟𝑐𝑜𝑠𝜃 ∀ 𝑥, 𝑦 ∈ 𝐷𝑥𝑦


𝑉={ 0≤𝑟≤1 𝑉 = { 𝑦 = 𝑟𝑠𝑖𝑛𝜃 𝑉 = { 𝑧1 ≤ 𝑧 ≤ 𝑧2
0 ≤ 𝜃 ≤ 𝜋 (𝑦 ≥ 0) 𝑧=𝑧 →0≤𝑧≤𝑦

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)

%sketch the given region


[X,Y]=meshgrid(-1:0.005:1,0:0.005:1 );
Z=Y;
Z(X.^2+Y.^2>1)=NaN;
surf(X,Y,Z,'FaceColor','g','FaceAlpha',0.5,'EdgeColor','none');
hold on;
surf(X,Y,Z*0,'FaceColor','r','FaceAlpha',0.5,'EdgeColor','none');
[Y,Z]=meshgrid(0:0.005:1);
X=(1-Y.^2).^(1/2);X1=-sqrt(1-Y.^2);
X(Z>Y)=NaN;X1(Z>Y)=NaN;
surf(X,Y,Z,'FaceColor','b','FaceAlpha',0.5,'EdgeColor','none');
surf(X1,Y,Z,'FaceColor','b','FaceAlpha',0.5,'EdgeColor','none');
xlabel('x-axis');
ylabel('y-axis');
zlabel('z-axis');

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)

%sketch the given region


[X,Y]=meshgrid(0:0.01:2);
Z=zeros(201,201)+1;
Z(Y>(2*X-X.^2).^(1/2))=NaN;
surf(X,Y,Z,'FaceColor','g','FaceAlpha',0.5,'EdgeColor','none');
hold on;
surf(X,Y,Z*0,'FaceColor','r','FaceAlpha',0.5,'EdgeColor','none');
[X,Z]=meshgrid(0:0.01:2);
Y=(2*X-X.^2).^(1/2);
Y(Z>1)=NaN;
surf(X,Y,Z,'FaceColor','b','FaceAlpha',0.5,'EdgeColor','none');
surf(X,0*Y,Z,'FaceColor','r','FaceAlpha',0.5,'EdgeColor','none');

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)

%sketch the given region


[X,Y,Z]=sphere(100);
surf(X,Y,Z,'FaceColor','r','FaceAlpha',0.8);
xlabel('x-axis');
ylabel('y-axis');
zlabel('z-axis');

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)

%sketch the given region


[X,Y,Z]=sphere(100);
Z(Z<0)=NaN;
surf(X,Y,Z,'FaceColor','r','FaceAlpha',0.5,'EdgeColor','none');hold on;
[x,y]=meshgrid(-1:0.001:1);
y(x.^2+y.^2-1>0)=NaN;
surf(x,y,0*y,'FaceColor','g','FaceAlpha',0.5,'EdgeColor','none');
xlabel('x-axis');
ylabel('y-axis');
zlabel('z-axis');

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)

%sketch the given region


[X,Y,Z]=sphere(100);
Z(Z<0)=NaN;
Z(X<0)=NaN;
Z(Y<0)=NaN;
surf(X,Y,Z,'FaceColor','g','FaceAlpha',0.5,'EdgeColor','none');
hold on;
X=X*2; Y=Y*2; Z=Z*2;
Z(Z<0)=NaN;
Z(X<0)=NaN;
Z(Y<0)=NaN;
surf(X,Y,Z,'FaceColor','r','FaceAlpha',0.5,'EdgeColor','none');
[X,Z]=meshgrid(0:0.01:2);
Y=meshgrid(0:0.01:2);
Y(X.^2+Z.^2>4)=NaN;
Y(X.^2+Z.^2<1)=NaN;

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)

%sketch the given region


[X,Y,Z]=sphere(100);
X=X*2; Y=Y*2; Z=Z*2;
Z(Z<2^(1/2)-0.01)=NaN;
surf(X,Y,Z,'FaceColor','r','FaceAlpha',0.5,'EdgeColor','none');
hold on;
Z=(X.^2+Y.^2).^(1/2);
Z(Z>2^(1/2)+0.01)=NaN;
surf(X,Y,Z,'FaceColor','b','FaceAlpha',0.5,'EdgeColor','none');

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)

%sketch the given region


[X,Y,Z]=sphere(100);
Z(Z<0)=NaN;
surf(X,Y,Z,'FaceColor','r','FaceAlpha',0.5,'EdgeColor','none');hold on;
[x,y]=meshgrid(-1:0.001:1);
y(x.^2+y.^2-1>0)=NaN;
surf(x,y,0*y,'FaceColor','g','FaceAlpha',0.5,'EdgeColor','none');
xlabel('x-axis');
ylabel('y-axis');
zlabel('z-axis');

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

You might also like