The FSOLVE function cannot directly handle complex-valued functions or variables. However, a complex-valued function of a complex variable "z" can also be thought of as a system of 2 real-valued equations in 2 real variables.
Consider the following example:
To solve this complex function using the FSOLVE function, we first create the following function file:
function F = myfun(X)
z = X(1, :) + j*X(2, :);
f = z.^2 - z + 1;
F = [real(f); imag(f)];
Then, using the initial guess "z = 1 + 2j", the function can be solved by the following command:
[z fval] = fsolve(@myfun, [1; 2])
which produces the results:
z =
0.5000
0.8661
fval =
6.2523e-005
Therefore, the complex value that produces a local minimum of "abs(f(z))" is found to be:
For information on how to optimize complex functions using the Genetic Algorithm and Direct Search Toolbox, see the Related Solution.
Best Answer