Cody

# Problem 484. Steepest Descent Method

Solution 3028825

Submitted on 2 Oct 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Fail
% Rosenbrock's banana function F=@(x) 100*(x(2)-x(1).^2).^2 + (1-x(1)).^2; gradF=@(x) [100*(4*x(1).^3-4*x(1).*x(2))+2*x(1)-2; 100*(2*x(2)-2*x(1).^2)]; x0 = [-1.9; 2.0]; x1=[ -1.4478 2.1184]; x2=[ 1.7064 2.9446]; f1=6.0419; f2=0.6068; [xmin,fmin]=SteepestDescent(F,gradF,x0,0.01,1) assert(norm(xmin-x1)<0.2||norm(xmin-x2)<0.2) assert( abs(fmin-f1)<0.5|| abs(fmin-f2)<0.5) % 2 local min

Converged = logical 0 xmin = 77.6531 22.8363 fmin = 3.6086e+09

Assertion failed.

2   Fail
% Rosenbrock's banana function F=@(x) 100*(x(2)-x(1).^2).^2 + (1-x(1)).^2; gradF=@(x) [100*(4*x(1).^3-4*x(1).*x(2))+2*x(1)-2; 100*(2*x(2)-2*x(1).^2)]; x0 = [0; 0]; xcorrect=[1;1]; fcorrect=0; [xmin,fmin]=SteepestDescent(F,gradF,x0) % 20 iterations default assert(norm((xmin-xcorrect),inf)<1) assert(abs(fmin-fcorrect)<0.8);

Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 xmin = NaN NaN fmin = NaN

Assertion failed.

3   Fail
% Rosenbrock's banana function F=@(x) 100*(x(2)-x(1).^2).^2 + (1-x(1)).^2; gradF=@(x) [100*(4*x(1).^3-4*x(1).*x(2))+2*x(1)-2; 100*(2*x(2)-2*x(1).^2)]; x0 = [1.1; 0.9]; xcorrect=[1;1]; fcorrect=0; [xmin,fmin]=SteepestDescent(F,gradF,x0,1e-2,2000) assert(isequal(round(xmin),xcorrect)) assert(isequal(round(fmin),fcorrect))

Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = logical 0 Converged = log...

Assertion failed.