# Trouble finding a maximum of a constrained multivariate function

I have a multivariate function that I seek to maximize (ideally symbolically):

The function has the form:

$$\frac{(-j*a)}{8 (-(b/2) - j (c-d-e)) ((j*b*c)/2 - (j*b*d)/2 + c*d - d^2 + a^2/4))}$$

(where j is the imaginary number) I want to find the maximums of the real and imaginary parts. When I try to find them with the code:

Maximize[Im[function], {a, b, c, d, e}]


It tells me that my solution is indeterminate and that my maximum is at infinity. I believe that this issue is due to the function "blowing up" if all the values in the denominator are zero. So I wanted to write a code that ignores these cases when the parameters are zero.

  Maximize[Im[function], a>0, b>0, c>0,d>0, e>0, {a, b, c, d, e}]


In doing so, Mathematica "hangs" and I never get an answer.

Any ideas or suggestions for how I should proceed? Should I give up on finding a symbolic solution and go straight to using a numerical solver? It seems like a simple enough function that finding a maximum doesn't /seem/ impossible but maybe my intuition is wrong..

The code that hangs is:

fun = -((I a)/(
8 (-(b/2) - I (c - d - e)) ((I b c)/2 - (I b d)/2 + c d - d^2 +
a^2/4)));
imFUN = ComplexExpand[Im[fun]] // Simplify
Maximize[imFUN ,
a > 0 && b > 0 && c > 0 && d > 0 && e > 0,  {a, b, c, d, e}]

• Please provide copyable code. Otherwise, many people (myself included) will not try to answer your question. – Carl Woll Mar 6 '19 at 0:26
• Thanks for the feedback, I added copyable code. – Steven Sagona Mar 6 '19 at 0:32

Since $$\texttt{imFUN} \rightarrow \infty$$ as $$\{b,c,e\}\rightarrow0$$, $$a\ne0$$, and $$a^2=4d^2$$, making $$\{b,c,e\}$$ arbitrarily small will make $$\texttt{imFUN}$$ arbitrarily large, so it is not surprising that Mathematica cannot find a maximum.

Using NMaximize indicates that the objective function is probably unbounded:

NMaximize[{imFUN, a>0 && b>0 && c>0 && d>0 && e>0}, {a, b, c, d, e}, MaxIterations->100]
NMaximize[{imFUN, a>0 && b>0 && c>0 && d>0 && e>0}, {a, b, c, d, e}, MaxIterations->200]
NMaximize[{imFUN, a>0 && b>0 && c>0 && d>0 && e>0}, {a, b, c, d, e}, MaxIterations->300]


NMaximize::cvdiv: Failed to converge to a solution. The function may be unbounded.

{5726.59, {a -> 0.21148, b -> 0.000813153, c -> 2.17324, d -> 2.1732, e -> 0.}}

NMaximize::cvdiv: Failed to converge to a solution. The function may be unbounded.

{2.16255*10^8, {a -> 0.211743, b -> 3.55842*10^-9, c -> 2.17226, d -> 2.17226, e -> 0.}}

NMaximize::cvdiv: Failed to converge to a solution. The function may be unbounded.

{5.98731*10^12, {a -> 0.211742, b -> 7.03351*10^-13, c -> 2.17226, d -> 2.17226, e -> 0.}}