Question: % Objective Function to be minimized function f = f ( x , y , z ) f = 1 0 0 * x ^

% Objective Function to be minimized
function f = f(x, y, z)
f =100*x^2+ y^2+0.1*z^2+ x*y +0.1*x*y -6*x +4*y +6*z +15;
end
% Gradient of the function
function g = grad(x, y, z)
g =[200*x+y-6,2*y + x +0.1*z +4,0.2*z +0.1*y +6];
end
% Step size for the gradient descent
alpha =0.1;
% Maximum number of iterations
maxIter =100;
% Stopping criteria
epsilon =1e-4;
% Starting point
x0=[10,10,10];
% Current point
x = x0;
% Previous point
xPrev = zeros(size(x0));
% Iteration counter
k =0;
% Gradient descent loop
while k < maxIter && euclideanNorm(x, xPrev)> epsilon
% Update the previous point
xPrev = x;
% Compute the gradient at the current point
g = grad(x(1), x(2), x(3));
% Update the current point
x(1)= x(1)- alpha * g(1);
x(2)= x(2)- alpha * g(2);
x(3)= x(3)- alpha * g(3);
% Increase the iteration counter
k = k +1;
end
% Print the result
disp(['Local optima: ', num2str(x)]);
% Euclidean norm
function n = euclideanNorm(x, y, z)
n = sqrt(sum((x - y)-z).^2);
end
What is the error here, I want to output the local minima of objective function

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!