I know MaxValue is supposed to work with real numbers only, but there is some situations where a real valued function has complex terms anyway. Even with these complex terms, the function is still real valued. For example, consider the function $f:\mathbb{C}\to\mathbb{R}$ such that $f(z)=|z|$. It's not hard to come up with a lot more examples.
I wonder whether exist a way to maximize functions like this using Mathematica. In this example in particular, I have the following code
s = Abs[a + I*b]^2;
MaxValue[{s, a^2 + b^2 <= 1}, {a, b}, Reals]
which Mathematica replies with MaxValue::objc: The objective function Abs[a+I b]^2 contains a nonreal constant I. >>
.
When $a,b\in\mathbb{R}$ is clear that $|a+ib|^2$ is also real. In fact, the absolute value of any complex value is real, so why Mathematica is complaining about the imaginary number $i$ ? I know Mathematica is able to come up some simplification for this expression! Even without simlpification, Mathematica should know that the absolute value only outputs real values.
PS: the question is not about the example I gave, but about maximizing complex expressions (functions) which will be real after some simplification.
Thank you!