# Square root of CNOT and spectral decomposition of the Hadamard gate

I'm trying to compute the spectral decomposition of the Hadamard gate but I'm making a mistake somewhere.

Note: I believe (though I may be wrong so correct me if I am) that spectral decomposition is a way to find a diagonalized version of a matrix, additionally I am trying to work out $$\sqrt{\operatorname{CNOT}_{12}}$$, and based off an exam paper question it said to do so knowing that $$\operatorname{CNOT}_{12}=H_2Z_{12}H_2$$. I know that $$H_2=I \otimes H$$, and I thought the best way to do this would be to diagonalize $$H_2$$ by diagonalizing $$H$$ then take the square root of the diagonals of $$H_2, Z$$ to find $$\sqrt{\operatorname{CNOT}_{12}}$$.

Say we have $$H=\begin{bmatrix} \tfrac{1}{\sqrt{2}} &\tfrac{1}{\sqrt{2}} \\ \tfrac{1}{\sqrt{2}} & -\tfrac{1}{\sqrt{2}} \end{bmatrix}.$$

Now spectral decomposition of this matrix will be $$H=\sum_i \lambda_i|\psi_i\rangle \langle\psi_i|$$, where $$\lambda_i$$ corresponds to an eigenvalue and $$|\psi_i \rangle$$ is its associated eigenvector.

First we find the eigenvalues:

$$\det(H-\lambda I)=\det \begin{bmatrix} \tfrac{1}{\sqrt{2}}-\lambda &\tfrac{1}{\sqrt{2}} \\ \tfrac{1}{\sqrt{2}} & -\tfrac{1}{\sqrt{2}}-\lambda \end{bmatrix}$$ $$=(\tfrac{1}{\sqrt{2}}-\lambda)(-\tfrac{1}{\sqrt{2}}-\lambda)-\tfrac{1}{2}$$ $$=-\tfrac{1}{2}+\lambda^2-\tfrac{1}{2}=-1+\lambda^2\implies \lambda=\pm 1$$

Now we find the eigenvectors:

$$\lambda=1$$:

$$\begin{bmatrix} x\\y \end{bmatrix}=\begin{bmatrix} \tfrac{1}{\sqrt{2}} &\tfrac{1}{\sqrt{2}} \\ \tfrac{1}{\sqrt{2}} & -\tfrac{1}{\sqrt{2}} \end{bmatrix}\begin{bmatrix} x\\y \end{bmatrix}$$

$$\implies \tfrac{x+y}{\sqrt{2}}=x \implies (\sqrt{2}-1)x=y$$

$$\tfrac{x-y}{\sqrt{2}}=y \implies (\sqrt{2}+1)y=x$$

These equations give eigenvectors $$v_1=\begin{bmatrix} 1 \\(\sqrt{2}-1) \end{bmatrix}, v_2=\begin{bmatrix} (\sqrt{2}+1)\\1 \end{bmatrix}$$

The eigenvectors for $$\lambda=-1$$ are found, similarly, to be $$v_3=\begin{bmatrix} 1 \\(-\sqrt{2}-1) \end{bmatrix}, v_4=\begin{bmatrix} (-\sqrt{2}+1)\\1 \end{bmatrix}$$ But $$H=-\begin{bmatrix} 1 \\(-\sqrt{2}-1) \end{bmatrix}\begin{bmatrix} 1 &(-\sqrt{2}-1) \end{bmatrix}- \begin{bmatrix} (-\sqrt{2}+1)\\1 \end{bmatrix}\begin{bmatrix} (-\sqrt{2}+1)&1 \end{bmatrix}+\begin{bmatrix} 1 \\(\sqrt{2}-1) \end{bmatrix}\begin{bmatrix} 1 &(\sqrt{2}-1) \end{bmatrix}+\begin{bmatrix} (\sqrt{2}+1)\\1 \end{bmatrix}\begin{bmatrix} (\sqrt{2}+1)&1 \end{bmatrix}$$

Doesn't give me a diagonal matrix, where have I gone wrong?

• I don't know why they require you to write $\operatorname{CNOT}_{12}=H_2Z_{12}H_2$. For your method of taking square roots of diagonal elements to work, $H_2$ and $Z_{12}$ would have to be simultaneously diagonalizable (i.e. they at least need to commute). Did you check that? – Sanchayan Dutta Apr 28 at 7:59
• There is no "diagonalized version" of the matrix. Matrix is a matrix. But matrix can be unitary equivalent to some diagonal matrix. That is, $H=UDU^*$ for some unitary $U$ and diagonal $D$. – Danylo Y Apr 28 at 12:03
• @SanchayanDutta I checked and I see they're not simultaneously diagonalizable (They don't commute ) , this topic you mention was not something we'd not covered so I didn't know I had to check it . So it seems my proposed method won't work. How can we find the square-root of $CNOT_{12}$ then , using the fact that $CNOT_{12}=H_2Z_{12}H_2$ ? – bhapi Apr 28 at 15:13
• @SanchayanDutta I saw you edited your post and I agree that it does seem like a much easier method, it's just that on a past exam paper it said to do it the round-about way, probably exactly because it's round-about and takes more effort I suppose – bhapi Apr 28 at 15:18
• @SanchayanDutta The exact question (for clarity) is : The controlled phase flip can be converted to the CNOT gate by $H_2Z_{12}H_2=CNOT_{12}$, use this relation and the properties of the gates involved to determine the operation $\sqrt{CNOT_{12}}$ Hint :Split the controlled phase gate into a sequence of two square roots of the same gate first. I don't know if that helps at all . I'm going to keep working on the problem and if I cant get it I'll ask my lecturer in the end and post an answer if no one else does . But if the full question has shed any light please do let me know – bhapi Apr 28 at 15:25

Firstly, there's a conceptual error in your calculation of the eigenvectors.

$$\begin{bmatrix} x\\y \end{bmatrix}=\begin{bmatrix} \tfrac{1}{\sqrt{2}} &\tfrac{1}{\sqrt{2}} \\ \tfrac{1}{\sqrt{2}} & -\tfrac{1}{\sqrt{2}} \end{bmatrix}\begin{bmatrix} x\\y \end{bmatrix}$$

$$(\sqrt{2}-1)x=y \tag{1}$$

$$(\sqrt{2}+1)y=x \tag{2}$$

(1) and (2) are equivalent equations. To convince yourself multiply both sides of (1) by $$(\sqrt{2}+1)$$. The point is that when you solve the eigenvalue equation, you do not get a single eigenvector but rather a linear subspace of eigenvectors. We can only put forth the form of the eigenvectors in that subspace as:

$$\begin{bmatrix}x \\ (\sqrt{2}-1)x\end{bmatrix}=x\begin{bmatrix}1 \\ (\sqrt{2}-1)\end{bmatrix}$$ where $$x\in \Bbb C$$.

Your other vector $$\nu_2$$ lies in this same linear subspace. It's equivalent to $$(\sqrt{2}+1)\nu_1$$.

And again, $$\nu_4$$ is simply $$(-\sqrt{2}+1)\nu_3$$.

Secondly, for finding the square root of $$\operatorname{CNOT}_{12}$$ you could directly diagonalize $$\operatorname{CNOT}_{12}$$ instead of going about it in such a roundabout fashion (i.e. writing $$\operatorname{CNOT}_{12}$$ as $$H_2Z_{12}H_2$$). However, that approach is particularly useful for this specific case; see my update below.

It's a block diagonal matrix, so you can easily diagonalize the individual $$2\times 2$$ blocks.

Proceed like this:

Spectral decompose the upper left block like $$P\Lambda P^{-1}$$ and the lower right block like $$Q\Lambda'Q^{-1}$$. Then $$\operatorname{CNOT}_{12}=\begin{pmatrix}P&0\\0&Q\end{pmatrix}\begin{pmatrix}\Lambda&0\\0&\Lambda'\end{pmatrix}\begin{pmatrix}P^{-1}&0\\0&Q^{-1}\end{pmatrix}.$$

The required square root is simply $$\sqrt{\operatorname{CNOT}_{12}}=\begin{pmatrix}P&0\\0&Q\end{pmatrix}\begin{pmatrix}\sqrt\Lambda&0\\0&\sqrt\Lambda'\end{pmatrix}\begin{pmatrix}P^{-1}&0\\0&Q^{-1}\end{pmatrix}.$$

Update:

Initially, I didn't understand the significance of writing the $$\operatorname{CNOT}_{12}$$ as $$H_2Z_{12}H_2$$ but the hint in the question paper helped. One obvious fact (as $$H_2.H_2=\Bbb I$$) is that $$\operatorname{CNOT}_{12}=H_2Z_{12}H_2 = (H_2\sqrt{Z_{12}}H_2)(H_2\sqrt{Z_{12}}H_2),$$ and so $$\sqrt{\operatorname{CNOT}_{12}}=H_2\sqrt{Z_{12}}H_2.$$

Note that $$Z_{12}$$ is the controlled phase gate for $$\phi=\pi$$.

Now, an interesting property of the controlled phase gate is:

$$\begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & e^{i\phi/2} \end{pmatrix}.\begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & e^{i\phi/2} \end{pmatrix}= \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & e^{i\phi} \end{pmatrix}$$

So the square root of the $$Z_{12}$$ gate i.e. $$\sqrt{Z_{12}}$$ is $$\begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & e^{i\pi/2} \end{pmatrix}.$$

Now just pre- and post-multiply $$\sqrt{Z_{12}}$$ with $$H_2$$'s and you're done! This is indeed simpler than the spectral decomposition method I suggested earlier.

• Thank you for all your help :) – bhapi Apr 28 at 16:40

There are two points where you are wrong.

First: When you compute the eigenvector of H, which is $$2\times 2$$ matrix. So there should be one eigenvector corresponding to an eigenvalue, and should be normalized. In your computation for the case of $$\lambda=1$$, if you make a normalization you will find that there are the same.

Second: If you just want to get the square root of a self-adjoint one, then just make a square root of the eigenvalue is fine. That is for a self-adjoint operator: $$A = \sum_i \lambda_i |\psi_i\rangle\langle\psi_i|$$ then $$\sqrt{A} = \sum_i \sqrt{\lambda_i}|\psi_i\rangle\langle\psi_i|$$