function g = trigonometric_gradient1(x)
- ##
- ## The gradient of the trigonometric function. See trigonometric1.m
- ## for more information.
- ##
+ %
+ % The gradient of the trigonometric function. See trigonometric1.m
+ % for more information.
+ %
n = length(x);
g = zeros(n,1);
f_k = n - cos_sum + k*(1 - cos(x(k))) - sin(x(k));
for j = [ 1 : n ]
- ## Add to the jth component of g the partial of f^2 with
- ## respect to x(j). The first term that we add here exists
- ## regardless of j.
+ % Add to the jth component of g the partial of f^2 with
+ % respect to x(j). The first term that we add here exists
+ % regardless of j.
g(j) = g(j) + 2*f_k*sin(x(j));
if (j == k)
- ## But this term vanishes when j != k.
+ % But this term vanishes when j != k.
g(j) = g(j) + 2*f_k*k*sin(x(k)) - 2*f_k*cos(x(k));
end
end