I want to maximize the function $f:\Bbb R^{12}\to\Bbb R$ given by $$\begin{align*} &f(x_1^{(1)},x_1^{(2)},x_2^{(1)},x_2^{(2)},x_3^{(1)},x_3^{(2)},y_1^{(1)},x_1^{(2)},y_2^{(1)},y_2^{(2)},y_3^{(1)},y_3^{(2)})=\\&\frac{1}{2}(-x_1^{(1)} y_1^{(1)} - x_1^{(2)} y_1^{(2)}) + \frac{1}{2} (-x_3^{(1)} y_1^{(1)} - x_3^{(2)} y1^{(2)})+ \\&\frac{1}{2} (-x_1^{(1)} y_3^{(1)} - x_1^{(2)} y_3^{(2)}) + \frac{1}{2} (x_3^{(1)} y_3^{(1)} + x_3^{(2)} y_3^{(2)}) \end{align*}$$ with the constraint $$(x_i^{(1)},x_i^{(2)}),(y_i^{(1)},y_i^{(2)})\in\Bbb S^1, i=1,2,3.$$
(notation: $\Bbb S^1=\{(x,y)\in\Bbb R^2; x^2+y^2=1\}$).
What is the best way to do that?
My attempt: I thought Lagrange Multipliers would be the best way to do it, but before the implementation, I tried to Maximize
. Don't works for this, the program runs forever. For the Lagrange Multiplies approach, my code was
ClearAll["Global`*"]
f[x11_, x12_, x21_, x22_, x31_, x32_, y11_, y12_, y21_, y22_, y31_,
y32_] := 1/2*(-x11 y11 - x12 y12) + 1/2*(-x31 y11 - x32 y12) +
1/2*(-x11 y31 - x12 y32) + 1/2*(x31 y31 + x32 y32)
const1 = -1 + x11^2 + x12^2;
const2 = -1 + x21^2 + x22^2;
const3 = -1 + x31^2 + x32^2;
const4 = -1 + y11^2 + y12^2;
const5 = -1 + y21^2 + y22^2;
const6 = -1 + y31^2 + y32^2;
sols = Solve[{const1 == 0, const2 == 0, const3 == 0, const4 == 0,
const5 == 0, const6 == 0,
Grad[f[x11, x12, x21, x22, x31, x32, y11, y12, y21, y22, y31,
y32], {x11, x12, x21, x22, x31, x32, y11, y12, y21, y22, y31,
y32}] ==
lambda1 Grad[
const1, {x11, x12, x21, x22, x31, x32, y11, y12, y21, y22,
y31, y32}] +
lambda2 Grad[
const2, {x11, x12, x21, x22, x31, x32, y11, y12, y21, y22,
y31, y32}] +
lambda3 Grad[
const3, {x11, x12, x21, x22, x31, x32, y11, y12, y21, y22,
y31, y32}] +
lambda4 Grad[
const4, {x11, x12, x21, x22, x31, x32, y11, y12, y21, y22,
y31, y32}] +
lambda5 Grad[
const5, {x11, x12, x21, x22, x31, x32, y11, y12, y21, y22,
y31, y32}] +
lambda6 Grad[
const6, {x11, x12, x21, x22, x31, x32, y11, y12, y21, y22,
y31, y32}]}];
values = f[x11, x12, x21, x22, x31, x32, y11, y12, y21, y22, y31, y32] /. sols
Max[values]
There is a problem again. It seems that there are a lot of critical points. Max[values]
returned some values in function of $y_3^{(1)}$. What can I do now? Maximize each expression in function of $y_3^{(1)}$ again? I only want the maximum value attained by $f$ in $\Bbb S^1\times\cdots\times\Bbb S^1$, don't care about the points where the maximum is attained. I don't know if it is $\sqrt{2}$ or not.
The last thing I tried was NMaximize
. It returns almost immediately the value $\sqrt{2}$. Is this maximum global of local? I will work with lots of functions like the one above. Will NMaximize
always gives-me global maxima for this kind of functions?
NMaximize
always find a global maximum? It would be awesome $\endgroup$