]> gitweb.michael.orlitzky.com - octave.git/blob - optimization/test_functions/trigonometric_hessian1.m
Replace ##-style comments with %-style comments in all non-test code.
[octave.git] / optimization / test_functions / trigonometric_hessian1.m
1 function H = trigonometric_hessian1(x)
2 %
3 % The Hessian of the Trigonometric function. See trigonometric1.m
4 % for more information. Not my implementation. Too ugly to
5 % recreate.
6 %
7 n = length(x);
8 H = zeros(n,n);
9
10 cos_sum = sum(cos(x));
11
12 for i = 1 : n
13 H(i,i) = sin ( x(i) );
14 end
15
16 s = 0;
17 for j = 1 : n
18 th = cos ( x(j) );
19 t = ( n + j ) - H(j,j) - cos_sum - j * th;
20 s = s + t;
21 for k = 1 : j-1
22 H(j,k) = 2 * ( sin ( x(k) ) * ( ( n + j + k ) * H(j,j) - th ) ...
23 - H(j,j) * cos ( x(k) ) );
24 end
25 H(j,j) = ( j * ( j + 2 ) + n ) * H(j,j)^2 + th * ...
26 ( th - ( 2 * j + 2 ) * H(j,j) ) + t * ( j * th + H(j,j) );
27 end
28
29 for j = 1 : n
30 H(j,j) = 2 * ( H(j,j) + cos ( x(j) ) * s );
31 end
32
33 for i = 1 : n
34 H(i,i+1:n) = H(i+1:n,i);
35 end
36
37 end