checkgradient

38 views
Skip to first unread message

Ivy

unread,
Mar 31, 2022, 8:52:39 AM3/31/22
to Manopt
Hello,
I am using  'steepestdescent' solver to solve my problem:
1648728146(1).jpg
x is the complex vector.
Here is the  European gradient. I think it should be correct. 
1648728981(1).jpg
But when I used checkgradient(problem) in Matlab, it showed me like this:
The slope should be 2. It appears to be: 1.
If it is far from 2, then directional derivatives might be erroneous.
# The cost function appears to return complex values.
# Please ensure real outputs.
The residual should be 0, or very close. Residual: 7.18676e-15.
If it is far from 0, then the gradient is not in the tangent space.
I wonder what might caused this problem. I will be so grateful if you help me.

Nicolas Boumal

unread,
Mar 31, 2022, 9:01:09 AM3/31/22
to Manopt
Hello,

Part of the message printed by checkgradient is:
# The cost function appears to return complex values.
> # Please ensure real outputs.

The cost function must return real values only (even if the variables are complex). This is because it does not make sense to minimize a complex-valued function.

Is $B \otimes C$ Hermitian? If not, the cost function may not be real valued.

If it is, and if your notation $d^*$ stands for conj(d) (that is, conjugate of d) and your notations $d^T$, $x^H$ stand for d.' (transpose) and x' (conjugate-transpose), then I agree that your cost function is mathematically real-valued. But it is still possible that small numerical errors lead to complex values in the cost function.

In that last case (if the function should be real but numerical errors create very small imaginary parts), then the solution is simply to return real(f(x)) instead of f(x), that is, discard the complex part.

Please let us know if this fixes the issue.

Best,
Nicolas

Reply all
Reply to author
Forward
0 new messages