--- /dev/null
+function H = extended_rosenbrock_hessian1(x)
+ ##
+ ## The Hessian of the extended Rosenbrock function. See
+ ## extended_rosenbrock1.m for more information.
+ ##
+ ## Since the number of arguments is variable, we take a vector
+ ## instead of its individual components.
+ ##
+ n = length(x);
+
+ if (odd(n))
+ ## 'm' below must be an integer.
+ H = NA;
+ return;
+ end
+
+ m = n / 2;
+ H = zeros(n, n);
+
+ % The extended Rosenbrock is simply a sum of Rosenbrock
+ % applications.
+ for k = [ 1 : m ]
+ y1 = x(2*k - 1);
+ y2 = x(2*k);
+
+ H_k = rosenbrock_hessian(y1, y2);
+
+ H(2*k - 1, 2*k - 1) = H(2*k - 1, 2*k - 1) + H_k(1,1);
+ H(2*k - 1, 2*k) = H(2*k - 1, 2*k) + H_k(1,2);
+ H(2*k, 2*k - 1) = H(2*k, 2*k - 1) + H_k(2,1);
+ H(2*k, 2*k) = H(2*k, 2*k) + H_k(2,2);
+ end
+end
--- /dev/null
+## When m=1 we should agree with rosenbrock_hessian1().
+
+x = [4;5];
+f1 = rosenbrock_hessian1(x);
+f2 = extended_rosenbrock_hessian1(x);
+
+unit_test_equals("(extended_)rosenbrock_hessian1 agree for m=1", ...
+ true, ...
+ f1 == f2);