# Writing a matrix as an outer product expansion.

1. Feb 14, 2010

### raisin_raisin

Hi,
Can someone explain to me how to write a matrix as a sum of outer products like $$\left|\psi\rangle\langle\psi\right|$$?
For example how would I do a CNOT gate? http://en.wikipedia.org/wiki/Controlled_NOT_gate
I assume this is fairly easy since it is always assumed and I have kind of picked up its something to do with associating the rows and columns with the basis vectors.

Thanks

2. Feb 14, 2010

### elibj123

If you have an n-elements orthonormal basis {|i>}, and a matrix A (nxn) so:

$$a_{ij}=<i|A|j>$$ (1)

Then this sum:

$$A=\sum_{ij}a_{ij}|i><j|$$

Represents the matrix. (Simply substitute this into (1) and use orthonormallity)

3. Feb 14, 2010

### SpectraCat

To expand on this a little, the outer product |i><j| indexes the ith row and jth column of the matrix. This is why the resolution of the identity is written as a sum over outer products:

$$\sum_{i=1}^{N}\left|i\right\rangle\left\langle i\right|=I$$

where |i> are the orthonormal basis vectors spanning some N-dimensional space, and I is the NxN identity matrix. So, can you see how to form a CNOT matrix now?

4. Feb 15, 2010

### Tao-Fu

Yes, you are exactly right. Each ket (bra) is taken to correspond to a column (row) vector. We usually deal with orthonormal kets, so in that case we can just map each one to an element of the normal ordered basis.

SpectraCat's elaboration should probably come first, since it shows you how to get the actual expressions for the matrix elements. You simply take the operator you are trying to expand in matrix form and apply two identity operators:
$$\hat{a} = \sum_i |i \rangle \langle i| \hat{a} = \sum_{i,j}|i \rangle \langle i| \hat{a}|j\rangle\langle j|$$

This is directly the matrix expansion of the operator once you have replaced kets (bras) with column (row) vectors. Now you can identify the center portion as the matrix elements. They are just numbers obtained by an inner product of two vectors. Now you can use elibj123's (1) to write this expression in the form of his second expression.
$$\sum_{i,j}|i \rangle \underbrace{\langle i| \hat{a}|j\rangle}_{a_{ij}}\langle j| = \sum_{i,j} a_{ij} |i \rangle \langle j |$$

Now just associate each |i> with a column vector in the normal ordered basis and you can write this out as a square matrix. I.e. each term |i><j| in the sum corresponds to a square matrix with all entries zero with the exception of a 1 at i'th row and j'th column. Each term in the sum contributes to exactly one value (the corresponding matrix element) in the final square matrix.

5. Feb 16, 2010

### Frame Dragger

I've gotten multiple answers to this question, but you're nice folks so maybe you'll throw me a line; bra-ket notation as a WORD is just a play on "bracket", right? I know what the notation means within math, but as with 'shake' (10 nanoseconds from shakes of a lamb's tail) or 'Quark' (3 quarks for muster mark), sometimes it's not obvious.

6. Feb 16, 2010

### SpectraCat

From the man himself, in "The Principles of Quantum Mechanics", p. 19. (italics are Dirac's)

"One may now look upon the symbols < and > as a distinctive kind of brackets. A scalar product <A|B> now appears as a complete bracket expression, and a bra vector <B| or a ket vector |A> as an incomplete bracket expression. We have rules that any complete bracket expression denotes a number and any incomplete bracket expression denotes a vector, of the bra or ket kind according to whether it contains the first or second kind of the brackets."

Not exactly poetry ... and not exactly mathematically rigorous either it seems ... perhaps he wrote better/more complete definitions elsewhere?

7. Feb 16, 2010

### Frame Dragger

If it was good enough for Dirac, it's good enough for us. :rofl: He was a great man... but very very odd. Every read the book, "The Strangest Man" by Graham Farmelo? Fine non-scientific biography of Paul Dirac? That was my favourite recent light read since 'Prime Obsession'; an amazing bio of Riemann, with alternating chapters on the evolution of his work and the Zeta function and the man himself.

8. Feb 16, 2010

### SpectraCat

Check out, "The Man Who Loved Only Numbers", about mathematician Paul Erdos sometime .. another great read. And I think every scientist would enjoy "The Baroque Cycle" by Neal Stephenson ... it is historical fiction, but absolutely fascinating.

9. Feb 16, 2010

### Frame Dragger

I haven't read the former, but I am a great fan of Neal Stephenson. Snow Crash is fantastic, Crytonomicon is hefty, but I laughed so hard within the first 50 pages I knew it would be a good read. His description of a semi-fictional Turing's early 'fancies' from the point of view of a nearly autistic mathematical genius 3rd party almost killed me. The Diamond Age, while very different in its focus, is a fascinating read.

Of course, I'm a great fan of William Gibson especially, but all of those in the surrounding genre ('Zeitgeist' by Bruce Sterling is fantastic) rounds out my sci-fi and much larger non-fiction stable.

I'm checked, and my local (a quick walk local) library has 'The Man Who Loved Only Numbers' and are holding it for me. Thanks! I LOVE any reading tips... and music. I never listen to the radio so I'm perpetually out of touch with current music. :rofl:

10. Feb 21, 2010

### raisin_raisin

Thank you very much (for the book recommendations as well