(123doc) Calculus 2 Assignment Report
(123doc) Calculus 2 Assignment Report
(123doc) Calculus 2 Assignment Report
CALCULUS 2
REPORT
Instructor: Đậu Thế Phiệt
Student name ID
Huỳnh Dương Gia Bả o 2252063
Nguyễn Khá nh Duy 2252117
Phù ng Nhậ t Huy 2252261
Tạ Anh Huy 2211272
Đỗ Quang Sinh 2252715
Lê Huỳnh Phú c 2252634
Trầ n Tấ n Tà i 2252728
Võ Minh Thă ng 2252762
2|Page
Contents
A. Introduction ..........................................................................................................3
B. Problem:
I. Problem 1..........................................................................................4
C. Conclusion ....................................................................................................31
3|Page
Ho Chi Minh City University of Technology
Faculty of Applied Science
A. INTRODUCTION
4|Page
Ho Chi Minh City University of Technology
Faculty of Applied Science
B. PROBLEMS
I. Problem 1
Let z=f ( x ) =x2 +2 y 2 +3 x y 3− y3
(b) Draw the contour plot of the function. Point out the local extreme and the saddle
point on that figure.
(c) Find the exact local extreme and saddle point (using calculus technique).
Theory:
We all know that the main uses of ordinary derivatives are to find maximum and minimum
values (extreme values). Similar with multivariable functions, we can use partial derivatives
to do the same thing.
Suppose we have a two-variable function f that is continuous on the interval (a ,b) and it is said
that:
A function f of two variables has a local maximum at (a ,b) if :
f (x , y )≤ f (a , b)
This means that f (x , y )≤ f (a , b) for all points (x , y ) in some disk with center (a ,b).
The number f (a , b) is called a local maximum value. If f (x , y )≥ f (a , b) when (x , y ) is
near (a ,b), then f has a local minimum at (a ,b) and f (a , b) is a local minimum value.
If the inequalities in the above definition hold for all points (x, y) in the domain of f then f
has an absolute maximum or local minimum at (a, b).
Therefore, If f has a local maximum or minimum at (a, b) and the first-order partial
derivatives of f exist at that point. And then
{f x (a , b )=0
f y ( a ,b )=0
But in some problems, there is a point called saddle point which located at the origin. Thus,
we have another tool called Second Derivatives Test to determine which points are
minimum, maximum and saddle.
Assume that the second partial derivatives are continuous on a disk with center (a, b), and
suppose:
5|Page
Ho Chi Minh City University of Technology
Faculty of Applied Science
{f x ( a , b )=0
f y ( a , b )=0
Let:
2
D ( a , b ) =f xx ( a , b ) . f yy ( a , b )−[ f xy ( a , b ) ]
If {fD>0<0 , then
xx
f ( a , b ) is the local maximum.
If D<0 , then f (a , b) is not a local extrema, the point (a ,b) is called a saddle point of f
Note: If D=0, the test tells no information. f could have a local maximum or local
minimum at (a ,b), or (a ,b) could be a saddle point of f .
Hand-writing solution:
Find the local extreme values of the function f (x , y )=x 2 +2 y 2+3 x y 3− y 3
- Firstly, we have to determine critical points for the given function f (x , y ) by
finding the partial derivatives with respect to x and to y and set each
partial derivative equal to zero.
{
' 3
f x =2 x +3 y
f y =4 y+ 9 x y 2−3 y 2
'
6|Page
Ho Chi Minh City University of Technology
Faculty of Applied Science
- We then have the system of equations:
{
3
2 x+ 3 y =0(1)
2 2
4 y + 9 x y −3 y =0 (2)
−3 3
x= y (4)
2
4 y +9 ( −32 y ) y −3 y =0
3 2 2
y ( −272 y −3 y + 4)=0
4
- Solve the equation for y and substitute the value to the equation (4):
y=0⇒ x=0
y=0.629⇒ x=−0.373
y=−0.833 ⇒ x=0.867
- We have:
{
f xx =2
2
f xy =9 y
f yy =4 +18 xy−6 y
- Therefore:
4
D ( x 0 , y 0 ) =−81 y +36 xy−12 y +8 (5)
7|Page
Ho Chi Minh City University of Technology
Faculty of Applied Science
At (0,0):
– D ( 0 , 0 )=8 >0
– f yy ( 0 , 0 )=2>0
⇒ f (0 , 0) is a local minimum.
At (-0.373,0.629):
MATLAB code:
% calculation
syms x y z
% differentiate z
eqns = [ fx == 0 , fy == 0];
vars = [ x y ];
8|Page
Ho Chi Minh City University of Technology
Faculty of Applied Science
soly_real = soly ( imag ( solx ) ==0) ;
% display section
%c
if D > 0
if fxx_val > 0
9|Page
Ho Chi Minh City University of Technology
Faculty of Applied Science
fprintf ('Therefore this is a local minimum point \n ')
else
end
else if D < 0
fprintf ('Therefore point (%s ,%s) is a saddle point \n ', solx_real ( n ) , soly_real ( n )
)
else
fprintf ('So conclusion for point (%s ,%s) \n ', solx_real ( n ) , soly_real ( n ) )
end
end
Code explanation:
neously, which are the first-order partial derivative equations set to zero.
10 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
vars = [x y]; - defines the variables to be solved for as x and y.
[solx, soly] = vpasolve(eqns, vars); - solves the system of equations eqns for the
variables vars and returns the solutions in the vectors solx and soly.
solx_real = solx(imag(solx)==0); - extracts the real parts of the solutions for solx
and assigns them to solx_real.
for n=1:length(solx_real) - starts a loop over the number of real solutions found.
vpasolve(); - function is used to solve the system of equations eqns for the variables
vars, which are x and y in this case.
11 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
Graph of the function z=f ( x ) =x 4−2 x 2− y 3 +3 y
syms x y z
[x , y ] = meshgrid ( -1:0.05:1 , -1:0.05:1) ;
z = x .^2 + 2* y .^2 + 3* x .* y .^3 - y .^3;
% plot 2 figure in 1 window
tiledlayout (2 ,1) ;
%a
nexttile
surf (x ,y ,z , 'edgecolor ', 'none ') ;
colormap hot ; %the higher value , the hotter color
xlabel ('x') ;
ylabel ('y') ;
zlabel ('z') ;
title ('GRAPH OF THE FUNCTION ')
pbaspect ([1 ,1 ,1])
%b
nexttile
contour (x ,y ,z ,200)
hold on
for n =1: length ( solx_real )
plot ( solx_real ( n ) , soly_real ( n ) , '*')
end
xlabel ('x') ;
ylabel ('y') ;
title ({ 'CONTOUR PLOT THE FUNCTION , ','LOCAL EXTREME AND SADDLE POINT ' })
pbaspect ([1 ,1 ,1])
12 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
The contour plot the function z=f ( x ) =x 4−2 x 2− y 3 +3 y along with the local
extreme and saddle point
Code explanation:
meshgrid() - generate a grid of x and y values to plot the surface and contour plots of the
function.
tiledlayout() - create a tiled layout for plotting multiple figures in one window
nexttile() - specify the location of the next plot in the tiled layout.
contour() - create a contour plot of the function. It takes x, y, and z matrices as input, and
creates contour lines at different function values.
for loop - plot the location of the local extreme and saddle points on the contour plot.
13 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
II. Problem 2
Find the maximum and minimum values of z=2 x 2−2 xy + y 3 subject to the single constraint
x2 +y2 = 4.
(b) Using contour plot (Draw the contour plot of the function and the constraint curve in the same
figure).
Theory:
To find the maximum and minimum value of f ( x , y )=2 x 2−2 xy + y 3 subject to the single
constraint g(x , y)= x2 + y 2=4 , we need to use the Lagrange multiplier method.
Lagrange multiplier method is a technique for finding maximum or minimum values of some
multivariable function f (x , y , z , ...) subject to a constraint of the form g(x , y , z ,...).
For example, a function of 2 variables can be used to explain the method. We get started by
finding the extreme values of f (x , y ) subject to a constraint g(x , y). In other words, we find the
points satisfying the condition that points (x , y ) lie on the level curve g(x , y)=k . The figure below
shows this curve together with several level curves of f (x , y ). These have the equations
f (x , y )=c where c ∈{7 ,8 ,9 , 10 , 11}.
14 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
The graph illustrates that the maximum value occupied at the point where f (x , y )=10 intersecting
g(x , y)=k . Analyzing the graph, we can easily see the fact that the maximum value appears when
those 2 functions touch each other and they have the same tangent line. Thus the normal lines at
the point of intersection (x0, y0) are identical. So the gradient vectors are parallel; Therefore,
∇ f (x 0 , y 0)=λg(x 0 , y 0)
where λ is a scalar.
For some scalar λ. The scalar parameter is called a Lagrange multiplier. The procedure based on
the above equation is as follows. We have from the chain rule,
df ( x , y ) ∂ f ( x , y ) ∂f (x , y) dg ( x , y ) ∂ g ( x , y ) ∂g(x , y)
= dx+ dy , = dx + dy
dxdy ∂x ∂y dxdy ∂x ∂y
Multiplying the second equation by λ and then add to first equation yield:
( ∂f (x , y ) ∂g(x , y)
∂x
+
∂x ) (
dx+
∂f (x , y) ∂g(x , y )
∂y
+
∂y
dy=0 )
Then we can rewrite the expression as the vector equation:
∇ f (x 0 , y 0)=λg(x 0 , y 0)
Thus, the maximum and minimum values of f (x , y ) subject to the constraint g(x 0 , y 0)=0can be
found by solving the following set of equations.
{
∂ f (x , y ) ∂ g ( x , y )
+ =0
∂x ∂x
∂ f (x , y ) ∂ g ( x , y )
+ =0
∂y ∂y
g ( x , y ) =0
The Lagrange multiplier method allows us to find the values of the variables that optimize the
objective function subject to the given constraints. This technique is widely used in various fields of
mathematics, physics, and engineering, particularly in optimization problems involving constraints.
14 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
2 3
Let f ( x , y )=z=2 x −2 xy+ y and g( x , y)= x2 + y 2 – 4
{
4 x−2 y +2 λx=0(1)
−2 y+ 3 y 2 +2 λy=0 (2)
x 2+ y2 −4=0(3)
2 4
⟹y =
1
1+
( 2+ λ )2
2
⟹ y=±
−2
√ 1+
1
( 2+ λ )
2
y=
Plug
√ 1+
1 to equation (4) then we obtain:
( 2+ λ )
2
4 −2 −4
3 +2λ − =0
√ √
1
( 2+1 λ )
2
1+ 1
1+ ( 2+ λ ) 1+
( 2+ λ )2 ( 2+ λ )
2
15 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
2
y=
With
√ 1+
1 we have another equation:
( 2+ λ )
2
4 2 4
3 +2λ − =0
√ √
1
( 2+1 λ )
2
1+ 1
1+ ( 2+ λ ) 1+
( 2+ λ )2 ( 2+ λ )
2
λ=−1.03873∧λ=−3.1317
−2 −2
y= = =−1.96318
√ 1+
1
( 2+ λ )
2
√ 1+
1
( 2+3.13935 )
2
y −1.96318
x= = =−0.38199
2+ λ 2+3.13935
With λ=−2.31197 :
−2 −2
y= = =−0.595631
√ 1+
1
( 2+ λ )
2
√ 1+
1
( 2−2.31197 )
2
y −0.595631
x= = =1.90925
2+ λ 2−2.31197
With λ=−1.03873
−2 −2
y= = =1.38602
√ 1+
1
( 2+ λ )
2
√ 1+
1
( 2−1.03873 )
2
16 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
y 1.38602
x= = =1.44186
2+ λ 2−1.03873
17 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
With λ=−3.1317 :
−2 −2
y= = =1.49874
√ 1+
1
( 2+ λ )
2
√ 1+
1
( 2−3.1317 )
2
y 1.38602
x= = =−1.3243
2+ λ 2−3.1317
After obtaining all value of x , y in each case of λ , we evaluate f at all the point (x,y). The largest of those
values is the maximum value of f ; the smallest is the minimum value of f
2 3
f (−0.38199 ,−1.96318 )=2 (−0.38199 ) −2 (−0.38199 ) (−1.96318 ) + (−1.96318 )
¿−8.77424
2 3
f ( 1.90925 ,−0.595631 )=2 ( 1.90925 ) −2 ( 1.90925 ) (−0.595631 ) + (−0.595631 )
¿ 9.35357
2 3
f ( 1.44186 ,1.38602 )=2 ( 1.44186 ) −2 ( 1.44186 )( 1.38602 ) + ( 1.38602 )
¿ 2.82364
2 3
f (−1.3243 , 1.49874 )=2 (−1.3243 ) −2 (−1.3243 ) ( 1.49874 ) + ( 1.49874 )
¿ 10.8436
Therefore:
MATLAB code:
This MATLAB code demonstrates how to plot the contour of a function and a
constraint curve in the same figure. Specifically, the function is z=2 x 2−2 xy + y 3 and the
constraint curve x 2+ y 2=4 in the same figure.
18 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
x = linspace ( -5 , 5 , 100) ;
y = linspace ( -5 , 5 , 100) ;
[X , Y ] = meshgrid (x , y ) ;
Z = 2* X .^2 - 2* X .* Y + Y .^3;
% Set labels
xlabel ('x') ;
ylabel ('y') ;
title ('Contour plot of z = 2x^2 - 2xy + y^3 and constraint x^2 + y^2 = 4') ;
19 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
The contour plot of function z=2 x 2−2 xy + y 3 and the constraint x 2+ y 2=4
Code explanation:
theta = linspace(0, 2*pi, 100) - create a 1x100 row vector θ of equally spaced values between
0 and 2π radians with 100 elements.
x_circle = r*cos(theta) - compute the x-coordinates of the circle using the cos function and θ.
y_circle = r*sin(theta) - compute the y-coordinates of the circle using the sin function and θ.
20 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
III. Problem 3
Let C be the intersection of the surface x 2+ y 2+ z 2=9 and the cylinder
x + 3 y =4 , z > 0.
2 2
where {f isacontinous
≤ x≤b
We obtain a polygonal approximation to C by dividing the interval [a , b] into n
subintervals with endpoints x 0 , x 1 ,... , x n and equal with ∆ x . If y i=f (x i), and then the
point Pi (x , y ) lies on C and the polygon with vertices P0 , P 1 , ... , P n, Illustrated in the
below figure, is an approximation to C.
The length L of is approximately the length of this polygon and the approximation gets better as
we let n increase. Therefore we define the length L of the curve C with equation y=f (x ),a ≤ x ≤ b
, as the limit of the lengths of these inscribed polygons (if the limit exists):
n
L=lim ∑ ¿ Pi−1 P i∨¿ ¿
n → ∞ i=1
21 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
By applying the Mean Value Theorem to f on the interval [ x i−1 , x i ] , we find that there exist a number
x i between x i−1 and x isuch that
¿
By the definition, this integral exists because the function g ( x )= 12+ [ f ' ( x ) ] is continuous. Thus we √ 2
have proved the following theorem: If f 'is continuous on [a,b], then the length of the curve y=f (x ) ,
a ≤ x ≤ b , is
b
a
√
L=∫ 1 + [ f ( x ) ] dx
2 ' 2
Then we have another assumption that C can be described by the parametric equations x=f ( t ) and
dx '
y=g ( t ), α ≤ x ≤ β ,where =f ( t ) > 0. This means that C is traversed once, from left to right, as t
dt
increased from α to β and f ( α )=a, f ( β )=b. We obtain:
√(
b β
√ )( )
dx 2 dy 2
2
L=∫ 1 + [ f ( x ) ] dx =∫
2 '
+ dx
a α dt dt
The length of space curve is defined in exactly the same way. Suppose that the curve has the
vector equation r (t )=⟨ f (t), g(t),h (t)⟩ , a ≤ x ≤ b, or, equivalently, the parametric equations
x=f (t), y=g(t ), z=h (t), where f ' , g ' and h ' are continuous. If the curve is traversed exactly once
as t increases from a to b, then it can be shown that its length is
√(
b β
√ [ f ( x ) ] + [ g ( x ) ] +[ h ( x ) ] dx=∫ )( )( )
dx 2 dy 2 dz 2
2 2 2
L=∫ ' ' '
+ + dt
a α dt dt dt
22 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
Tangent vectors:
In mathematics, a tangent vector is a vector that is tangent to a curve or surface at a given point.
Tangent vectors are described in the differential geometry of curves in the context of curves in R n.
More generally, tangent vectors are elements of a tangent space of a differentiable manifold. Tangent
vectors can also be described in terms of germs. Formally, a tangent vector at the point x is a linear
derivation of the algebra defined by the set of germs at x .
Let r (t ) be a parametric smooth curve. The tangent vector is given by r ' ( t ) where we have used a
prime instead of the usual dot to indicate differentiation with respect to parameter t . The unit
tangent vector is given by
'
r (x )
T ( x )=
|r ( x )|
MATLAB Code:
The surface of x + y + z =9 2 2 2
23 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
24 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
25 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
26 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
syms t ;
X = cos ( t ) .*2;
Y = sin ( t ) .*(2/ sqrt (3) ) ;
Z = sqrt (9 - 4.* cos ( t ) .^2 - 4/3.* sin ( t ) ^2) ; % calculate the z-coordinate of the curve
curveC = fplot3 (X , Y , Z , [ 0 2* pi ] , 'linewidth ', 3) ;
curveC . Color = 'b'; % plot the curve with blue color
daspect ([1 1 1]) % set the aspect ratio of axes to 1 1 1
xlabel ('x') ;
ylabel ('y') ;
zlabel ('z') ;
title (" The intersection curve C of two surfaces ") ;
27 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
Hand-writing solution:
{
x=2 cos t
2
y= sin t (1)
√3
0≤t≤2π
√ 2 4
z= 9−4 cos ( x ) − sin ( t )
3
2
{√
x=2 cos t
2
y= sin t
√3 (2)
4
z= 9−4 cos ( x )2− sin ( t )2
3
√(
2π
L=∫
0 dt) ( )( )
dx 2 dy 2 dz 2
+
dt
+
dt
dt
2π
¿∫ √ ¿ ¿ ¿ ¿
0
¿ 10.3677
28 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
Solving by MATLAB:
func = @( x ) sqrt (( -2.* sin ( x ) ) .^2 + (2./ sqrt (3) .* cos ( x ) ) .^2 + (((8/3) .* cos ( x) .* sin ( x ) ) ./
sqrt ((8/3) .* sin ( x ) .^2 + 5) ) .^2) ;
% Use the integral function to evaluate the integral of the integrand over the interval [0 , 2pi]
Result:
{√
x=2 cos(t)
2
y = sin (t)
√3 (3)
2 4
z= 9−4 cos ( x ) − sin (t)2
3
Let
r ( t )=2 cos ( t ) i⃗ +
2
√3 √ 2 4
sin ( t ) ⃗j + 9−4 cos ( x ) − sin ( t ) ⃗k
3
2
29 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
2 8 sin(t)cos (t)
r ' ( t ) =−2sin ( t ) ⃗i + cos ( t ) ⃗j+ ¿
√3 3¿¿¿
Code explanation:
l = sqrt(x.∧ 2 + y.∧ 2 + z.∧ 2) - calculates the length of the unit tangent vector at each
point on the curve.
m = -2*sin(t)./l - calculates the x-component of the unit tangent vector at each point on
the curve.
n = (2/sqrt(3).*cos(t))./l - calculates the y-component of the unit tangent vector at each
point on the curve.
p = (8.*cos(t).*sin(t))./sqrt(3.*(8.*sin(t).∧ 2 + 15))./l - calculates the z-component of
the unit tangent vector at each point on the curve.
quiver3(x_t, y_t, z_t, m, n, p) - plots the unit tangent vector at each point on the curve as
an arrow.
31 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
C. Conclusion
In conclusion, this report has presented the main findings and
recommendations of our project in solving three problems at Calculus 2 and
using the MATLAB for sketching the graph of curve and calculating the
values in each problem. We would like to thank our assistant teacher,
Mr.Phiet , for his valuable guidance and feedback throughout the course of
this project. He has been very supportive and helpful in clarifying our
doubts and providing us with useful resources and suggestions. His
expertise and experience have greatly enhanced the quality and rigor of our
work. We are grateful for his time and effort in mentoring us.
32 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
33 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
34 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
35 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
36 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
37 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
38 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
39 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
40 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
41 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
42 | P a g e
Ho Chi Minh City University of Technology
Faculty of Applied Science
43 | P a g e