Concept of controlled U gate in Codebook chapter I.12

Hi everyone,
First of all, I really want to thank pennylane for making such a great course material.
I am not able to understand the below lines in Codebook Chapter I.12, but I know this looks like a very very important material to develop good understanding of quantum computing.
Please explain me this concept with some basic and easy to understand easy example.
Thank you in advance.

Hi @Manu_Chaudhary , thanks for checking in. Which part are you struggling with?

Thank you @Ivana_at_Xanadu for the response. For ex, in equation (6), in the matrix, there is a identity, zero matrix, U matrix. It looks quite symmetrical and but I am not getting this logic.
Is there any video to understand this? These are basic fundamentals but are very very important for developing the understanding of the subject.

Hey @Manu_Chaudhary , okay, let’s take a look. :slight_smile:

In equation (6) you’re looking at |0⟩⟨0|\otimes \mathbb{I} + |1⟩⟨1|\otimes U on the right side.
As you said, U is the unitary operator matrix from this node. \mathbb{I} is the identity, but |0⟩⟨0| is not a zero matrix!
If you look at some of the more introductory content, you will learn that |0⟩ is a non-zero vector! In fact, |0⟩ and |1⟩ are basis states for the Pauli-Z basis. In this case, |0⟩⟨0| = \left( \begin{array}{} 1 \\ 0 \end{array} \right) \left( \begin{array}{} 1 & 0 \end{array} \right) = \left( \begin{array}{} 1 & 0 \\ 0 & 0 \end{array} \right).
You can try working out the |1⟩⟨1| matrix for yourself.
Then you simply apply the Kroenecker product (\otimes) and you get the matrix on the left.

I would like to strongly encourage you to look at some of the more basic content before trying to go on with learning. :slight_smile: For example, the first node of the introduction chapter should be able to explain most of the mathematics you got stuck on here: node I.1.

Good luck!