How does bra-ket notation work?

Quantum algorithms frequently use bra-ket notation in their description. What do all of these brackets and vertical lines mean? For example: $|ψ⟩=α|0⟩+β|1⟩$

While this is arguably a question about mathematics, this type of notation appears to be used frequently when dealing with quantum computation specifically. I'm not sure I have ever seen it used in any other contexts.

Edit

By the last part, I mean that it is possible to denote vectors and inner products using standard notation for linear algebra, and some other fields that use these objects and operators do so without the use of bra-ket notation.

This leads me to conclude that there is some difference/reason why bra-ket is especially handy for denoting quantum algorithms. It is not an assertion of fact, I meant it as an observation. "I'm not sure I have seen it used elsewhere" is not the same statement as "It is not used in any other contexts".

As already explained by others, a ket $\left|\psi\right>$ is just a vector. A bra $\left<\psi\right|$ is the Hermitian conjugate of the vector. You can multiply a vector with a number in the usual way.

Now comes the fun part: You can write the scalar product of two vectors $\left|\psi\right>$ and $\left|\phi\right>$ as $\left<\phi\middle|\psi\right>$.

You can apply an operator to the vector (in finite dimensions this is just a matrix multiplication) $X\left|\psi\right>$.

All in all, the notation is very handy and intuitive. For more information, see the Wikipedia article or a textbook on Quantum Mechanics.

• "bra is a Hermitian conjugate." What is a Hermitian conjugate of a vector? And is $\langle\phi|\psi\rangle$ just the inner product $\phi^\top \psi$ of vectors $\phi$ and $\psi$? Nov 17, 2019 at 23:16
• There are two kinds of vectors, column vectors and row vectors. The Hermitian conjugate of a column vector is a row vector with complex conjugated elements, and vice versa. Nov 17, 2019 at 23:22
• complex conjugated elements? Nov 17, 2019 at 23:25
• Elements as in matrix elements. You can also use the term "components" that is more usual when talking about vectors. Nov 17, 2019 at 23:27
• Yes, $\langle\phi|\psi\rangle$ is the inner product, but the vector space is complex, so the formula is $\phi^\dagger\psi$, note the dagger for the Hermitian conjugate, it is not just the transpose. Nov 17, 2019 at 23:34

You could think of $|0\rangle$ and $|1\rangle$ as two orthonormal basis states (represented by "ket"s) of a quantum bit which resides in a two dimensional complex vector space. The lines and brackets you see is basically the bra-ket notation a.k.a Dirac notation which is commonly used in quantum mechanics.

As an example $|0\rangle$ could represent the spin-down state of an electron while $|1\rangle$ could represent the spin-up state. But actually the electron can be in a linear superposition of those two states i.e. $|\psi\rangle_{\text{electron}} = a|0\rangle + b|1\rangle$ (this is usually normalized like $\frac{a|0\rangle + b|1\rangle}{\sqrt{|a|^2+|b|^2}}$) where $a,b\in \Bbb{C}$.

What do all of these brackets and vertical lines mean?

The notation $\left \lvert v \right \rangle$ means exactly the same thing as $\vec{v}$ or $\textbf{v}$, i.e. it denotes a vector whose name is "v". That's it. There is no further mystery or magic, at all. The symbol $\left \lvert \psi \right \rangle$ denotes a vector called "psi".

The symbol $\left \lvert \cdot \right \rangle$ is called a "ket", but it could just as well (and in my opinion should) be called a "vector" with absolutely no loss of meaning at all.

While this is arguably a question about mathematics, this type of notation appears to be used frequently when dealing with quantum computation specifically. I'm not sure I have ever seen it used in any other contexts.

The notation was invented by a physicist (Paul Dirac) and is called "Dirac notation" or "bra-ket notation". As far as I know, Dirac probably invented it while studying quantum mechanics, and so historically the notation has mostly been used to denote the vectors that show up in quantum mechanics, i.e. quantum states. Bra-ket notation is the standard in any quantum mechanics context, not just quantum computation. For example, the Schrodinger equation, which has to do with dynamics in quantum systems and predates quantum computation by decades, is written using bra-ket notation.

Furthermore, the notation is pretty convenient in other linear algebra contexts and is used outside of quantum mechanics.

The ket notation $|\psi\rangle$ means a vector in whatever vector space we're working in, such as the space of all complex linear combinations of the eight 3-bit strings $000$, $001$, $010$, etc., as we might use to represent the states of a quantum computer. Unadorned $\psi$ means exactly the same thing—the $|\psi\rangle$ ket notation is useful partly to emphasize that, for example, $|010\rangle$ is an element of the vector space of interest, and partly for its cuteness in combination with the bra notation.

The bra notation $\langle\psi|$ means the dual vector or covector—a linear functional, or linear map from vectors to scalars, whose value at a vector $|\phi\rangle$ is the inner product of $\psi$ with $\phi$, cutely written $\langle\psi|\phi\rangle$. Here we assume the existence of an inner product, which is not a given in arbitrary vector spaces, but in quantum physics we usually work in Hilbert spaces which by definition have an inner product. The dual of a vector is sometimes also called its (Hermitian) transpose, because in matrix representation, a vector corresponds to a column and a covector corresponds to a row, and when you multiply $\mathrm{row} \times \mathrm{column}$ you get a scalar. (The Hermitian part means in addition to transposing the matrix, we take the complex conjugate of its entries—which is really just further transposing the matrix representation $\scriptstyle\begin{bmatrix}a&b\\-b&a\end{bmatrix}$ of the complex number $a + b i$.)

When written the other way, $|\psi\rangle\langle\phi|$, you get the outer product of $\psi$ with $\phi$, defined to be the linear transformation of the vector space to itself given by $|\theta\rangle \mapsto (\langle\phi|\theta\rangle) |\psi\rangle$. That is, given a vector $\theta$, it scales the vector $\psi$ by the scalar given by the inner product $\langle\phi|\theta\rangle$. Since the operations in question are associative, we can remove the parentheses and unambiguously write $$(|\psi\rangle\langle\phi|)|\theta\rangle = |\psi\rangle\langle\phi|\theta\rangle = \langle\phi|\theta\rangle|\psi\rangle = (\langle\phi|\theta\rangle)|\psi\rangle.$$ The operations involved are not commutative in general, however: reversing the order yields the complex conjugate$\langle\psi|\phi\rangle = \langle\phi|\psi\rangle^*$, replacing $a + b i$ by $a - b i$. There may be other transformations of the spaces involved thrown in the mix too, like $\langle\psi|A|\phi\rangle$, which can be read equivalently as the precomposition of the linear functional $\langle\psi|$ by the linear transformation $A$, applied to the vector $|\phi\rangle$, or as the evaluation of the linear functional $\langle\psi|$ at the vector obtained by transforming $|\phi\rangle$ by the linear transformation $A$.

The notation is used mainly in quantum physics; mathematicians tend to just write $\psi$ where physicists might write $|\psi\rangle$; $\psi^*$ for the covector $\langle\psi|$; either $\langle\psi,\phi\rangle$ or $\psi^*\phi$ for the inner product; and $\psi^*A\phi$ for what physicists would notate by $\langle\psi|A|\phi\rangle$.

This leads me to conclude that there is some difference/reason why bra-ket is especially handy for denoting quantum algorithms.

There's already an accepted answer and an answer that explains 'ket', 'bra' and the scalar product notation.

I'll try add a bit more to the highlighted entry. What makes it a useful/handy notation?

The first thing that bra-ket notation is really used a lot for is to denote very simply the eigenvectors of a (usually Hermitian) operator associated with an eigenvalue. Suppose we have an eigenvalue equation $A(v)=\lambda v$, this can be denoted as $A\left|\lambda\right\rangle=\lambda \left|\lambda\right\rangle$, and probably some extra label $k$ if there is some degeneracy $A\left|\lambda,k\right\rangle=\lambda \left|\lambda,k\right\rangle$.

You see this employed all over quantum mechanics, momentum eigenstates tend to be labelled as $\left|\vec{k}\right\rangle$ or $\left|\vec{p}\right\rangle$ depending on units, or with multiple particle states $\left|\vec{p}_1,\vec{p}_2,\vec{p}_3\ldots\right\rangle$; occupation number representation for bose and fermi system many body systems $\left|n_1,n_2,\ldots\right\rangle$; a spin half particle taking the eigenstates usually of the $S_z$ operator, written sometimes as $\left|+\right\rangle$ and $\left|-\right\rangle$ or $\left|\uparrow\,\right\rangle$ and $\left|\downarrow\,\right\rangle$, etc as shorthand for $\left|\pm \hbar/2\right\rangle$; spherical harmonics as eigenfunctions of the $L^2$ and $L_z$ functions are conveniently written as $\left|l,m\right\rangle$ with $l=0,1,2,\ldots$ and $m=-l,-l+1,\ldots,l-1,l.$

So convenience of notation is one thing, but there's also a kind of 'lego' feeling to algebraic manipulations with dirac notation, take for instance the $S_x$ spin half operator in dirac notation as $S_x=\frac{\hbar}{2}(\left|\uparrow\right\rangle\left\langle\downarrow\right|+\left|\downarrow\right\rangle\left\langle\uparrow\right|)$, acting on a state like $\left|\uparrow\right\rangle$ one simply does

$$S_x\left|\uparrow\right\rangle=\frac{\hbar}{2}\left(\left|\uparrow\rangle\langle\downarrow\right|+\left|\downarrow\rangle\langle\uparrow\right|\right)\left|\uparrow\right\rangle=\frac{\hbar}{2}\left|\uparrow\rangle\langle\downarrow\mid\uparrow\right\rangle+\frac{\hbar}{2}\left|\downarrow\rangle\langle\uparrow\mid\uparrow\right\rangle=\frac{\hbar}{2}\left|\downarrow\right\rangle$$

since $\left\langle\uparrow\mid\uparrow\right\rangle=1$ and $\left\langle\downarrow\mid\uparrow\right\rangle=0$.

What makes it handy for quantum algorithms?

Say we have a suitable two level system for a qubit; this forms a two dimensional complex vector space $V$ say whose basis is denoted as $\left|0\right\rangle$ and $\left|1\right\rangle$. When we consider say $n$ qubits of this form, the states of the system live in a bigger space the tensor product space, $V^{\otimes n}$. Dirac notation can be rather handy here, the basis states will be labelled by strings of ones and zeros and one usually denotes a state e.g. $\left|1\right\rangle\otimes\left|0\right\rangle\otimes\left|0\right\rangle\otimes\left|1\right\rangle\equiv\left|1001\right\rangle$, and say we have a bit flip operator $X_i$ which interchanges $1\leftrightarrow 0$ on the $i$'th bit, this can act rather simply on the above strings e.g. $X_3\left|1001\right\rangle=\left|1011\right\rangle$, and taking a sum of operators or acting on a superposition of states works just as simply.

Slight caution: a state written as $\left|a,b\right\rangle$ doesn't always mean $\left|a\right\rangle\otimes\left|b\right\rangle$, for instance when you have two identical fermions with wave functions say $\phi_{k_1}(\vec{r}_1)$ and $\phi_{k_2}(\vec{r}_2)$, with labels indexing some basis set, then one might write the slater determinant state of the fermions $$\frac{1}{\sqrt{2}}\left(\phi_{k_1}(\vec{r}_1)\phi_{k_2}(\vec{r}_2)-\phi_{k_1}(\vec{r}_2)\phi_{k_2}(\vec{r}_1)\right)$$ in a shorthand as $\left|\phi_{k_1},\phi_{k_2}\right\rangle$ or even $\left|k_1,k_2\right\rangle\neq \left|k_1\right\rangle\otimes \left|k_2\right\rangle$.