# Using Maximize function with UnitaryMatrixQ constraint

Define a function

 m[x_, y_, z_, w_, a_, b_, c_, d_, e_, f_] = { {a*Abs[x]^2 + 2 *Re[e*x*Conjugate[y]] + c*Abs[y]^2,
b*Abs[x]^2 + 2*Re[f*x*Conjugate[y]] + d*Abs[y]^2 }, {a*Abs[z]^2 +
2*Re[e*x*Conjugate[y]] + d*Abs[y]^2,
b*Abs[z]^2 + 2*Re[f*z*Conjugate[w]] + d*Abs[w]^2} } // MatrixForm


which returns the matrix $$\begin{pmatrix} a | x |^2 + 2 \text{Re}(ex \overline{y}) + c |y |^2 & b | x |^2 + 2 \text{Re}(f x \overline{y}) + d |y |^2 \\ a | z |^2 + 2\text{Re}(e z \overline{w}) + c | w |^2 & b | z |^2 + 2\text{Re} (f z \overline{w}) + d | w|^2 \end{pmatrix}$$

Can one use the maximize function with the UnitaryMatrixQ to find the maximum of the largest eigenvalue of this matrix, where $$\begin{pmatrix} x & y \\ z &w \end{pmatrix}$$ is a unitary matrix?

• You would need to know the values of {a,b,c,d,e,f} Aug 29, 2021 at 14:46

For numerical values of the parameters it could be done as below.

m[x_, y_, z_, w_, a_, b_, c_, d_, e_,
f_] = {{a*Abs[x]^2 + 2*Re[e*x*Conjugate[y]] + c*Abs[y]^2,
b*Abs[x]^2 + 2*Re[f*x*Conjugate[y]] + d*Abs[y]^2}, {a*Abs[z]^2 +
2*Re[e*x*Conjugate[y]] + d*Abs[y]^2,
b*Abs[z]^2 + 2*Re[f*z*Conjugate[w]] + d*Abs[w]^2}};


Form the unitary matrix conditions.

umat = {{x, y}, {z, w}};
constraints =
IdentityMatrix[2]] == 0];

(* Out[277]= {-1 + x^2 + y^2 == 0, w y + x z == 0,
w y + x z == 0, -1 + w^2 + z^2 == 0} *)


Create the objective function that maximizes the largest eigenvalue.

objfunc[x_, y_, z_, w_, a_, b_, c_, d_, e_, f_] := With[
{mat = m[x, y, z, w, a, b, c, d, e, f]},
Max[Eigenvalues[mat]]]


Now we make a function to do the maximization, given number values for the parameters.

max[a_?NumberQ, b_?NumberQ, c_?NumberQ,
d_?NumberQ, e_?NumberQ, f_?NumberQ] :=
NMaximize[
{objfunc[x, y, z, w, a, b, c, d, e, f],\
constraints}, {x, y, z, w}]


Try it out:

In[284]:= {max, vals} = max[1, 2, 3, 4, 5, 6]

(* Out[284]= {9.77255,
{x -> -0.777484, y -> 0.628902, z -> -0.628902,
w -> -0.777484}} *)