Cody

# Problem 481. Rosenbrock's Banana Function and its derivatives

Solution 2470094

Submitted on 4 Jun 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   Pass

2   Fail
x = [0; 0]; assert(isequal(Rosenbrock_banana(x),1))

value = 1 gradient = []

Undefined function 'hessian' for input arguments of type 'double'. Error in Rosenbrock_banana (line 6) b =hessian(100*(x2-x1^2)^2+(1-x1)^2, x); Error in Test2 (line 2) assert(isequal(Rosenbrock_banana(x),1))

3   Fail
x = [1; 1]; assert(isequal(Rosenbrock_banana(x),0))

value = 0 gradient = []

Undefined function 'hessian' for input arguments of type 'double'. Error in Rosenbrock_banana (line 6) b =hessian(100*(x2-x1^2)^2+(1-x1)^2, x); Error in Test3 (line 2) assert(isequal(Rosenbrock_banana(x),0))

4   Fail
x = [1; -1]; assert(isequal(Rosenbrock_banana(x),400))

value = 400 gradient = []

Undefined function 'hessian' for input arguments of type 'double'. Error in Rosenbrock_banana (line 6) b =hessian(100*(x2-x1^2)^2+(1-x1)^2, x); Error in Test4 (line 2) assert(isequal(Rosenbrock_banana(x),400))

5   Fail
x = [-1; 0.5]; assert(isequal(Rosenbrock_banana(x),29))

value = 29 gradient = []

Undefined function 'hessian' for input arguments of type 'double'. Error in Rosenbrock_banana (line 6) b =hessian(100*(x2-x1^2)^2+(1-x1)^2, x); Error in Test5 (line 2) assert(isequal(Rosenbrock_banana(x),29))

6   Fail

value = 1 gradient = []

Undefined function 'hessian' for input arguments of type 'double'. Error in Rosenbrock_banana (line 6) b =hessian(100*(x2-x1^2)^2+(1-x1)^2, x); Error in Test6 (line 2) [~,grad]=Rosenbrock_banana(x);

7   Fail
x = [0; 0]; [~,~,Hess]=Rosenbrock_banana(x); assert(isequal(Hess,diag([2, 200])))

value = 1 gradient = []

Undefined function 'hessian' for input arguments of type 'double'. Error in Rosenbrock_banana (line 6) b =hessian(100*(x2-x1^2)^2+(1-x1)^2, x); Error in Test7 (line 2) [~,~,Hess]=Rosenbrock_banana(x);

8   Fail

value = 0 gradient = []

Undefined function 'hessian' for input arguments of type 'double'. Error in Rosenbrock_banana (line 6) b =hessian(100*(x2-x1^2)^2+(1-x1)^2, x); Error in Test8 (line 2) [~,grad]=Rosenbrock_banana(x);

9   Fail
x = [1; 1]; [~,~,Hess]=Rosenbrock_banana(x); assert(isequal(Hess,[802, -400; -400, 200]))

value = 0 gradient = []

Undefined function 'hessian' for input arguments of type 'double'. Error in Rosenbrock_banana (line 6) b =hessian(100*(x2-x1^2)^2+(1-x1)^2, x); Error in Test9 (line 2) [~,~,Hess]=Rosenbrock_banana(x);

10   Fail