Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task is to find approximations to optimal solution, graident and hessian that minimizes the function, through steepest decent method. My working so far : function

Task is to find approximations to optimal solution, graident and hessian that minimizes the function, through steepest decent method.
My working so far :
function SteepestD_MethodFinal()
% Initial point
x0=[10; 10; 10];
% Function handle for the objective function
f = @(x)100*x(1)^2+ x(2)^2+0.1*x(3)^2+ x(1)*x(2)+0.1*x(2)*x(3)-6*x(1)+4*x(2)+6*x(3)+15;
% Gradient of the objective function
grad_f = @(x)[200*x(1)+ x(2)-6;
2*x(2)+ x(1)+0.1*x(3)+4;
0.2*x(3)+0.1*x(2)+6];
% steepest decent method
[x_opt, f_opt, grad_opt]= SteepestD_Method(f, grad_f, x0);
% Display results
disp('Approximated Optimal point:');
disp(x_opt);
disp('Approximated Function value at optimal point:');
disp(f_opt);
disp('Approximated Gradient at optimal point:');
disp(grad_opt);
end
function [x_opt, f_opt, grad_opt]= SteepestD_Method(f, grad_f, x0)
% Parameters
tol =1e-6;
max_iter =1000;
% Initialization
x = x0;
g = grad_f(x);
d =-g;
k =0;
while norm(g)> tol && k < max_iter
% Line search to find optimal step size alpha
alpha = fminbnd(@(a) f(x + a*d),0,1);
% Update the point
x = x + alpha * d;
% Compute new gradient
g_new = grad_f(x);
% Update the direction
d =-g;
% Update the gradient
g = g_new;
% Increment iteration counter
k = k +1;
end
% Optimal values
x_opt = x;
f_opt = f(x_opt);
grad_opt = g;
end
Question : has my code ,which uses steepest decent method ,done approximating the optimal soultion and gradient correctly ?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Accounting

Authors: Joe Hoyle, Thomas Schaefer, Timothy Doupnik

10th edition

0-07-794127-6, 978-0-07-79412, 978-0077431808

Students also viewed these Databases questions