tutorial8
tutorial8
% Question 1
% Define system variables
syms x y
% Define the function
f1 = (x^3) * (y^2) * (12-x-y)
f1 =
p = diff(f1, x)
p =
q = diff(f1, y)
q =
r = diff(p, x)
r =
s = diff(p, y)
s =
t = diff(q, y)
t =
critical_points =
1
for i = 1:length(critical_point_x)
% Current critical point
current_points = [critical_point_x(i), critical_point_y(i)]
% Hessian determinant
disp('h = r*t - (s^2)')
h1 = r1 * t1 - (s1^2)
current_points =
r1 =
s1 =
t1 =
h = r*t - (s^2)
h1 =
The function has a local maximum at this point.
current_points =
r1 =
s1 =
t1 =
h = r*t - (s^2)
h1 =
The second derivative test is inconclusive. (Test Fails)
% Question 2
% Define system variables
syms x y
% Define the function
f2 = (x^2)+(y^2)-6*x+12
f2 =
2
% First-order partial derivatives
disp('First-order partiral derivatives: ')
p = diff(f2, x)
p =
q = diff(f2, y)
q =
r = diff(p, x)
r =
s = diff(p, y)
s =
t = diff(q, y)
t =
critical_points =
for i = 1:length(critical_point_x)
% Current critical point
current_points = [critical_point_x(i), critical_point_y(i)]
% Hessian determinant
disp('h = r*t - s^2')
h2 = r2 * t2 - (s2^2)
3
% Classification of critical point
if (h2 > 0 && r2 > 0)
disp('The function has a local minimum at this point.');
elseif (h2 > 0 && r2 < 0)
disp('The function has a local maximum at this point.');
elseif (h2 < 0)
disp('The function has a saddle point at this point.');
else
disp('The second derivative test is inconclusive. (Test Fails)');
end
end
current_points =
r2 =
s2 =
t2 =
h = r*t - s^2
h2 =
The function has a local minimum at this point.
% Question 3
% Define system variables
syms x y
% Define the function
f3 = (x^2)+(y^2)-x*y-2*x-y
f3 =
p = diff(f3, x)
p =
q = diff(f3, y)
q =
r = diff(p, x)
4
r =
s = diff(p, y)
s =
t = diff(q, y)
t =
critical_points =
for i = 1:length(critical_point_x)
% Current critical point
current_points = [critical_point_x(i), critical_point_y(i)]
% Hessian determinant
disp('h = r*t - s^2')
h3 = r3 * t3 - (s3^2)
current_points =
r3 =
s3 =
5
t3 =
h = r*t - s^2
h3 =
The function has a local minimum at this point.
% Question 4
% Define system variables
syms x y
% Define the function
f4 = (x^2) * (y^3) * (1-x-y)
f4 =
p = diff(f4, x)
p =
q = diff(f4, y)
q =
r = diff(p, x)
r =
s = diff(p, y)
s =
t = diff(q, y)
t =
6
critical_points =
for i = 1:length(critical_point_x)
% Current critical point
current_points = [critical_point_x(i), critical_point_y(i)]
% Hessian determinant
disp('h = r*t - s^2')
h4 = r4 * t4 - (s4^2)
current_points =
r4 =
s4 =
t4 =
h = r*t - s^2
h4 =
7
current_points =
r4 =
s4 =
t4 =
h = r*t - s^2
h4 =
The second derivative test is inconclusive. (Test Fails)
% Question 5
% Define system variables
syms x y
% Define the function
f5 = (x^3)+x*(y^2)-12*(x^2)+21*x-2*(y^2)
f5 =
p = diff(f5, x)
p =
q = diff(f5, y)
q =
r = diff(p, x)
r =
s = diff(p, y)
s =
t = diff(q, y)
t =
8
[critical_point_x, critical_point_y] = solve([p == 0, q == 0], [x, y]);
critical_points = [critical_point_x, critical_point_y]
critical_points =
for i = 1:length(critical_point_x)
% Current critical point
current_points = [critical_point_x(i), critical_point_y(i)]
% Hessian determinant
disp('h = r*t - s^2')
h5 = r5 * t5 - (s5^2)
current_points =
r5 =
s5 =
t5 =
h = r*t - s^2
h5 =
The function has a local maximum at this point.
current_points =
r5 =
s5 =
t5 =
h = r*t - s^2
h5 =
The function has a local minimum at this point.
9
current_points =
r5 =
s5 =
t5 =
h = r*t - s^2
h5 =
The function has a saddle point at this point.
current_points =
r5 =
s5 =
t5 =
h = r*t - s^2
h5 =
The function has a saddle point at this point.
10