Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task i s t o find approximations t o optimal solution, graident and hessian that minimizes the function, through newton method. M y working s

Task isto find approximations to optimal solution, graident and hessian that minimizes the function, through newton method.
My working so far :
function NewtonMethod()
% 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];
% Hessian of the objective function
hess_f = @(x)[200,1,0 ;
1,2,0.1 ;
0,0.1,0.2];
% newton method
[x_opt, f_opt, grad_opt, hess_opt]= Newton_Method(f, grad_f, hess_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);
disp('Approximated Hessian at optimal point:');
disp(hess_opt);
end
function [x_opt, f_opt, grad_opt, hess_opt]= Newton_Method(f, grad_f,hess_f, x0)
% Parameters
tol =1e-6;
max_iter =1000;
% Initialization
x = x0;
g = grad_f(x);
h = hess_f(x);
d =-h\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);
% Compute new Hessian
h_new = hess_f(x);
% Compute beta
beta =(g_new' * g_new)/(g'* g);
% Update the direction
d =-g_new + beta * d;
% 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;
hess_opt = h;
end
Question : has my code for the Newton method correctly approximated the optimal solutions and gradient? .Is the algorithmn correct ?
and I was doubtful about the hessian apprximation, how do I update the hessian in the code above

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions

Question

Describe the benefits to the company of B2C sales.

Answered: 1 week ago

Question

Why do you want to be a clinical psychologist?

Answered: 1 week ago

Question

What requirement did Health Canada initially require of Aurora?

Answered: 1 week ago