Now, let us look at our first application of semi-definite programming. Suppose that we would like to solve the following geometry problem.
Before we can attack this with semidefinite programming, we need to first convert it into an equivalent problem involving a semidefinite matrix. First, note that
Problem 7.1.5 does not change if we assume that
\(u_1,u_2,u_3\) are unit vectors, and so we will assume this as it will be convenient later. We recall that the angle
\(\varphi\) between two unit vectors
\(u,v\) can be determined via
\begin{equation*}
\cos(\varphi) = u^Tv.
\end{equation*}
Also, observe that the function \(\cos(\varphi)\) is decreasing for \(0\leq \varphi\leq 2\pi\text{.}\) So, the problem of maximizing the smallest angle between any two of the three vectors can be rephrased as minimizing the largest dot product among any pair of them. That is, our problem is equivalent to
\begin{align*}
\text{min } \amp \amp x\\
\text{subject to } \amp\amp u_1^Tu_1=1,\\
\amp\amp u_2^Tu_2=1,\\
\amp\amp u_3^Tu_3=1,\\
\amp\amp u_1^Tu_2= x,\\
\amp\amp u_1^Tu_3= x,\\
\amp\amp u_2^Tu_3= x.
\end{align*}
We can remove the variable \(x\) as follows:
\begin{align*}
\text{min } \amp \amp u_1^Tu_2\\
\text{subject to } \amp\amp u_1^Tu_1=1,\\
\amp\amp u_2^Tu_2=1,\\
\amp\amp u_3^Tu_3=1,\\
\amp\amp u_1^Tu_3- u_1^Tu_2=0 ,\\
\amp\amp u_2^Tu_3-u_1^Tu_2= 0.
\end{align*}
Note that the first three constraints come from our assumption that all three vectors have length one. Now, this still isn’t in quite the right format, but it is closer. Our next step is to use
Condition 4 to convert this into an SDP. Indeed, imagine that we let
\(R\) be the
\(3\times 3\) matrix where the three columns are given by
\(u_1,u_2,u_3\text{,}\) respectively, and let
\(X=R^TR\text{.}\) Note that the entry on the
\(i\)th row and
\(j\)th column of
\(X\) is precisely
\(u_i^Tu_j\text{.}\) Also, by
Lemma 7.1.2, not only is the matrix
\(X\) positive semidefinite, but
every positive semidefinite matrix can be represented as such a product. So, letting the entries of
\(X\) be the variables of our matrix, we get the following:
\begin{align*}
\text{min } \amp \amp x_{1,2}\\
\text{subject to } \amp\amp x_{1,1}=1,\\
\amp\amp x_{2,2}=1,\\
\amp\amp x_{3,3}=1,\\
\amp\amp x_{1,3}-x_{1,2}=0 ,\\
\amp\amp x_{2,3}-x_{1,2}= 0,\\
\amp\amp X\succeq 0.
\end{align*}
Now, we need to be careful here. There is a still a subtle issue here. In an SDP, the matrix \(C\) in the objective function as well as all of the matrices \(A_1,\dots,A_m\) in the constraints are supposed to be symmetric. The above optimization problem fails that condition. However, its always easy to “symmetrize” it by replacing every instance of \(x_{i,j}\) with \(\frac{1}{2}\left(x_{i,j}+x_{j,i}\right)\text{,}\) which does not change anything because the matrix is symmetric anyway. In this case, after doing these substitutions, we will also re-scale some of our constraints to get rid of fractions. So, the above optimization problem is equivalent to
\begin{align*}
\text{min } \amp \amp \frac{1}{2}x_{1,2}+\frac{1}{2}
x_{2,1}\\
\text{subject to } \amp\amp x_{1,1}=1,\\
\amp\amp x_{2,2}=1,\\
\amp\amp x_{3,3}=1,\\
\amp\amp x_{1,3}+x_{3,1}-x_{1,2}-x_{2,1}=0 ,\\
\amp\amp x_{2,3}+x_{3,2}-x_{1,2}-x_{2,1}= 0,\\
\amp\amp X\succeq 0.
\end{align*}
Okay, now, after all of this messing around, let’s try to solve this thing. There is a video at the end of this section which does this via computing the eigenvalues of \(X\) and determining when they are non-negative (which is a pretty easy calculation). To give ourselves some practice with SDP duality, let’s instead solve this by taking the dual and analyzing it. First, we observe that the matrix
\begin{equation*}
\begin{bmatrix}1\amp -1/2\amp -1/2\\ -1/2\amp 1\amp -1/2\\-1/2\amp -1/2\amp 1\end{bmatrix}
\end{equation*}
is primal feasible (its eigenvalues are \(3/2,3/2,0\)). Therefore, the value of the primal SDP is at most \(-1/2\text{.}\) Let’s now take the dual. By definition, it is
\begin{align*}
\text{max } \amp \amp y_1+y_2+y_3\\
\amp\amp \begin{bmatrix}-y_1\amp \frac{1}{2}+y_4+y_5\amp -y_4\\ \frac{1}{2}+y_4+y_5\amp -y_2\amp -y_5\\-y_4\amp -y_5\amp-y_3\end{bmatrix}\succeq 0.
\end{align*}
Now, if we plug in \(y_1=y_2=\cdots=y_5=-1/6\text{,}\) we get a feasible point (the matrix has eigenvalues \(3/2,0,0\)) which gives a value of \(-1/2\text{.}\) So, by weak duality for SDPs, the value of the primal and the dual SDPs must be equal to \(-1/2\text{.}\) So, the maximum possible angle it \(\arccos(-1/2)=2\pi/3\text{.}\)