Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I tried to obtain approximations of optimal points, grad and hessian using newton method,.function NewtonMethod ( ) % Initial point x 0 = [ 1
I tried to obtain approximations of optimal points, grad and hessian using newton method,.function NewtonMethod Initial point x; ; ; Function handle for the objective function f @xx xx xxxxxxx; Gradient of the objective function gradf @xx x; x xx; xx; Hessian of the objective function hessf @x ; ; ; newton method xopt, fopt, gradopt, hessopt NewtonMethodf gradf hessf x; Display results dispApproximated Optimal point:; dispxopt; dispApproximated Function value at optimal point:; dispfopt; dispApproximated Gradient at optimal point:; dispgradopt; dispApproximated Hessian at optimal point:; disphessopt; end function xopt, fopt, gradopt, hessopt NewtonMethodf gradfhessf x Parameters tol e; maxiter ; Initialization x x; g gradfx; h hessfx; d g; k ; while normg tol && k maxiter Line search to find optimal step size alpha alpha fminbnd@a fx ad; Update the point x x alpha d; Compute new gradient gnew gradfx; Compute new Hessian hnew hessfx; Update the direction d h gnew; Update the gradient g gnew; Increment iteration counter k k ; end Optimal values xopt x; fopt fxopt; gradopt g; hessopt h; end Question : does my code correctly approximates the optimal solution, graident and hessian using newton method
I tried to obtain approximations of optimal points, grad and hessian using newton method,.function NewtonMethod
Initial point
x; ; ;
Function handle for the objective function
f @xx xx xxxxxxx;
Gradient of the objective function
gradf @xx x;
x xx;
xx;
Hessian of the objective function
hessf @x ;
;
;
newton method
xopt, fopt, gradopt, hessopt NewtonMethodf gradf hessf x;
Display results
dispApproximated Optimal point:;
dispxopt;
dispApproximated Function value at optimal point:;
dispfopt;
dispApproximated Gradient at optimal point:;
dispgradopt;
dispApproximated Hessian at optimal point:;
disphessopt;
end
function xopt, fopt, gradopt, hessopt NewtonMethodf gradfhessf x
Parameters
tol e;
maxiter ;
Initialization
x x;
g gradfx;
h hessfx;
d g;
k ;
while normg tol && k maxiter
Line search to find optimal step size alpha
alpha fminbnd@a fx ad;
Update the point
x x alpha d;
Compute new gradient
gnew gradfx;
Compute new Hessian
hnew hessfx;
Update the direction
d h gnew;
Update the gradient
g gnew;
Increment iteration counter
k k ;
end
Optimal values
xopt x;
fopt fxopt;
gradopt g;
hessopt h;
end
Question : does my code correctly approximates the optimal solution, graident and hessian using newton method
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started