]> gitweb.michael.orlitzky.com - octave.git/blobdiff - optimization/test_functions/trigonometric1.m
Add trigonometric functions and their tests.
[octave.git] / optimization / test_functions / trigonometric1.m
diff --git a/optimization/test_functions/trigonometric1.m b/optimization/test_functions/trigonometric1.m
new file mode 100644 (file)
index 0000000..f7fd625
--- /dev/null
@@ -0,0 +1,18 @@
+function f = trigonometric1(x)
+  ##
+  ## The trigonometric function. See More, Garbow, and Hillstrom,
+  ## function #26.
+  ##
+  ## This function has a minimum with f(x) == 0. The suggested
+  ## starting point is x0=(1/n, 1/n,...).
+  ##
+  n = length(x);
+  f = 0;
+
+  cos_sum = sum(cos(x));
+
+  for k = [ 1 : n ]
+    f_k = n - cos_sum + k*(1 - cos(x(k))) - sin(x(k));
+    f = f + (f_k)^2;
+  end
+end