The main problem here is that there is no single solution to this optimization or parameter setting problem. For example, if you look at the expected and actual results above, Utilde
equivalent (ignoring rounding differences) for two ( x
, U
) pairs, i.e.
Utilde(x = 1.5, U = 50 + 25i) = Utilde(x = 1.7318, U = 88.8760)
Although I have not studied it in detail, I even suspect that for any value of x
you can find U
that computes Utilde(x, U) = Utilde(x = 1.5, U = 50 + 25i)
.
Thus, the solution here will be to further limit the problem of setting parameters, so that the solver gives any solution that can be considered acceptable. Alternatively, reformulate Utilde
to have a unique meaning for any pair ( x
, U
).
UPDATE, AUG 1
Given reasonable initial values, it actually seems to be sufficient to limit x
real value. Performing unconditional nonlinear optimization using the diff
function formulated above, I get the following result:
x = 1.50462926953244 U = 50.6977768845879 + 24.7676554234729i diff = 3.18731710515855E-06
However, changing the initial value to values โโmore distant from the desired values โโgives different solutions, therefore, limiting x
to real values โโnot only provides a unique solution to the problem.
I implemented this in C # using the BOBYQA optimizer, but the numbers should be the same as above. If you want to try outside of Matlab, it should also be relatively simple to turn the C # code below into C ++ code using the std :: complex class and the (unlimited) non-linear C ++ optimizer of your choice. You can find some C ++ compatible codes that do not require gradient computation here , and there are various implementations available in Numerical Recipes. For example, you can access the C NR version online here .
For reference, here are the relevant parts of my C # code:
class Program { private static readonly Complex Coeff = new Complex(-2.0, 2.0); private static readonly Complex UTilde0 = GetUTilde(1.5, new Complex(50.0, 25.0)); static void Main(string[] args) { double[] vars = new[] {1.0, 25.0, 0.0};