Optimization to find complex number as input
===

I am wondering if there is a C/C++ library or Matlab code technique to determine real and complex numbers using a minimization solver.  Here is a code snippet showing what I would like to do.  For example, suppose that I know `Utilde`, but not `x` and `U` variables.  I want to use optimization (`fminsearch`) to determine `x` and `U`, given `Utilde`.  Note that `Utilde` is a complex number. 

    x = 1.5;
    U = 50 + 1i*25;
    x0 = [1 20];  % starting values
    Utilde = U * (1 / exp(2 * x)) * exp( 1i * 2 * x);
    xout = fminsearch(@(v)optim(v, Utilde), x0);

    function diff = optim(v, Utilde)
    x = v(1);
    U = v(2);
    diff =  abs( -(Utilde/U) + (1 / exp(2 * x)) * exp( 1i * 2 * x  ) );

The code above does not converge to the proper values, and `xout = 1.7318   88.8760`.  However, if  `U = 50`, which is not a complex number, then `xout = 1.5000   50.0000`, which are the proper values.

Is there a way in Matlab or C/C++ to ensure proper convergence, given `Utilde` as a complex number?  Maybe I have to change the code above? 