This bug has been fixed for Release 14 (R14). For previous releases, read below for any possible workarounds:
In general, complex functions "f(z)" evaluate to a complex value. In this situation, you must define a measure of optimality of these complex results that evaluate to a real value (e.g., "|f(z)|").
The real and imaginary parts must be considered separate variables within the objective function. Therefore, the input argument to the objective function will be a 1-by-2 vector including the real and imaginary part. For this example, the objective function is in the form:
function f = objfun(X)
z = X(:, 1) + i*X(:, 2);
f = z.^2 - z + 1;
f = abs(f);
Then, using the initial guess "z = 1 + 2i", the function can be optimized by the following command:
which produces the results:
z =
0.5000 0.8661
f =
6.2523e-005
Therefore, the complex value that produces a local minimum of "abs(f(z))" is found to be:
Note that this method is the same for the PATTERNSEARCH function, except a 1-by-2 initial guess must be specified in the second input argument.
For information on how to optimize complex functions using the Optimization Toolbox, see the Related Solution.
Best Answer