Trying to find the minimum of this function using steepest descent, unsure why I keep getting the wrong answer. (1.5,1) should be the optimal

2 views (last 30 days)
%Steepest Descent
clc
x0 = [5 2];
k = 0;
while k < 6
f = @(x1,x2) 5.*x1.^2+7.*x2.^2-5.*x1-10.*x1.*x2+x2;
dfdx1 = @(x1,x2) 10.*x1-10.*x2-5;
dfdx2 = @(x1,x2) 14.*x2-10.*x1+1;
x1 = x0(1);
x2 = x0(2);
s1 = -feval(dfdx1,x1,x2)
s2 = -feval(dfdx2,x1,x2)
alpha = (-10.*x1.*s1-14.*s2.*x2-5.*s1-10.*s1.*x2-10.*s2.*x1-s2)/(10.*(s1.^2)+14.*(s2.^2)-20.*s1.*s2)
x0 = [x0 + alpha.*[s1 s2]]
k=k+1;
end

Answers (0)

Categories

Find more on Get Started with Optimization Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!