Assignment 1_checked
Assignment 1_checked
Calculation error.
ASSIGNMENT 1
Name: Ashutosh Mishra
Roll No: 121EE0337
SOLUTION-4:
% Question 4
f = [-1; -1];
A = [1 2;
2 1;
-1 0];
b = [10; 10; 0];
Aeq = [0 1];
Beq = [3];
SOLUTION-5:
% Question 5
H = [2 0;
0 2];
f = [-4;
-2];
A = [-1 -1;
-1 0];
b = [-4;
0];
[x, fval] = quadprog(H, f, A, b);
fprintf("Final x1 = %0.4f, x2 = %0.4f",x(1), x(2));
fprintf("Minimized value of J(x1, x2) = %0.4f", (fval+6));
SOLUTION-6:
For exact line search to find the value of alpha initial value were assumed as x0 and y0
−2𝑥0
∆X = −∇𝐽 = [ ]
−4𝑦0
𝑥02 + 4𝑦02
𝛼=
2𝑥02 + 16𝑦02
% Question 6
% Exact Line Search
XY = [2; 1];
x = XY(1);
y = XY(2); There was an error in the question. I meant the 2-norm of grad(J) to be less than
JLimit = 0.0001; 10^-4 be the stopping criterion. Anyways it's fine whatever you did
% J(x, y) = x^2 + 2 * y^2;
with given information as the minimum value of function is zero.
J = 1;
counter = 1;
h1 = x1*x1 + 2*x2*x2 - 2;
h2 = -x1;
h3 = -x2;
del2h1 = [2 0;
0 2];
gradh1 = [2*x1;
Same mistake.
2*x2];
gradh2 = [-1;
0];
gradh3 = [0;
-1];