Math toolkit
Matrices acting on states
Gates are matrices; circuit order vs matrix order
In the app every question checks your answer and explains a wrong one.
Matrix times vector
A single-qubit gate is a matrix. Applying it to a state means multiplying the state’s column vector (every ket, such as , stands for one: see kets as vectors). Each output entry is a row of the matrix dotted with the input.
A shortcut: the first column is what the gate does to , and the second column is what it does to .
Worked example
Hadamard on |1⟩
and .
Top entry: . Bottom entry: .
So , the state called .
Check yourself
Apply to .
Hints
- Dot the top row with the input. What do you get?
- swaps the two entries.
Show the answer
Answer:
The top row picks out , the bottom row picks out .
Order, and the dagger
In a circuit, time runs left to right: first , then . As matrices that is , because the matrix nearest the ket acts first. The adjoint is the conjugate transpose. A matrix is unitary when ; every quantum gate is unitary, so every gate can be undone by applying .
Check yourself
A circuit applies and then to a qubit. Which expression gives the final state?
- A
- B
- C
Show the answer
Answer: A.
Read the circuit left to right and write the matrices right to left: .
Why not the others
- B. That applies first. The matrix closest to the ket acts first, so circuit order is reversed in the formula.
- C. Gates in sequence compose by multiplication, not addition.
Check yourself
Which of these matrices could be a quantum gate?
- A
- B
- C
- D
Hints
- Look at the columns: what does each matrix do to and to ?
- A gate needs both images to be unit vectors, and orthogonal to each other.
Show the answer
Answer: A.
sends and : two unit columns that are orthogonal, so .
Why not the others
- B. This keeps and sends to the zero vector, which is not a state. Its second column has length 0, not 1, so it is not unitary. It describes the measurement outcome 0, not a gate.
- C. Each column has length 1, but both columns are the same: and land on the same state, and is sent to zero. A gate must keep orthogonal states orthogonal so it can be undone.
- D. Its second column, the image of , is , with length . A gate must keep every state normalized, so each column must have length 1.
Go further
Free resources for when you want more than this refresher covers.
- Matrix multiplication as composition3Blue1Brown · Video
Shows why a product of matrices applies the right-hand one first, which is why a circuit’s gates appear in reverse order.
- Precalculus 2e: Matrices and matrix operationsOpenStax · Free book
Worked examples and exercises on adding, scaling and multiplying matrices, for more practice than this refresher gives.
- Linear algebra (18.06SC)Gilbert Strang, MIT OpenCourseWare · Course
A full university course with lecture videos, problem sets and exams with solutions, for the whole subject.
- Unitary matrixWikipedia · Article
The equivalent definitions of a unitary matrix and its properties, such as eigenvalues on the unit circle.
Lessons that use it
- Lesson 0: Orientation and diagnosticHow the lessons work, five key words, how states are written, and a quick check of the math the lessons assume
- Lesson 4: Single-qubit gatesGates as matrices and as turns of the Bloch sphere, and why every gate is unitary
- Lesson 8: TeleportationMove an unknown qubit with one Bell pair and two classical bits