MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

# Solution 60501

Submitted on 13 Mar 2012 by Robert Canfield

Correct

217Size
`This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.`

### Test Suite

Test
Code Input and Output
1
Pass

```%%
% Rosenbrock's banana function
F=@(x) 100*(x(2)-x(1).^2).^2 + (1-x(1)).^2;
x0 = [-1.9; 2.0];
x1=[
-1.4478
2.1184];
x2=[
1.7064
2.9446];
f1=6.0419;
f2=0.6068;
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
```
```iter alpha f(alpha)  norm(c)
0 0.0000 267.6200 1270.8691
1 0.0004   6.0204   1.6920
xmin =
-1.4522
2.1173
fmin =
6.0204
```
2
Pass

```%%
% Rosenbrock's banana function
F=@(x) 100*(x(2)-x(1).^2).^2 + (1-x(1)).^2;
x0 = [0; 0];
xcorrect=[
0.2927
0.0506];
fcorrect=0.63;
assert(norm(xmin-xcorrect)<0.1)
assert( abs(fmin-fcorrect)<0.01)
```
```iter alpha f(alpha)  norm(c)
0 0.0000   1.0000   2.0000
2 0.0098   0.6237   7.5488
xmin =
0.2931
0.0507
fmin =
0.6237
```
3
Pass

```%%
% Rosenbrock's banana function
F=@(x) 100*(x(2)-x(1).^2).^2 + (1-x(1)).^2;
x0 = [0;0];
xcorrect = [1;1;];
fcorrect = 0;
assert(norm(xmin-xcorrect)<0.01)
assert(abs(fmin-fcorrect)<0.01);
```
```iter alpha f(alpha)  norm(c)
0 0.0000   1.0000   2.0000
13 1.1440   0.0000   0.0000
xmin =
1.0000
1.0000
fmin =
7.2406e-13
```
4
Pass

```%%
% Rosenbrock's banana function
F=@(x) 100*(x(2)-x(1).^2).^2 + (1-x(1)).^2;
HessF=@(x) 200*[4*x(1).^2-2*(x(2)-x(1).^2)+1/100, -2*x(1);
-2*x(1), 1];
xcorrect = [1;1];
fcorrect = 0;
x0 = [-1.9; 2];
```iter alpha f(alpha)  norm(c)