02 July 2026

An insight about the Partial Trace

The Partial Trace is an important tool for analyzing the state of one or more qubits in a larger system. In this article, I'd like to share an insight that I've had involving the Partial Trace of Density Matrices.

Let's start with a simple pure state, where Alice holds qubit \(\left| u \right\rangle\) and Bob holds qubit \(\left| v \right\rangle\). The state of the total system can then be expressed as:
\[ \begin{aligned} \left| \psi \right\rangle &= \sum_{i,j \ \in\ \{0,1\}} \alpha_{ij} \left| ij \right\rangle \\[5pt] &= \alpha_{00}\left| 00 \right\rangle \ +\ \alpha_{01}\left| 01 \right\rangle \ +\ \alpha_{10}\left| 10 \right\rangle \ +\ \alpha_{11}\left| 11 \right\rangle \end{aligned} \]
where the various \(\alpha_{ij}\) represent the amplitudes of the basis states. The values of these amplitudes can be obtained by expressing the state in a slightly more elaborate fashion:
\[ \begin{aligned} \left| \psi \right\rangle &= \left| u \right\rangle \otimes \left| v \right\rangle = \begin{bmatrix} u_0\\ u_1 \end{bmatrix} \otimes \begin{bmatrix} v_0\\ v_1 \end{bmatrix} = \begin{bmatrix} u_0 \begin{bmatrix} v_0\\ v_1 \end{bmatrix}\\ u_1 \begin{bmatrix} v_0\\ v_1 \end{bmatrix}\\ \end{bmatrix} = \begin{bmatrix} u_0 v_0\\ u_0 v_1\\ u_1 v_0\\ u_1 v_1 \end{bmatrix} \\[5pt] &= u_0 v_0\left| 00 \right\rangle \ +\ u_0 v_1\left| 01 \right\rangle \ +\ u_1 v_0\left| 10 \right\rangle \ +\ u_1 v_1\left| 11 \right\rangle \end{aligned} \]
The density matrix, which describes the total system, can then be computed by taking the outer product of \( \left| \psi \right\rangle \) with its conjugate transpose:
\[ \begin{aligned} \rho &= \left| \psi \right\rangle\!\left\langle \psi \right| = \begin{bmatrix} u_0 v_0\\ u_0 v_1\\ u_1 v_0\\ u_1 v_1 \end{bmatrix} \begin{bmatrix} \overline{u_0 v_0} & \overline{u_0 v_1} & \overline{u_1 v_0} & \overline{u_1 v_1} \end{bmatrix} \\[5pt] &= \begin{bmatrix} u_0 v_0 \overline{u_0 v_0} & u_0 v_0 \overline{u_0 v_1} & u_0 v_0 \overline{u_1 v_0} & u_0 v_0 \overline{u_1 v_1}\\ u_0 v_1 \overline{u_0 v_0} & u_0 v_1 \overline{u_0 v_1} & u_0 v_1 \overline{u_1 v_0} & u_0 v_1 \overline{u_1 v_1}\\ u_1 v_0 \overline{u_0 v_0} & u_1 v_0 \overline{u_0 v_1} & u_1 v_0 \overline{u_1 v_0} & u_1 v_0 \overline{u_1 v_1}\\ u_1 v_1 \overline{u_0 v_0} & u_1 v_1 \overline{u_0 v_1} & u_1 v_1 \overline{u_1 v_0} & u_1 v_1 \overline{u_1 v_1} \end{bmatrix} \hspace{20pt}\text{(Matrix 1)} \\[5pt] &= \begin{bmatrix} \alpha_{00} \overline{\alpha_{00}} & \alpha_{00} \overline{\alpha_{01}} & \alpha_{00} \overline{\alpha_{10}} & \alpha_{00} \overline{\alpha_{11}}\\ \alpha_{01} \overline{\alpha_{00}} & \alpha_{01} \overline{\alpha_{01}} & \alpha_{01} \overline{\alpha_{10}} & \alpha_{01} \overline{\alpha_{11}}\\ \alpha_{10} \overline{\alpha_{00}} & \alpha_{10} \overline{\alpha_{01}} & \alpha_{10} \overline{\alpha_{10}} & \alpha_{10} \overline{\alpha_{11}}\\ \alpha_{11} \overline{\alpha_{00}} & \alpha_{11} \overline{\alpha_{01}} & \alpha_{11} \overline{\alpha_{10}} & \alpha_{11} \overline{\alpha_{11}} \end{bmatrix} \hspace{20pt}\text{(Matrix 2)} \end{aligned} \]
The Partial Trace
Taking the partial trace over a density matrix gives us a reduced density matrix, which expresses the state of the system from the perspective of an observer who can only see a part of it. For example, if we want to express the state of the system from Bob's perspective, we take the partial trace over Alice's qubit. The canonical way of computing the partial trace is:
\[ \begin{aligned} \rho^B = \mathit{Tr}_A \left( \rho \right) =& \sum_{i,j \ \in\ \{0,1\}} \left( \sum_{k \ \in\ \{0,1\}} \alpha_{ki} \overline{\alpha_{kj}} \right) \left| i \right\rangle\!\left\langle j \right| \\[5pt] =&\ \left( \alpha_{00}\overline{\alpha_{00}} + \alpha_{10}\overline{\alpha_{10}} \right) \left| 0 \right\rangle\!\left\langle 0 \right|\ + \\[5pt] &\ \left( \alpha_{00}\overline{\alpha_{01}} + \alpha_{10}\overline{\alpha_{11}} \right) \left| 0 \right\rangle\!\left\langle 1 \right|\ + \\[5pt] &\ \left( \alpha_{01}\overline{\alpha_{00}} + \alpha_{11}\overline{\alpha_{10}} \right) \left| 1 \right\rangle\!\left\langle 0 \right|\ + \\[5pt] &\ \left( \alpha_{01}\overline{\alpha_{01}} + \alpha_{11}\overline{\alpha_{11}} \right) \left| 1 \right\rangle\!\left\langle 1 \right| \\[5pt] =&\begin{bmatrix} \alpha_{00}\overline{\alpha_{00}} + \alpha_{10}\overline{\alpha_{10}} & \alpha_{00}\overline{\alpha_{01}} + \alpha_{10}\overline{\alpha_{11}}\\ \alpha_{01}\overline{\alpha_{00}} + \alpha_{11}\overline{\alpha_{10}} & \alpha_{01}\overline{\alpha_{01}} + \alpha_{11}\overline{\alpha_{11}} \end{bmatrix} \hspace{20pt}\text{(Matrix 3)} \end{aligned} \]
This method is often described as "summing over all possible states of Alice's qubit". Indeed, we add up all amplitudes where Alice's component is either \(u_0\) (the ones that are \(u_0 v_* \overline{u_0 v_*} \) or \(\alpha_{0*} \overline{\alpha_{0*}} \)) or \(u_1\) (the ones that are \(u_1 v_* \overline{u_1 v_*} \) or \(\alpha_{1*} \overline{\alpha_{1*}} \)) ("\(*\)" denotes a wildcard here: \(0\) or \(1\)).

Conversely, computing the system from Alice's perspective yields:
\[ \begin{aligned} \rho^A = \mathit{Tr}_B \left( \rho \right) =& \sum_{i,j \ \in\ \{0,1\}} \left( \sum_{k \ \in\ \{0,1\}} \alpha_{ik} \overline{\alpha_{jk}} \right) \left| i \right\rangle\!\left\langle j \right| \\[5pt] =&\ \left( \alpha_{00}\overline{\alpha_{00}} + \alpha_{01}\overline{\alpha_{01}} \right) \left| 0 \right\rangle\!\left\langle 0 \right|\ + \\[5pt] &\ \left( \alpha_{00}\overline{\alpha_{10}} + \alpha_{01}\overline{\alpha_{11}} \right) \left| 0 \right\rangle\!\left\langle 1 \right|\ + \\[5pt] &\ \left( \alpha_{10}\overline{\alpha_{00}} + \alpha_{11}\overline{\alpha_{01}} \right) \left| 1 \right\rangle\!\left\langle 0 \right|\ + \\[5pt] &\ \left( \alpha_{10}\overline{\alpha_{10}} + \alpha_{11}\overline{\alpha_{11}} \right) \left| 1 \right\rangle\!\left\langle 1 \right| \\[5pt] =&\begin{bmatrix} \alpha_{00}\overline{\alpha_{00}} + \alpha_{01}\overline{\alpha_{01}} & \alpha_{00}\overline{\alpha_{10}} + \alpha_{01}\overline{\alpha_{11}}\\ \alpha_{10}\overline{\alpha_{00}} + \alpha_{11}\overline{\alpha_{01}} & \alpha_{10}\overline{\alpha_{10}} + \alpha_{11}\overline{\alpha_{11}} \end{bmatrix} \hspace{20pt}\text{(Matrix 4)} \end{aligned} \]
The Geometric Interpretation
The partial trace of a density matrix can also be interpreted in a geometric fashion. If we take the density matrix as given by Matrix 2 and add some colour to it, we get:
\[ \begin{aligned} \begin{bmatrix} \bbox[#cc99ff, 3px]{\alpha_{00} \overline{\alpha_{00}}} & \bbox[#99ff99, 3px]{\alpha_{00} \overline{\alpha_{01}}} & \alpha_{00} \overline{\alpha_{10}} & \alpha_{00} \overline{\alpha_{11}}\\ \bbox[#99ccff, 3px]{\alpha_{01} \overline{\alpha_{00}}} & \bbox[#ff9999, 3px]{\alpha_{01} \overline{\alpha_{01}}} & \alpha_{01} \overline{\alpha_{10}} & \alpha_{01} \overline{\alpha_{11}}\\ \alpha_{10} \overline{\alpha_{00}} & \alpha_{10} \overline{\alpha_{01}} & \bbox[#cc99ff, 3px]{\alpha_{10} \overline{\alpha_{10}}} & \bbox[#99ff99, 3px]{\alpha_{10} \overline{\alpha_{11}}}\\ \alpha_{11} \overline{\alpha_{00}} & \alpha_{11} \overline{\alpha_{01}} & \bbox[#99ccff, 3px]{\alpha_{11} \overline{\alpha_{10}}} & \bbox[#ff9999, 3px]{\alpha_{11} \overline{\alpha_{11}}} \end{bmatrix} \end{aligned} \]
If we now "take out" the two coloured submatrices and add them together, we get:
\[ \begin{aligned} \begin{bmatrix} \bbox[#cc99ff, 3px]{\alpha_{00} \overline{\alpha_{00}}} & \bbox[#99ff99, 3px]{\alpha_{00} \overline{\alpha_{01}}}\\ \bbox[#99ccff, 3px]{\alpha_{01} \overline{\alpha_{00}}} & \bbox[#ff9999, 3px]{\alpha_{01} \overline{\alpha_{01}}} \end{bmatrix} + \begin{bmatrix} \bbox[#cc99ff, 3px]{\alpha_{10} \overline{\alpha_{10}}} & \bbox[#99ff99, 3px]{\alpha_{10} \overline{\alpha_{11}}}\\ \bbox[#99ccff, 3px]{\alpha_{11} \overline{\alpha_{10}}} & \bbox[#ff9999, 3px]{\alpha_{11} \overline{\alpha_{11}}} \end{bmatrix} = \begin{bmatrix} \bbox[#cc99ff, 3px]{\alpha_{00} \overline{\alpha_{00}} + \alpha_{10} \overline{\alpha_{10}}} & \bbox[#99ff99, 3px]{\alpha_{00} \overline{\alpha_{01}} + \alpha_{10} \overline{\alpha_{11}}}\\ \bbox[#99ccff, 3px]{\alpha_{01} \overline{\alpha_{00}} + \alpha_{11} \overline{\alpha_{10}}} & \bbox[#ff9999, 3px]{\alpha_{01} \overline{\alpha_{01}} + \alpha_{11} \overline{\alpha_{11}}} \end{bmatrix} \end{aligned} \]
The result is exactly Bob's reduced density matrix as given by Matrix 3! For Alice's reduced density matrix, we have to draw the colours a bit differently:
\[ \begin{aligned} \begin{bmatrix} \bbox[#cc99ff, 3px]{\alpha_{00} \overline{\alpha_{00}}} & \alpha_{00} \overline{\alpha_{01}} & \bbox[#99ff99, 3px]{\alpha_{00} \overline{\alpha_{10}}} & \alpha_{00} \overline{\alpha_{11}}\\ \alpha_{01} \overline{\alpha_{00}} & \bbox[#cc99ff, 3px]{\alpha_{01} \overline{\alpha_{01}}} & \alpha_{01} \overline{\alpha_{10}} & \bbox[#99ff99, 3px]{\alpha_{01} \overline{\alpha_{11}}}\\ \bbox[#99ccff, 3px]{\alpha_{10} \overline{\alpha_{00}}} & \alpha_{10} \overline{\alpha_{01}} & \bbox[#ff9999, 3px]{\alpha_{10} \overline{\alpha_{10}}} & \alpha_{10} \overline{\alpha_{11}}\\ \alpha_{11} \overline{\alpha_{00}} & \bbox[#99ccff, 3px]{\alpha_{11} \overline{\alpha_{01}}} & \alpha_{11} \overline{\alpha_{10}} & \bbox[#ff9999, 3px]{\alpha_{11} \overline{\alpha_{11}}} \end{bmatrix} \end{aligned} \]
Then, to obtain Alice's reduced density matrix as given by Matrix 4:
\[ \begin{aligned} \begin{bmatrix} \bbox[#cc99ff, 3px]{\alpha_{00} \overline{\alpha_{00}}} & \bbox[#99ff99, 3px]{\alpha_{00} \overline{\alpha_{10}}}\\ \bbox[#99ccff, 3px]{\alpha_{10} \overline{\alpha_{00}}} & \bbox[#ff9999, 3px]{\alpha_{10} \overline{\alpha_{10}}} \end{bmatrix} + \begin{bmatrix} \bbox[#cc99ff, 3px]{\alpha_{01} \overline{\alpha_{01}}} & \bbox[#99ff99, 3px]{\alpha_{01} \overline{\alpha_{11}}}\\ \bbox[#99ccff, 3px]{\alpha_{11} \overline{\alpha_{01}}} & \bbox[#ff9999, 3px]{\alpha_{11} \overline{\alpha_{11}}} \end{bmatrix} = \begin{bmatrix} \bbox[#cc99ff, 3px]{\alpha_{00} \overline{\alpha_{00}} + \alpha_{01} \overline{\alpha_{01}}} & \bbox[#99ff99, 3px]{\alpha_{00} \overline{\alpha_{10}} + \alpha_{01} \overline{\alpha_{11}}}\\ \bbox[#99ccff, 3px]{\alpha_{10} \overline{\alpha_{00}} + \alpha_{11} \overline{\alpha_{01}}} & \bbox[#ff9999, 3px]{\alpha_{10} \overline{\alpha_{10}} + \alpha_{11} \overline{\alpha_{11}}} \end{bmatrix} \end{aligned} \]
So far, pretty basic textbook stuff. But why does this work? Why do these summations and their geometric interpretation lead to how Alice and Bob observe the total system from their own perspective?

Reversing the tensor product
I'm sure the insight that I got when thinking about this question isn't new, but since I couldn't find it in any of the textbooks or articles that I studied, I decided to write it up. Here goes:

To get the density matrix of the total system, as given by Matrix 1, we took the tensor product of \( \left| v \right\rangle \) and \( \left| w \right\rangle \), which yielded \( \left| \psi \right\rangle \), and then we took the outer product of \( \left| \psi \right\rangle \) with its conjugate transpose.

We could, however, also do it the other way around. Instead of computing the outer product of the tensor product, we could also compute the tensor product of the outer products. These are equivalent. So, instead of:
\[ \begin{aligned} \rho = \left| \psi \right\rangle\!\left\langle \psi \right| = \left( \left| u \right\rangle \otimes \left| v \right\rangle \right) \left( \left\langle u \right| \otimes \left\langle v \right| \right) \end{aligned} \]
we get:
\[ \begin{aligned} \rho = \left| u \right\rangle\!\left\langle u \right| \otimes \left| v \right\rangle\!\left\langle v \right| \end{aligned} \]
Of course, this does imply that the qubits are unentangled, because if they are entangled, they won't have their own separate state vectors and you can't create the outer products of those either. Despite this limitation, let's explore this equation in detail and see what insight it can bring us:
\[ \begin{aligned} \rho &= \left| u \right\rangle\!\left\langle u \right| \otimes \left| v \right\rangle\!\left\langle v \right| \\[5pt] &= \begin{bmatrix} u_0\\ u_1 \end{bmatrix} \begin{bmatrix} \overline{u_0} & \overline{u_1} \end{bmatrix} \otimes \begin{bmatrix} v_0\\ v_1 \end{bmatrix} \begin{bmatrix} \overline{v_0} & \overline{v_1} \end{bmatrix} \\[5pt] &= \begin{bmatrix} u_0 \overline{u_0} & u_0 \overline{u_1} \\ u_1 \overline{u_0} & u_1 \overline{u_1} \\ \end{bmatrix} \otimes \begin{bmatrix} v_0 \overline{v_0} & v_0 \overline{v_1} \\ v_1 \overline{v_0} & v_1 \overline{v_1} \\ \end{bmatrix} \\[5pt] &= \begin{bmatrix} u_0 \overline{u_0} \begin{bmatrix} v_0 \overline{v_0} & v_0 \overline{v_1} \\ v_1 \overline{v_0} & v_1 \overline{v_1} \\ \end{bmatrix} & u_0 \overline{u_1} \begin{bmatrix} v_0 \overline{v_0} & v_0 \overline{v_1} \\ v_1 \overline{v_0} & v_1 \overline{v_1} \\ \end{bmatrix} \\ u_1 \overline{u_0} \begin{bmatrix} v_0 \overline{v_0} & v_0 \overline{v_1} \\ v_1 \overline{v_0} & v_1 \overline{v_1} \\ \end{bmatrix} & u_1 \overline{u_1} \begin{bmatrix} v_0 \overline{v_0} & v_0 \overline{v_1} \\ v_1 \overline{v_0} & v_1 \overline{v_1} \\ \end{bmatrix} \\ \end{bmatrix} \hspace{20pt}\text{(Matrix 5)} \\[5pt] &= \begin{bmatrix} u_0 \overline{u_0} v_0 \overline{v_0} & u_0 \overline{u_0} v_0 \overline{v_1} & u_0 \overline{u_1} v_0 \overline{v_0} & u_0 \overline{u_1} v_0 \overline{v_1}\\ u_0 \overline{u_0} v_1 \overline{v_0} & u_0 \overline{u_0} v_1 \overline{v_1} & u_0 \overline{u_1} v_1 \overline{v_0} & u_0 \overline{u_1} v_1 \overline{v_1}\\ u_1 \overline{u_0} v_0 \overline{v_0} & u_1 \overline{u_0} v_0 \overline{v_1} & u_1 \overline{u_1} v_0 \overline{v_0} & u_1 \overline{u_1} v_0 \overline{v_1}\\ u_1 \overline{u_0} v_1 \overline{v_0} & u_1 \overline{u_0} v_1 \overline{v_1} & u_1 \overline{u_1} v_1 \overline{v_0} & u_1 \overline{u_1} v_1 \overline{v_1} \end{bmatrix} \hspace{20pt}\text{(Matrix 6)} \end{aligned} \]
Matrix 6 is obviously equivalent to Matrix 1: since complex multiplication is commutative, for each entry of Matrix 1, just move the u's to the left and the v's to the right and you end up with Matrix 6.

But let's focus on Matrix 5. According to the geometric interpretation for computing Bob's reduced density matrix, we should add up the following submatrices:
\[ \begin{aligned} \begin{bmatrix} \bbox[#ffcc99, 3px]{ u_0 \overline{u_0} \begin{bmatrix} v_0 \overline{v_0} & v_0 \overline{v_1} \\ v_1 \overline{v_0} & v_1 \overline{v_1} \\ \end{bmatrix}} & u_0 \overline{u_1} \begin{bmatrix} v_0 \overline{v_0} & v_0 \overline{v_1} \\ v_1 \overline{v_0} & v_1 \overline{v_1} \\ \end{bmatrix} \\ u_1 \overline{u_0} \begin{bmatrix} v_0 \overline{v_0} & v_0 \overline{v_1} \\ v_1 \overline{v_0} & v_1 \overline{v_1} \\ \end{bmatrix} & \bbox[#ffcc99, 3px]{ u_1 \overline{u_1} \begin{bmatrix} v_0 \overline{v_0} & v_0 \overline{v_1} \\ v_1 \overline{v_0} & v_1 \overline{v_1} \\ \end{bmatrix}} \\ \end{bmatrix} \end{aligned} \]
This is a nice illustration of the partial trace over Alice's subsystem: the trace is the sum of the diagonal and here, we sum the two components which correspond to the diagonal values of the density matrix of Alice's subsystem in isolation (\( \left| u \right\rangle\!\left\langle u \right| \)). It gives us:
\[ \begin{aligned} \rho^B = u_0 \overline{u_0} \begin{bmatrix} v_0 \overline{v_0} & v_0 \overline{v_1} \\ v_1 \overline{v_0} & v_1 \overline{v_1} \\ \end{bmatrix} \ + \ u_1 \overline{u_1} \begin{bmatrix} v_0 \overline{v_0} & v_0 \overline{v_1} \\ v_1 \overline{v_0} & v_1 \overline{v_1} \\ \end{bmatrix} \end{aligned} \]
The inner product of a qubit with itself must always be equal to 1, since the total probability of all outcomes must be 1. Since \( u_0 \) and \( u_1 \) are the amplitudes of Alice's qubit, we know that \( u_0 \overline{u_0} + u_1 \overline{u_1} = 1 \). Therefore, the reduced density matrix of Bob is equal to:
\[ \begin{aligned} \rho^B = \begin{bmatrix} v_0 \overline{v_0} & v_0 \overline{v_1} \\ v_1 \overline{v_0} & v_1 \overline{v_1} \\ \end{bmatrix} \end{aligned} \]
This is exactly the same as the outer product of Bob's qubit with its conjugate transpose or, in other words, the density matrix of Bob's qubit in isolation. Similarly, if we use Matrix 5 to determine Alice's reduced density matrix, we get:
\[ \begin{aligned} \begin{bmatrix} \bbox[#ffcc99, 3px]{ u_0 \overline{u_0} } \begin{bmatrix} \bbox[#ffcc99, 3px]{ v_0 \overline{v_0} } & v_0 \overline{v_1} \\ v_1 \overline{v_0} & \bbox[#ffcc99, 3px]{ v_1 \overline{v_1} } \\ \end{bmatrix} & \bbox[#ffcc99, 3px]{ u_0 \overline{u_1} } \begin{bmatrix} \bbox[#ffcc99, 3px]{ v_0 \overline{v_0} } & v_0 \overline{v_1} \\ v_1 \overline{v_0} & \bbox[#ffcc99, 3px]{ v_1 \overline{v_1} } \\ \end{bmatrix} \\ \bbox[#ffcc99, 3px]{ u_1 \overline{u_0} } \begin{bmatrix} \bbox[#ffcc99, 3px]{ v_0 \overline{v_0} } & v_0 \overline{v_1} \\ v_1 \overline{v_0} & \bbox[#ffcc99, 3px]{ v_1 \overline{v_1} } \\ \end{bmatrix} & \bbox[#ffcc99, 3px]{ u_1 \overline{u_1} } \begin{bmatrix} \bbox[#ffcc99, 3px]{ v_0 \overline{v_0} } & v_0 \overline{v_1} \\ v_1 \overline{v_0} & \bbox[#ffcc99, 3px]{ v_1 \overline{v_1} } \\ \end{bmatrix} \\ \end{bmatrix} \end{aligned} \]
Again, this is a good illustration of the partial trace over Bob's subsystem: we sum the components which correspond to the diagonal values of the density matrix of Bob's subsystem in isolation (\( \left| v \right\rangle\!\left\langle v \right| \)). It gives us:
\[ \begin{aligned} \rho^A = \begin{bmatrix} u_0 \overline{u_0} \left( v_0 \overline{v_0} + v_1 \overline{v_1} \right) & u_0 \overline{u_1} \left( v_0 \overline{v_0} + v_1 \overline{v_1} \right) \\ u_1 \overline{u_0} \left( v_0 \overline{v_0} + v_1 \overline{v_1} \right) & u_1 \overline{u_1} \left( v_0 \overline{v_0} + v_1 \overline{v_1} \right) \end{bmatrix} \end{aligned} \]
Analogous to Alice's amplitudes, we know that \( v_0 \overline{v_0} + v_1 \overline{v_1} = 1 \). Therefore, the reduced density matrix of Alice is equal to:
\[ \begin{aligned} \rho^A = \begin{bmatrix} u_0 \overline{u_0} & u_0 \overline{u_1} \\ u_1 \overline{u_0} & u_1 \overline{u_1} \\ \end{bmatrix} \end{aligned} \]
Like Bob's, Alice's reduced density matrix is equal to the density matrix of Alice's qubit in isolation.

So, if we take Matrix 5 (which is a blueprint for calculating the density matrix by taking the tensor product of the separate components) as a base, and apply the geometric interpretation of the partial trace (which is equivalent to the summation notation), we can see that the partial trace effectively reverses the calculation of the density matrix! It yields the separate components that formed the density matrix of the total system in the first place! Of course, this only literally applies when the two qubits are unentangled, but it still provides a nice insight into why the partial trace works the way it does.

If we look at simple multiplication, then 2*10 = 20, but if you have 20, you don't know whether it came from 2*10 or 4*5. That information is lost when you do the multiplication: the value 20 is only a single number and therefore contains less information than the original components combined. With density matrices that are created from qubits, this does not apply. Since the density matrix of the total system has 16 complex values, it makes sense that those values contain enough information to reconstruct the 2 qubits with 2 complex values each that created it in the first place.

I hope this small insight of mine is useful to you. Thanks for reading!

09 January 2025

The CHSH Game is best played on the Bloch Sphere

The CHSH game is a fun game, that shows the power of entangled qubits. In this article, I will take an alternative approach to this game, using the Bloch Sphere as the playing field.

Prerequisite knowledge: Let's start with a quick recap of how the CHSH game is played: There are 2 players, Alice and Bob, and a referee, Charlie. Alice and Bob are in separate rooms, they cannot communicate. Charlie gives Alice a random bit \(x \in \left\{ 0, 1 \right\}\). He also gives Bob a random bit \(y \in \left\{ 0, 1 \right\}\). Alice must return a bit \(a \in \left\{ 0, 1 \right\}\) and Bob must return a bit \(b \in \left\{ 0, 1 \right\}\). They win if \(x \wedge y = a \oplus b\), where \(\oplus\) denotes the XOR operation.

For example, if Alice gets \(x=1\) and Bob gets \(y=0\), then \(x \wedge y = 1 \wedge 0 = 0\) and the winning combinations are \(a=0, b=0\) and \(a=1, b=1\), because in those cases \(a \oplus b = 0\).

In the classical solution, Alice and Bob can simply always both return 0. Then, they will win all cases, except when they both get a 1 from Charlie. This is a win rate of 75%. As it turns out, they cannot actually do better than that. However, if they share an entangled pair of qubits, they can significantly improve those odds.

We will go through a detailed, step-by-step explanation of the quantum solution in a bit, but first, let me explain why I wrote this article in the first place. After all, there are already quite a few explanations of this on the Internet. The traditional explanations of how this quantum solution works, often use these "rotated hooks" as measuring bases for Alice and Bob:


The equations for Bob's measuring bases (the green arrows) are then as follows:
\[ \begin{aligned} \left| m_0 \right\rangle &= \cos \frac{\pi}{8} \left| 0 \right\rangle + \sin \frac{\pi}{8} \left| 1 \right\rangle \\[5pt] \left| m_1 \right\rangle &= -\sin \frac{\pi}{8} \left| 0 \right\rangle + \cos \frac{\pi}{8} \left| 1 \right\rangle \\[5pt] \left| n_0 \right\rangle &= \cos \frac{\pi}{8} \left| 0 \right\rangle - \sin \frac{\pi}{8} \left| 1 \right\rangle \\[5pt] \left| n_1 \right\rangle &= \sin \frac{\pi}{8} \left| 0 \right\rangle + \cos \frac{\pi}{8} \left| 1 \right\rangle \end{aligned} \]
When I was studying this, the approach wasn't immediately clear to me. Why do we need those rotated hooks? They are supposed to be rotated \( \frac{\pi}{8} \) from each other, but why do they have to be rotated about those specific angles? Can't they be rotated about any other angle? And those equations... what's the pattern there? They don't seem to have any kind of symmetry?

A few weeks before this, I had studied the Bloch Sphere extensively. I thought, you know what? Let's use the Bloch Sphere instead and see what happens! Since we didn't seem to need complex numbers here, I took the projection of the Bloch Sphere along the \( x-z \) axes, basically with \( \phi = 0 \). State vectors in this plane can then be expressed as follows:
\[ \begin{aligned} \left| v \right\rangle &= \cos \frac{\theta}{2} \left| 0 \right\rangle + e^{i\phi} \sin \frac{\theta}{2} \left| 1 \right\rangle &(\text{Bloch sphere equation}) \\[5pt] &= \cos \frac{\theta}{2} \left| 0 \right\rangle + \sin \frac{\theta}{2} \left| 1 \right\rangle &(\phi = 0) \end{aligned} \]
According to the standard quantum solution to the CHSH game, we need 4 measuring bases that are rotated \( \frac{\pi}{8} \) from each other. We will look at how to use these to solve the game later, but first, let's draw them. As you can see above, the Bloch Sphere equation divides the z-angle by 2. So in order to express 4 measuring bases that are rotated \( \frac{\pi}{8} \) from each other, we need to rotate them \( \frac{\pi}{4} \) from each other on the Bloch Sphere. In the \( x-z \) plane (with \( \phi = 0 \)), this then looks as follows:
\( \left| 0 \right\rangle \)
\( \left| 1 \right\rangle \)
\( \left| + \right\rangle \)
\( \left| - \right\rangle \)
\( \left| m_0 \right\rangle \)
\( \left| m_1 \right\rangle \)
\( \left| n_0 \right\rangle \)
\( \left| n_1 \right\rangle \)
\( 0 \)
\( \frac{1}{4}\pi \)
\( -\frac{1}{4}\pi \)
\( \frac{1}{2}\pi \)
\( -\frac{1}{2}\pi \)
\( \frac{3}{4}\pi \)
\( -\frac{3}{4}\pi \)
\( \pi \)
\( x \)
\( z \)
\( \theta \)
Now this looks a whole lot better! In fact, it's the only way you can draw 4 bases (with 2 vectors each) in the \( x-z \) plane that is perfectly symmetrical! It has reflective symmetry in the \(x\) and \(z\) axes and rotational symmetry every \( \frac{1}{4}\pi \). Later, we'll see why this is important, but first, let's see what the equations for all 8 basis vectors look like. Let's start with Alice's. These should be straightforward, but for completeness sake, let's verify them anyway:
\[ \begin{aligned} \left| 0 \right\rangle &= \cos \frac{0}{2} \left| 0 \right\rangle + \sin \frac{0}{2} \left| 1 \right\rangle &&= \left| 0 \right\rangle \\[5pt] \left| 1 \right\rangle &= \cos \frac{\pi}{2} \left| 0 \right\rangle + \sin \frac{\pi}{2} \left| 1 \right\rangle &&= \left| 1 \right\rangle \\[5pt] \left| + \right\rangle &= \cos \frac{\frac{1}{2} \pi}{2} \left| 0 \right\rangle + \sin \frac{\frac{1}{2} \pi}{2} \left| 1 \right\rangle &&= \frac{1}{\sqrt{2}} \left| 0 \right\rangle + \frac{1}{\sqrt{2}} \left| 1 \right\rangle \\[5pt] \left| - \right\rangle &= \cos \frac{-\frac{1}{2} \pi}{2} \left| 0 \right\rangle + \sin \frac{-\frac{1}{2} \pi}{2} \left| 1 \right\rangle &&= \frac{1}{\sqrt{2}} \left| 0 \right\rangle - \frac{1}{\sqrt{2}} \left| 1 \right\rangle \\[5pt] \end{aligned} \]
Now for Bob's. Let's see if they will be any different than the ones from the "rotated hooks" approach. By the way, if you're working with the Bloch Sphere a lot, this page is your friend!
\[ \begin{aligned} \left| m_0 \right\rangle &= \cos \frac{\frac{1}{4} \pi}{2} \left| 0 \right\rangle + \sin \frac{\frac{1}{4} \pi}{2} \left| 1 \right\rangle &&= \cos \frac{\pi}{8} \left| 0 \right\rangle + \sin \frac{\pi}{8} \left| 1 \right\rangle \\[5pt] \left| m_1 \right\rangle &= \cos \frac{-\frac{3}{4} \pi}{2} \left| 0 \right\rangle + \sin \frac{-\frac{3}{4} \pi}{2} \left| 1 \right\rangle &&= \sin \frac{\pi}{8} \left| 0 \right\rangle - \cos \frac{\pi}{8} \left| 1 \right\rangle \\[5pt] \left| n_0 \right\rangle &= \cos \frac{-\frac{1}{4} \pi}{2} \left| 0 \right\rangle + \sin \frac{-\frac{1}{4} \pi}{2} \left| 1 \right\rangle &&= \cos \frac{\pi}{8} \left| 0 \right\rangle - \sin \frac{\pi}{8} \left| 1 \right\rangle \\[5pt] \left| n_1 \right\rangle &= \cos \frac{\frac{3}{4} \pi}{2} \left| 0 \right\rangle + \sin \frac{\frac{3}{4} \pi}{2} \left| 1 \right\rangle &&= \sin \frac{\pi}{8} \left| 0 \right\rangle + \cos \frac{\pi}{8} \left| 1 \right\rangle \\[5pt] \end{aligned} \]
That's interesting! The equations for \(\left| m_0 \right\rangle\), \(\left| n_0 \right\rangle\) and \(\left| n_1 \right\rangle\)are the same, but the one for \(\left| m_1 \right\rangle\) is now multiplied by a factor of -1! This is a global phase, so it won't affect any measurement, but it does mean that the equations now look perfectly symmetrical!

(For the astute reader, who notices that \(\theta\) should ideally always be in the range \([0,\pi]\): if you remove the minuses from the \(\theta = -\frac{1}{4} \pi\), \(\theta = -\frac{1}{2} \pi\) and \(\theta = -\frac{3}{4} \pi\) values and calculate those vectors with \(\phi = \pi\) instead, you will see that it will lead to exactly the same outcomes, since \(\cos-\theta = \cos\theta\), \(\sin-\theta = -\sin\theta\) and \(e^{i\pi} = -1\). I thought I'd keep it simple by leaving the complex numbers out of this article.)

By moving all bases to the Bloch Sphere, we have obtained a perfectly even and symmetrical distribution of basis vectors, with perfectly symmetrical equations. This is going to help a lot in understanding why the quantum solution to the CHSH game works. But before we get there, let's have a look at the actual quantum strategy.

The Quantum Strategy for the CHSH Game
In the Quantum Strategy, Alice and Bob share an entangled pair of qubits. More precisely, they share a Bell Pair: \(\left| \psi \right\rangle = \frac{1}{\sqrt{2}} \left| 00 \right\rangle + \frac{1}{\sqrt{2}} \left| 11 \right\rangle\). We have 4 bases for measuring a qubit: \(\{\left| 0 \right\rangle, \left| 1 \right\rangle\}\) and \(\{\left| + \right\rangle, \left| - \right\rangle\}\) for Alice and \(\{\left| m_0 \right\rangle, \left| m_1 \right\rangle\}\) and \(\{\left| n_0 \right\rangle, \left| n_1 \right\rangle\}\) for Bob. These bases are orthogonal, which is illustrated by the fact that their vectors lie on opposite ends of the Bloch Sphere.

The trick is, that Alice and Bob use their input bit (resp. \(x\) and \(y\)) to determine which basis they will use for measuring their half of the entangled pair. They will then use the result of their measurement to determine their output bit (resp. \(a\) and \(b\)). They will do this according to the following schema, where the colors illustrate what the value of their output bit will be:
\[ \begin{aligned} x = 0\!:\quad &\text{Alice measures in} & \{ &\bbox[#b3fff0, 3px]{\left| 0 \right\rangle}, & &\bbox[#ecb3ff, 3px]{\left| 1 \right\rangle} \} \\ x = 1\!:\quad &\text{Alice measures in} & \{ &\bbox[#b3fff0, 3px]{\left| + \right\rangle}, & &\bbox[#ecb3ff, 3px]{\left| - \right\rangle} \} \\ & & &\downarrow & &\downarrow \\ &\text{Alice returns} &a =\ &\bbox[#b3fff0, 3px]{0} & &\bbox[#ecb3ff, 3px]{1} \\[20pt] y = 0\!:\quad &\text{Bob measures in} & \{ &\bbox[#b3ffb3, 3px]{\left| m_0 \right\rangle}, & &\bbox[#ffcccc, 3px]{\left| m_1 \right\rangle} \} \\ y = 1\!:\quad &\text{Bob measures in} & \{ &\bbox[#b3ffb3, 3px]{\left| n_0 \right\rangle}, & &\bbox[#ffcccc, 3px]{\left| n_1 \right\rangle} \} \\ & & &\downarrow & &\downarrow \\ &\text{Bob returns} &b =\ &\bbox[#b3ffb3, 3px]{0} & &\bbox[#ffcccc, 3px]{1} \end{aligned} \]
There are four possible cases, because both \(x\) and \(y\) can be 0 or 1. We will explore two of these cases in detail, the other two will be left as an exercise for the reader. After exploring the two cases, we will have a look at why this strategy actually works.

Case 1
Let's test the first case! In this case, \(x = 0\) and \(y = 0\), so \(x \wedge y = 0\). \(a \oplus b\) must then also be 0. This is true if \(a = b = 0\) or \(a = b = 1\).

Since \(x = 0\), Alice will measure in the \(\{\left| 0 \right\rangle, \left| 1 \right\rangle\}\) basis and since \(y = 0\), Bob will measure in the \(\{\left| m_0 \right\rangle, \left| m_1 \right\rangle\}\) basis. This means that we either want Alice to get \(\left| 0 \right\rangle\) and Bob to get \(\left| m_0 \right\rangle\), or Alice to get \(\left| 1 \right\rangle\) and Bob to get \(\left| m_1 \right\rangle\).

The probability of the first one, Alice getting \(\left| 0 \right\rangle\) and Bob getting \(\left| m_0 \right\rangle\), is calculated as follows:
\[ \begin{aligned} \left\| (\left\langle 0 \right| \otimes \left\langle m_0 \right|) \left| \psi \right\rangle \right\|^{2} &= \left\| \left( \begin{bmatrix} \overline{1} & \overline{0} \end{bmatrix} \otimes \begin{bmatrix} \overline{\cos \frac{\pi}{8}} & \overline{\sin \frac{\pi}{8}} \end{bmatrix} \right) \begin{bmatrix} \frac{1}{\sqrt{2}}\\ 0\\ 0\\ \frac{1}{\sqrt{2}} \end{bmatrix} \right\|^{2} \\[5pt] &= \left\| \begin{bmatrix} \cos \frac{\pi}{8} & \sin \frac{\pi}{8} & 0 & 0 \end{bmatrix} \begin{bmatrix} \frac{1}{\sqrt{2}}\\ 0\\ 0\\ \frac{1}{\sqrt{2}} \end{bmatrix} \right\|^{2} \\[5pt] &= \left\| \frac{1}{\sqrt{2}}\cos \frac{\pi}{8} \right\|^{2} \\[5pt] &= \frac{1}{2}\cos^2 \frac{\pi}{8} \end{aligned} \]
The probability of the second one, Alice getting \(\left| 1 \right\rangle\) and Bob getting \(\left| m_1 \right\rangle\), is calculated as follows:
\[ \begin{aligned} \left\| (\left\langle 1 \right| \otimes \left\langle m_1 \right|) \left| \psi \right\rangle \right\|^{2} &= \left\| \left( \begin{bmatrix} \overline{0} & \overline{1} \end{bmatrix} \otimes \begin{bmatrix} \overline{\sin \frac{\pi}{8}} & \overline{-\cos \frac{\pi}{8}} \end{bmatrix} \right) \begin{bmatrix} \frac{1}{\sqrt{2}}\\ 0\\ 0\\ \frac{1}{\sqrt{2}} \end{bmatrix} \right\|^{2} \\[5pt] &= \left\| \begin{bmatrix} 0 & 0 & \sin \frac{\pi}{8} & -\cos \frac{\pi}{8} \end{bmatrix} \begin{bmatrix} \frac{1}{\sqrt{2}}\\ 0\\ 0\\ \frac{1}{\sqrt{2}} \end{bmatrix} \right\|^{2} \\[5pt] &= \left\| -\frac{1}{\sqrt{2}}\cos \frac{\pi}{8} \right\|^{2} \\[5pt] &= \frac{1}{2}\cos^2 \frac{\pi}{8} \end{aligned} \]
They win if either will happen, which, by summing the two separate values, has probability:
\[ \frac{1}{2}\cos^2 \frac{\pi}{8} \ +\ \frac{1}{2}\cos^2 \frac{\pi}{8} \ =\ \cos^2 \frac{\pi}{8} \ \approx\ 0.85 \ =\ 85\% \]
This is significantly better than the win rate of 75% for the classical solution, although that 75% was for all cases combined, not just one case, so let's move on!

Case 2
For the second case, we take \(x = 1\) and \(y = 1\), so \(x \wedge y = 1\). \(a \oplus b\) must then also be 1. This is true if \(a = 0\) and \(b = 1\) or if \(a = 1\) and \(b = 0\).

Since \(x = 1\), Alice will measure in the \(\{\left| + \right\rangle, \left| - \right\rangle\}\) basis and since \(y = 1\), Bob will measure in the \(\{\left| n_0 \right\rangle, \left| n_1 \right\rangle\}\) basis. This means that we either want Alice to get \(\left| + \right\rangle\) and Bob to get \(\left| n_1 \right\rangle\), or Alice to get \(\left| - \right\rangle\) and Bob to get \(\left| n_0 \right\rangle\).

The probability of the first one, Alice getting \(\left| + \right\rangle\) and Bob getting \(\left| n_1 \right\rangle\), is calculated as follows:
\[ \begin{aligned} \left\| (\left\langle + \right| \otimes \left\langle n_1 \right|) \left| \psi \right\rangle \right\|^{2} &= \left\| \left( \begin{bmatrix} \overline{\frac{1}{\sqrt{2}}} & \overline{\frac{1}{\sqrt{2}}} \end{bmatrix} \otimes \begin{bmatrix} \overline{\sin \frac{\pi}{8}} & \overline{\cos \frac{\pi}{8}} \end{bmatrix} \right) \begin{bmatrix} \frac{1}{\sqrt{2}}\\ 0\\ 0\\ \frac{1}{\sqrt{2}} \end{bmatrix} \right\|^{2} \\[5pt] &= \left\| \begin{bmatrix} \frac{1}{\sqrt{2}}\sin \frac{\pi}{8} & \frac{1}{\sqrt{2}}\cos \frac{\pi}{8} & \frac{1}{\sqrt{2}}\sin \frac{\pi}{8} & \frac{1}{\sqrt{2}}\cos \frac{\pi}{8} \end{bmatrix} \begin{bmatrix} \frac{1}{\sqrt{2}}\\ 0\\ 0\\ \frac{1}{\sqrt{2}} \end{bmatrix} \right\|^{2} \\[5pt] &= \left\| \frac{1}{2}\sin \frac{\pi}{8} + \frac{1}{2}\cos \frac{\pi}{8} \right\|^{2} \\[5pt] &= \frac{1}{4}\sin^2 \frac{\pi}{8} \ +\ \frac{1}{2} \sin\frac{\pi}{8} \cos\frac{\pi}{8} \ +\ \frac{1}{4}\cos^2 \frac{\pi}{8} \end{aligned} \]
The probability of the second one, Alice getting \(\left| - \right\rangle\) and Bob getting \(\left| n_0 \right\rangle\), is calculated as follows:
\[ \begin{aligned} \left\| (\left\langle - \right| \otimes \left\langle n_0 \right|) \left| \psi \right\rangle \right\|^{2} &= \left\| \left( \begin{bmatrix} \overline{\frac{1}{\sqrt{2}}} & \overline{-\frac{1}{\sqrt{2}}} \end{bmatrix} \otimes \begin{bmatrix} \overline{\cos \frac{\pi}{8}} & \overline{-\sin \frac{\pi}{8}} \end{bmatrix} \right) \begin{bmatrix} \frac{1}{\sqrt{2}}\\ 0\\ 0\\ \frac{1}{\sqrt{2}} \end{bmatrix} \right\|^{2} \\[5pt] &= \left\| \begin{bmatrix} \frac{1}{\sqrt{2}}\cos \frac{\pi}{8} & -\frac{1}{\sqrt{2}}\sin \frac{\pi}{8} & -\frac{1}{\sqrt{2}}\cos \frac{\pi}{8} & \frac{1}{\sqrt{2}}\sin \frac{\pi}{8} \end{bmatrix} \begin{bmatrix} \frac{1}{\sqrt{2}}\\ 0\\ 0\\ \frac{1}{\sqrt{2}} \end{bmatrix} \right\|^{2} \\[5pt] &= \left\| \frac{1}{2}\cos \frac{\pi}{8} + \frac{1}{2}\sin \frac{\pi}{8} \right\|^{2} \\[5pt] &= \frac{1}{4}\cos^2 \frac{\pi}{8} \ +\ \frac{1}{2} \cos\frac{\pi}{8} \sin\frac{\pi}{8} \ +\ \frac{1}{4}\sin^2 \frac{\pi}{8} \end{aligned} \]
They win if either will happen, which, by summing the two separate values, has the following probability (again, keep this one at hand!):
\[ \begin{aligned} &\frac{1}{2}\cos^2 \frac{\pi}{8} \ +\ \cos\frac{\pi}{8} \sin\frac{\pi}{8} \ +\ \frac{1}{2}\sin^2 \frac{\pi}{8} \\[5pt] =\ &\frac{1}{2}\left( \cos^2 \frac{\pi}{8} + \sin^2 \frac{\pi}{8} \right) \ +\ \cos\frac{\pi}{8} \sin\frac{\pi}{8} \\[5pt] =\ &\frac{1}{2} \ +\ \cos\frac{\pi}{8} \sin\frac{\pi}{8} \\[5pt] =\ &\frac{1}{2} \ +\ \frac{1}{2}\sin\left( \frac{\pi}{8} + \frac{\pi}{8} \right) \ -\ \frac{1}{2}\sin\left( \frac{\pi}{8} - \frac{\pi}{8} \right) \\[5pt] =\ &\frac{1}{2} \ +\ \frac{1}{2}\sin\frac{\pi}{4} \ -\ \frac{1}{2}\sin 0 \\[5pt] =\ &\frac{1}{2} \ +\ \frac{1}{2}\cos\frac{\pi}{4} \\[5pt] =\ &\frac{1 + \cos\left( 2 \cdot \frac{\pi}{8} \right)}{2} \\[5pt] =\ &\cos^2 \frac{\pi}{8} \ \approx\ 0.85 \ =\ 85\% \end{aligned} \]
Success again! It turns out that the other two cases also resolve to a win rate of \( \cos^2 \frac{\pi}{8} \), meaning that \( \cos^2 \frac{\pi}{8} \) is actually the overall win rate for all cases combined. So, why is this?

Why does this work?
To see why the Quantum Strategy always gives the same probability for each of the cases, let's have a look at the outcomes that we want for each case:
\[ \begin{aligned} &\text{For}\ x = 0, y = 0, \text{we want outcome} \left\{ \left| 0 \right\rangle, \left| m_0 \right\rangle \right\}\ \text{or} \left\{ \left| 1 \right\rangle, \left| m_1 \right\rangle \right\} \\[5pt] &\text{For}\ x = 0, y = 1, \text{we want outcome} \left\{ \left| 0 \right\rangle, \left| n_0 \right\rangle \right\}\ \text{or} \left\{ \left| 1 \right\rangle, \left| n_1 \right\rangle \right\} \\[5pt] &\text{For}\ x = 1, y = 0, \text{we want outcome} \left\{ \left| + \right\rangle, \left| m_0 \right\rangle \right\}\ \text{or} \left\{ \left| - \right\rangle, \left| m_1 \right\rangle \right\} \\[5pt] &\text{For}\ x = 1, y = 1, \text{we want outcome} \left\{ \left| + \right\rangle, \left| n_1 \right\rangle \right\}\ \text{or} \left\{ \left| - \right\rangle, \left| n_0 \right\rangle \right\} \\[5pt] \end{aligned} \]
Now have a look at all of these desired outcomes on the Bloch Sphere. Their vectors are always right next to each other! Because Alice's and Bob's qubits are entangled, the closer the measuring bases are to each other, the higher the probability that the outcomes are close to each other as well. This maximizes the probability that Alice and Bob will indeed measure a result that will win them the game. The Bloch Sphere makes this much more obvious than the "rotated hooks".

Moreover, it is also clear that a win rate of \( \cos^2 \frac{\pi}{8} \) is indeed the maximum win rate that is achievable when Alice and Bob share an entangled pair (as is proven by Tsirelson's bound). This is because there is no other way to distribute 4 bases on the Bloch Sphere that is more optimal than this one. Move two vectors of a desired outcome closer to each other, and two other ones will move away from each other. You can't do better than the perfectly symmetrical distribution.

Conclusion
Playing the CHSH game on the Bloch Sphere gives us a symmetrical distribution of measuring bases, along with symmetrical equations for those bases. It provides an intuitive insight into why the Quantum Strategy works and why it is indeed the most optimal strategy possible.

This approach has helped me understand the CHSH game a lot better. I hope it will be useful to others as well!

24 August 2023

About feelings. And rationality.

It's a common contradiction: feelings vs. rationality. Do we listen to our feelings? Or do we make our decisions using facts, numbers and reasoning? Perhaps we try to balance both? But is the contradiction between the two even real?

Our culture and our language seem to teach us that feelings and rationality are opposites, with phrases like "being a hot-head" vs. "keeping your head cool". I'd like to argue that this is a misconception.

Feelings are important. We can trace them back to biochemical and neurological processes in the brain, each with a distinct evolutionary origin. Fear, for example, evolved to keep us away from danger. Empathy evolved to make us help one another. They are an inherent part of us, like our arms, legs, muscles and bones. Moreover, feelings may be the only reason we do things at all: Why walk? To cross the street. Why cross the street? To get to work. Why work? To make money. Why make money? To provide for my family. Why do that? Because it makes me feel satisfied and secure. Why does it make you feel satisfied and secure? It just does. There's no why anymore. This, of course, is exactly why feelings evolved in the first place: to make us do things that benefit us!

Rational reasoning is a skill that we can use when we make decisions, analyze things, or communicate with someone. And whenever we do, we can include our feelings in that reasoning. Is it irrational to treat ourselves to something unhealthy once in a while? Is that "emotional behaviour"? Not at all, because the mental benefits of that treat may outweigh the effects of the "unhealthy" food. In other cases, rational thinking may tell us to ignore certain feelings, such as unjustified fears. If we add our feelings to our list of considerations when making a decision, then rationality can actually contribute to our mental health.

There is no contradiction between feelings and rationality. In fact, they can't even be compared in the first place! Feelings are a part of who we are and rationality is a skill. It's like comparing "an apple" to "blue". It makes no sense.

So, if feelings are not irrational, then which things are? And how do they relate to our feelings?

Principles, Morals & Ethics

Most people have principles in order to spare them the effort of thinking

- Fliegende Blätter -

Principles, morals & ethics are shortcuts that lead people to make decisions "just because". They don't need a reason, they just do it "out of principle" or because "it's the right thing to do". Principles, morals & ethics assume that different situations can all be treated the same. In reality, they rarely can. It's a better idea to rationally analyze the specifics of each situation individually, especially when we take our feelings, like empathy and sense of justice, into account. Thinking rationally about our the facts, and our feelings, leads to a better outcome than just mindlessly applying a principle or moral code, and probably makes us feel better about it too.

Beliefs
Let's say that we believe that vegetables are healthy. That could be true, or not. But does it depend on what we believe? If eating vegetables is good, then it's good, no matter what we believe. And if it's not good, then it's not good, no matter what we believe.

Whether vegetables are healthy or not, is therefore a thing of fact. It is either true, or not. Of course, it could be somewhere in between, but the truth does not depend on what goes on in our brain. It does not matter what we think. We don't change the health benefits of vegetables by believing things about them.

How about placebos? Some people seem to benefit medically from the belief that they've been given a real medicine. It is, however, not the belief itself that positively affects their body, but rather the mental process that is triggered by that belief. Mental processes can indeed affect how the body works, as Wim Hof famously demonstrated. He also showed that we don't need a false belief to do this. We can simply study the biochemical processes behind this skill and apply that knowledge. Beliefs don't turn placebos into real medicine.

So, do we really believe that vegetables are healthy? Or, do we suspect it? Suspecting is fundamentally different from believing, since suspecting means that we try to find the truth about something. Believing means that we pretend we've already found it.

Believing is admitting that one cannot deal with the uncertainty of suspecting

Now, let's look at what those words do with our feelings. When two people have opposite beliefs, they tend to clash. They tend to become defensive and, if confronted with evidence that goes against their beliefs, instead of changing them, they tend to double down on them. All the while they experience negative feelings, related to feeling attacked and dislike of people with opposite beliefs.

What if we use the word "suspect" instead? If one person suspects that vegetables are healthy and another suspects that they're unhealthy, what do they feel when confronted with one another? Exactly! The urge to find out! This urge is not only very constructive, it's also a very pleasant, motivating feeling. And even when we find out that our suspicion was wrong, it doesn't feel bad. Instead, we feel good about having learned something!

Suspecting automatically leads to understanding, whereas believing makes understanding unnecessary.

I'd rather have a mind opened by wonder than one closed by belief

- Gerry Spence -

Opinions
Strictly speaking, opinions don't exist. Only facts exist. Facts can contain probabilities (eg. "there's a 30% chance of rain") and conditions ("if it rains, then there are clouds", which does not say that it rains, or that there are clouds, yet it is still a fact). We either know a fact, or we don't know a fact. And if it's somewhere in between, we suspect a fact.

But what about things where the truth depends on what we think? For example, I may have the opinion that a certain pizza is nice, and you may disagree. In that case, what is the truth? Is the pizza nice or not? Are there two truths?

Multiple realities and truths are nice for science fiction, but in real life, there is only one reality, one truth and one set of facts. In this case, the pizza is round, the pizza is warm and the pizza is spicy. Those are facts about the pizza.

The pizza however, is not nice. It's also not bad. Instead, I find it nice and you find it bad. Those are not facts about the pizza, they're facts about you and me. It is a fact that I like it and it is a fact that you don't.

If we communicate using the words "opinion", "agree" or "disagree", then we pretend that reality depends on our words. If I say "It's my opinion that my car will pass the inspection" and you say "I disagree", then each of us pretends to be able to shape the future. Whether or not the car will pass, however, is not influenced at all by our opinions. As with beliefs, it's much better to use the word "suspect". The effects on our feelings are very similar. Having an opinion tends to make us feel defensive. Having a suspicion tends to make us feel curious and constructive.

Dogma
Principles, morals, ethics, beliefs and even opinions, are forms of dogma: things that we accept as truth, even if we aren't certain. While there is no contradiction between rationality and feelings, there is a big contradiction between rationality and dogma. If we think rationally, we let go of all dogma. That means that we have to accept uncertainties and things that we simply don't know. This is not a problem. In fact, knowing that we don't know something is useful! It's better to make a decision that takes into account uncertainties, than one that is based on false beliefs or opinions.

Another problem with dogma is that it blocks our mind from learning new things that conflict with what is already there. A rational mind, free from dogma, is therefore the most open-minded one possible.

A Rational Mindset
Imagine yourself at the edge of the jungle. Behind you is society, with its principles, morals, ethics, beliefs and opinions. But as soon as you step into the wilderness, all of those are gone. Only facts and feelings remain. Rational decision making will give you the best chance of surviving. After years, you return to human society, but you keep the jungle mindset and apply it within society. You'll be able to make better decisions, communicate more effectively and feel much better throughout. You've achieved a rational mindset. Congratulations!

Of course, it's possible without the jungle too...

Thanks for reading and if you have any feedback, let me know!

Welcome to the jungle

- Axl Rose -

12 January 2023

Reactor: even more fun in Kotlin!

In the previous article, I gave an introduction into Reactor: a Reactive Programming Java library that makes working with data easier and more fun. In this article, I will explore how Reactor behaves in that other, very popular, JVM language: Kotlin. I will also compare Reactor to Kotlin Flows & Coroutines.

Extension methods
One of the most powerful features of Kotlin are extension methods (also known as lambda-with-receiver): the ability to add methods to external classes in your own code. For example, this is a method that prepends “Hello” to a String:

Reactor uses this to add various extension methods of its own:

There are quite a few more handy extension methods available. For a complete overview, check the API Docs.

Scope functions
Scope functions are extension methods that are defined by Kotlin itself. One example is the let method, that works on any Object. It executes a function block and returns its result. This is particularly useful in Builder style patterns, where you invoke a chain of methods that all return an Object of the same type. Of course a Flux isn’t technically a Builder, because the chain of methods creates a chain of fluxes that subscribe to one another, rather than operating on a single Flux, but the programming style is very similar.

Let’s have a look at the hotel example from the previous article. There, we have a hotelService and a reservationService that return a Reactor Flux of resp. HotelRooms and Reservations. A Flux is an Object that can stream data asynchronously and exists even when the data itself isn’t there (yet). In addition, a Flux has many, many methods to manipulate the stream.

Now, let’s say that we only want to call the switchIfEmpty method if the Marriot hotels are enabled. In Java, you would have to do this:

Using the Kotlin let scope function, we can simply do:

Competition: Reactor vs Flows & Coroutines!
In addition to providing several improvements to the Reactor experience, Kotlin also comes with its own solution for Reactive Programming: Kotlin Flows & Coroutines. By adding the suspend keyword to a method, you can turn that method into an async method, that will execute in a non-blocking, async fashion when data is actually available. Here is an example, using the Spring Framework, which offers support for both Reactor as well as Kotlin Flows & Coroutines.

In Kotlin Flows & Coroutines, you would write:

This is similar to the following in Reactor:

A much more comprehensive comparison between the two can be found in this Medium article.

Which is better
As always, this depends largely on your specific needs and preferences. Speaking for myself, I prefer Reactor for the following reasons:

  • In Kotlin Flows & Coroutines, the code requires a mix between language keywords (eg. suspend) and API classes and methods (eg. Flow). This is not very elegant and slightly confusing. In Reactor, the use of the language itself (Java, Kotlin or any other JVM language) doesn’t change. Instead, the reactive patterns are fully contained in the Reactor API (eg. Flux).

  • Related to this, Reactor makes reactive programming more explicit. It’s obvious from the code that you’re working with a reactive API. Code written with Kotlin Flows & Coroutines looks very similar to blocking code. This may seem nice, but making explicit what is actually happening is very important for readability and maintenance. If programmers see code that differs from traditional, blocking code only because of the suspend keywords, they may not be aware that they are dealing with a reactive system and may make mistakes because of that. Reactor makes it obvious that you’re working with an async, non blocking API, without having to deal with callbacks.

  • Functions with the suspend keyword are only callable from other functions with the suspend keyword, or from a coroutine. This makes it more difficult to share logic with blocking code. The various methods of Flux simply take ordinary lambda’s, that can contain any logic.

  • Kotlin Flows & Coroutines is purely push-based: the async code executes when data becomes available from the source. Reactor, on the other hand, offers a push-pull hybrid: data gets pushed downstream, but subscribers can also request data from upstream and propagate backpressure signals upstream.

  • A quick comparison between the Flow API from Kotlin Flows & Coroutines and the Flux API from Reactor shows that the amount of operations that Reactor offers is many, many times larger. It doesn’t even come close. Whatever use case you have, whatever operation you need, Reactor is likely to offer it. And in the rare cases where it doesn’t, it offers plenty of hook methods to implement your own.
Conclusion
Using Reactor as a Reactive Programming platform enables you to write async, non blocking code with any JVM language. However, by using some of Kotlin’s unique and powerful language constructs, you can make the experience even better!

Thank you for reading!

26 October 2022

Reactor: making data more fun in Java!

In this article I’d like to give a short introduction into Reactor: a Java library that enables Reactive Programming techniques that make working with data easier and more fun!

What is reactive programming?
With Big Data platforms producing more and more data and AI/ML systems needing more and more input, applications increasingly have to deal with very large data streams. Processing these with traditional programming paradigms is possible, but rarely ideal.

Reactive programming is a programming style that allows you to specify what should happen with data, without specifying how it should be achieved. It also doesn’t require the actual data to be present (yet).

Most Java programs use an imperative programming style with blocking code to execute business logic. This works well when the data is readily present and the amount of data is not too large, but when the number of data increases or data might arrive in the future, this approach has severe limitations, because it blocks the executing thread until all data has arrived and has been processed.

One way to approach this problem is to make the program run asynchronously, with callbacks that respond to the arrival of data. Consider this example:

This code gets HotelRooms, trying one hotel first, then another. It takes a maximum of 50 rooms and reserves them. If anything goes wrong, the customer service is notified.

The first problem with this code is that it’s complex. Nothing special is happening here, but it’s already difficult to understand. We could put the reservation logic in a private method, to avoid duplication, but it would not avoid the complexity.

The second problem is that it doesn’t solve the problem of very large amounts of data. We only take 50 elements from the List of HotelRooms, but the whole List still has to be loaded in memory first, because it is passed through the callback parameter. What if it, hypothetically, contains a million elements?

Instead of List, Reactor uses Flux to manage an ordered collection of elements. A Flux is an Object that can stream data asynchronously and exists even when the data itself isn’t there (yet). In addition, a Flux has many, many methods to manipulate the stream.

Now, let’s imagine that the hotelService and reservationService methods don’t accept Callbacks, but instead return a Reactor Flux of resp. HotelRooms and Reservations:

That’s all it takes!

The amazing thing about Reactor is that nothing happens until you subscribe! This means that the fluxes that are returned from the hotelService don’t actually start pumping data until that data is requested. The downstream flow of data is started and can be tuned by an upstream flow of signals.

Each method in the chain actually creates a new Flux that subscribes to the previous Flux.

Threading
The entire chain executes asynchronously, only processing data when it arrives. You can fully control the threads on which the different parts of the chain run. For example, if you want to run the hotelService and reservationService operations on the same thread that you subscribed from, but the notificationService and the customerService on parallel threads:

The publishOn method affects everything that happens below it in the chain, in this case the handler methods that are specified in the subscribe method.

Perhaps you want to start the entire subscription on a bounded elastic thread pool:

The subscribeOn method affects everything that happens from the top of the chain, where the data flow will start upon subscription.

Backpressure
Reactor is created with large flows of data in mind. If a Flux at the top produces more data than the services below it can handle, there are various mechanisms available to deal with that.

The take(50) method, for example, takes 50 items from upstream and then cancels the subscription. However, it does not tell upstream that it is only going to take 50. The Flux upstream could still produce a lot of data.

To propagate this signal upstream, we could set the optional limitRequest boolean to true:

Now only 50 items are requested from the Flux instances upstream, preventing the production of superfluous data. There are a lot of methods available to tune the rate at which data will be processed: limitRate, takeWhile, takeUntil and many more. You can use them anywhere in the chain and they will signal the corresponding demand upstream.

Testing
Reactor comes with useful tools for testing instances of Flux. Suppose we have the following Flux:

It can be unit tested like this:

StepVerifiers support many, many methods for verification, including functionality for using virtual time, if you want to test Flux instances that perform certain actions over a long period of time, like processing a continuous live stream of data.

Logging
Because a lot of logic takes place inside the methods of a Flux, stacktraces can be hard to read when something goes wrong. For that purpose, Reactor has sophisticated tooling to make sense of error messages.

When debugging, you can activate Hooks.onOperatorDebug(); which will instrument the calls to the Reactor methods and use them to create stacktraces with very useful meta information.

For production, Reactor comes with a Java Agent that instruments your code without paying the performance penalty associated with the debugging alternative. To use it, simply call ReactorDebugAgent.init();

And, since not all logging is about errors, you can simply call one of the many overloaded log() methods anywhere in the call chain of a Flux and Reactor will log a useful message whenever an element passes through that link of the chain:

Reactor and Spring
Spring offers extensive support for Reactive Programming and it chose Reactor as the library to implement it. Not only is this a confirmation of the fact that Reactor is the go-to standard of Reactive Programming in Java, it is also very convenient!

When connecting to backend systems, like Cassandra or Kafka, Spring provides several integrations that generally follow the same pattern:

Operations, like CassandraOperations or KafkaOperations

Templates, like CassandraTemplate or KafkaTemplate

Repositories, like CassandraRepository or KafkaRepository

These classes provide several methods that return data from the underlying system, like CassandraTemplate.select(query), which returns a List of objects of the appropriate type.

Spring also provides Reactive versions of each of these! So, for example, for Cassandra, Spring provides a ReactiveCassandraOperations, ReactiveCassandraTemplate and ReactiveCassandraRepository. Instead of a List<T>, they return a Flux<T>!

On the frontend, Spring Webflux uses Reactor to implement Reactive endpoints. This makes it easy to, for example, process a multipart request reactively:

The output itself can also be reactive, creating a continuous data stream over HTTP:

Comparison with java.util.Stream
You may wonder: doesn’t java.util.Stream already have this declarative, method chaining style of programming that can process data in parallel?

It does. However, there are several reasons why using Reactor is superior when dealing with data flows:

  • Reactor has a subscriber mechanism. Data will only start to flow once you subscribe.
  • Reactor is asynchronous by default.
  • Stream does not handle backpressure, you have to be ready to receive the entire stream of data, even if you only process a part of it.
Also, Stream has a rather basic API. In addition to the things that we’ve already seen, Reactor has a lot more to offer:

  • Do you need metrics on the amount of data that goes through a Flux? Reactor integrates with Micrometer.
  • Do you want to only start the flow when a Flux has a certain number of subscribers? Reactor offers ConnectableFlux.
  • Do you need grouping of a Flux’s values, for example, grouping a Flux of numbers into a Flux of odd and a Flux of even numbers? Reactor offers Flux.groupBy.
  • Do you need windowing of a Flux’s values, for example, windowing a Flux of numbers into windows of 1 hour each? Reactor offers many Flux.window methods.
  • Do you need buffering of a Flux’s values, for example, processing a Flux of numbers in buffers of 1000? Reactor offers many Flux.buffer methods.
And the list goes on. There’s too much to discuss in one article, as Reactor has a method for every conceivable use case and if not, it provides plenty of hooks to implement your own.

Conclusion
I hope I’ve been able to give you an idea about what Reactor is and what it can do for you.

If you have an application landscape that includes Big Data systems like NoSQL databases or Streaming platforms and you need to process that data, for example to create an AI/ML model, Reactor can be the spider in the web that connects all these components together in a scalable, asynchronous, parallel and flexible manner.

At the same time, Reactor makes the work more fun for developers by offering a Reactive programming model and taking away the boilerplate code that usually comes with these use cases.

If you want to learn more about Reactor, I recommend the Reference Manual, in particular the section that lists which method to use for which use case.

The main website offers plenty of learning material and this interactive web based tutorial is an excellent way to get started.

Next time…
In the next article, I will explain how Reactor integrates with Kotlin and takes advantage of a few unique language constructs that Kotlin offers.

Thanks a lot for reading and stay tuned!

21 January 2021

Big Tech should have the power

Should social media companies have the power to determine who can speak and what can be said? Most people argue that they probably shouldn't. In this article, I'd like to give three reasons why they probably should.

  1. While most of the debate centers around whether they should have the power, let's for a moment have a look at how they use that power right now, while they have it. Currently, social media companies are very reluctant to ban or censor any opinion, unless it actually becomes violent or dangerous. For the most part, people are allowed to spread all the falsehoods they desire. Any accusation of "abuse of power" therefore seems unwarranted. If anything, society might be better off if social media companies would use their moderation powers more, rather than less.

  2. The debate also rarely answers the question of what should happen if social media companies don't have the power anymore. There are two alternatives:

    • Firstly, no moderation at all, not even the modest moderation that is currently practised. Anyone can say anything, long live our freedom. This is a bad idea. Freedom is nice, but we still have a speed limit on public roads, because people are not responsible enough to deal with too much freedom there. The same goes for drugs: alcohol is allowed, but hard drugs is forbidden.

    • The other alternative is that there are independent rules for social media. This leads to the inevitable question: who sets the rules? And the answer would be: the authorities. In most democratic countries, the "authorities" are split up in three independent entities:

      • The executive branch (the government)
      • The legislative branch (parliament or congress)
      • The judicial branch (the courts)
      In reality though, two of these aren't independent at all, since the leader of a country (the president or prime minister), usually controls both the executive as well as the legislative branch. Letting the government set the rules for social media would give that leader even more power.

      Separation of power into different branches is what prevents a dictatorship. Imagine a situation where a president or prime minister would control not just the government and the parliament / congress, but set the rules for all social media platforms as well...
  3. When talking about social media companies, we usually use words like "they", or "Big Tech", as if they are a single entity. In reality though, they are completely independent. If Twitter bans a certain user, Facebook doesn't have to follow suit. The same goes for all the other ones. This means that power is separated even more, which, as explained above, is a good thing.

    What this also does, is bring part of the power back to the people! Why? Because they can leave! When WhatsApp changed their Terms and Conditions, lots of users switched to Signal or Telegram. This way, people directly influence their power over the companies that are in control of social media moderation. Voting with your feet can be a lot more powerful than voting at the ballot box.
All in all, I think that the current situation is perfectly fine and doesn't require fundamental change. Thanks for reading and if you have a comment, feel free to leave it below!

18 August 2020

The Lukashian Calendar

After almost two years of development, the first version of The Lukashian Calendar website is finally live!

The Lukashian Calendar is a radically fresh approach to a calendar that is easier, simpler and more accurate. It gets rid of all the legacy elements of existing calendars and sees a calendar for what it really is: not a way to measure a duration of time (that's what we have seconds for), but a representation of the movements of the Earth in the Solar System.

Curious? (and you should be!) Visit the website here!

31 March 2016

What is scientific thinking?

The question "What is scientific thinking?" often leads to answers about the scientific method or Karl Popper's falsifiability criterion. While both very valid, I would like to propose a new, simpler and more intuitive answer.

Let's imagine two columns. Each column represents a certain way of thinking:


In Column A, the thinking starts with an observation. You see something, experience something or read about an observation that someone else has made. Then, after the observation, you start reasoning about it, using the laws of logic. After a lot of reasoning, you arrive at a conclusion.

Then, another observation could be made, that is related to the first one. In that case, the reasoning could change, and therefore the conclusion could change too. Or, a flaw could be found in the reasoning. Then also, the conclusion will change. People who use Column A thinking are therefore always open to new ideas. Their conclusions are never fixed and can always change. Let's look at an example of Column A thinking:

Observation: As we expel more carbon dioxide into the atmosphere, the average global temperature rises.
Reasoning: It could be explained by the fact that carbon dioxide makes the atmosphere absorb more heat from the sun.
Conclusion: When carbon dioxide levels rise, the atmosphere will absorb more heat and temperatures rise.

Then, another observation is made:

Observation: The increase in temperature is higher than can be explained by the increase in carbon dioxide.
Reasoning: As the ice caps melt, less sunlight is reflected back into space, so more sunlight is absorbed by the earth.
Conclusion: When temperatures rise as a result of more carbon dioxide, it will lead to side effects that make the temperature rise even faster.

What do we see here? As more and more observations are done, existing conclusions are challenged, new reasonings are being performed and new, more detailed and correct conclusions are created. We're on our way to wisdom.

Now, let's compare this with Column B. In Column B, the conclusion comes first! After the conclusion has been set, observations can be made. After the observations are made, it's up to the reasoning to connect the observations to the predetermined conclusion. So, what does this approach mean for the conclusion? Can a new observation change an existing conclusion? No, it cannot, the conclusion can never change. What if a flaw is found in the reasoning? Then the reasoning must be replaced by another reasoning, without changing the conclusion. An example:

Conclusion: Climate change does not exist.
Observation: Average global temperatures have been increasing steadily over the last few decades.
Reasoning: It is a coincidence. Changes in temperature have happened throughout history.

Then, a flaw in the reasoning is found:

Conclusion: Climate change does not exist.
Observation: Average global temperatures have been increasing steadily over the last few decades in a way that is not consistent with random temperature changes throughout history (in other words, the previous reasoning was wrong).
Reasoning: The evidence has been forged. It's all a hoax, created by the Chinese to hamper our economy.

What happens here? No matter what the observations are, no matter how many flaws are found in the reasoning, the conclusion will never change. Such an unchangeable conclusion is also called a dogma.

Different mindset
Of course, Column A is the correct, scientific way to think. But why are there so many people who think according to Column B? To Column A thinkers, the reasonings that the Column B thinkers come up with, often seem very irrational, even absurd. But why can't they see that? The reason is: for them, reasoning has a different purpose! For scientific thinkers, reasoning has the purpose of creating conclusions out of observations. Reasoning, therefore, is very important, since the conclusions are based on it! For Column B thinkers on the other hand, reasoning is not important at all, since nothing follows from it. If the reasonings are absurd or irrational, it does not matter, since nothing depends on the reasonings.

This is also why discussions between the two groups are often fruitless. It is as if the groups speak a different language. A Column A person gives a flawless reasoning, proving his or her point, but that reasoning is simply shoved aside by a Column B thinker, because for the Column B thinker, the reasoning is irrelevant if it does not support their predetermined conclusion. For the Column A person, this can be difficult to understand, after all, the Column A person uses reasoning to arrive at conclusions, so if a reasoning leads to a certain conclusion, then the conclusion should not just be dismissed. But from the point of view of the Column B person, reasoning has the sole purpose of connecting observations to unchangeable conclusions, so from their point of view, dismissing the reasoning and the conclusion of the Column A person makes sense.

Causes
So, what drives people to Column B? How do people end up with a brain that works in such a way? There are multiple reasons:

  • Lack of understanding of logic: Since Column A thinkers use reasoning to arrive at a conclusion, they need to be well versed in logical thinking. If you do not understand the laws of logic, then it can be difficult to use the Column A approach. Also, a misunderstanding of logic gives Column B thinkers extra "ammunition" for their reasonings. For example, they could argue: "If climate change cannot be proven, then it must be false". Someone who knows logic, knows that it does not really matter whether something can be (dis-)proven or not. It is very easy to come up with nonsense that cannot be disproven and, similarly, to come up with excellent scientific theories that cannot be proven. If you don't know that though, then you can use false logic to reinforce your Column B reasonings.

    This reason is, for a large part, due to the fact that logic isn't taught in schools anywhere! Not in primary school and not in secondary school. In most countries, you need to go to university and study something like Computer Science before you're ever exposed to logic. When schools teach "science", they teach scientific facts, for example physics or chemistry. What they don't teach, is a logical, scientific way of thinking. This is a shame, because basic logic is no more difficult than basic math and would greatly increase the reasoning skills of many people.

  • Echo chambers: These are environments (online, or in the real world) where people are surrounded by other people who share the exact same opinions. No opinion is ever challenged and the people continuously reaffirm the opinions of one another. Echo chambers are often rife with Column B type thinking, but the problem is: even when a Column B reasoning is wrong, how would you know if everyone around you agrees with it? The Internet does make it easier for people to meet other people with different opinions, but at the same time, the Internet also creates a lot of echo chambers of its own.

  • Conservatism: A lot of people like the idea that things are the way they are, do not change and will always be the same. This is especially true when it comes to changes that are too slow to notice in a lifetime, such as evolution, plate tectonics, astronomical changes and, to a lesser degree, climate change.

  • Confirmation bias: Column B type people tend to only register observations that confirm their conclusions, while discarding or ignoring observations that do not confirm their conclusions. By doing that, they constantly reinforce their feeling that their conclusions are correct.

  • Sensationalist, click-bait media: This is something that has surfaced very recently: websites on the Internet that are exploiting the weaknesses of the human psychology. They create articles with headlines that trigger curiosity and the desire to click on it, only to then lead the reader to articles full of sensationalist content, triggering even stronger reactions, such as anger and hatred. Eventually, readers end up addicted to content that keeps triggering these reactions in the brain, reaffirming the content that has been presented earlier. Once hooked, readers will move to a Column B type of thinking, rejecting any views that contradict the content which keeps their brains happy with a daily dose of anger and sensation. Take a look at this excellent video to find out more about this.
Apart from these, there are quite a few more human psychological traits that affect rational thinking.

Religion
So far, I have been using climate change deniers as an example of Column B type thinkers, but there are many more:

  • Young earth creationists, who believe that the earth is only a few thousand years old and was created exactly like it is today.

  • Anti vaxxers, who believe that vaccines cause autism and refuse to vaccinate their children. Created by the aforementioned click-bait media and grown strong through Internet echo chambers, this is a particularly dangerous group of people, since they're actively bringing back diseases that were almost eradicated.

  • Geocentrists / Flat earth truthers, who believe that the earth is flat and at the center of the universe. Yes, they really do exist.
An interesting question is: does religion belong in this list too? My answer would be: not necessarily. While it is true that a lot of religious people practice Column B type thinking, it is also possible to be religious, while still maintaining a scientific, Column A mindset. So, what must a religious person do in order to be safe and sound in Column A?

  • First of all, realize that you cannot be certain. The whole idea behind Column A is that conclusions can change. One of the oldest philosophers of the human race said it before:

    The only true wisdom is in knowing that you know nothing

    - Socrates -

    But what if you are certain? What if you can't help yourself? What if you have this realization, deep down, that you're certain that your god exists? Well, let's assume for a moment that you're a christian and you are certain that the christian god exists. In that case, you will also deny the existence of other gods, for example the hindu gods. Your christian god exists and the hindu gods do not and you are certain of it, for whatever reason.

    Now, imagine a hindu, and realize that he has the exact same certainty that you have! To him, the christian god is false, the hindu gods are real, he is just as convinced and certain as you are and... he's wrong. His gods don't exist, right? So what does that prove? It proves that being certain is not enough to be certain. After all, he is as certain as you, and he's wrong. And if you say: "well, that means that he cannot be as certain as me", then you've just created a reasoning that ties an observation to an unchangeable conclusion. Welcome to Column B!

    It does take great maturity to understand that the opinion we are arguing for is merely the hypothesis we favor, necessarily imperfect, probably transitory, which only very limited minds can declare to be a certainty or a truth.

    - Milan Kundera -

  • Always make sure that you let your observations and subsequent reasonings determine your conclusions. This also means that you cannot deny certain scientific certainties, such as evolution and the history of the universe. Those theories have been formed through sound observation and reasoning, so denying them automatically leads to Column B. Of course, from a theoretical point of view, those scientific theories cannot be proven beyond any theoretical doubt, but if every single observation confirms a theory, then for all intents and purposes it should be regarded as a correct theory.

  • Realize that there is no "proof" that proves your religion correct. Sure, there are plenty of such "proofs" available online, but once you develop an understanding of logic and science, you will quickly discover that all of them are false. Instead of believing in your religion because of some "proof", realize that there is no proof, you cannot be certain, but you can still believe, simply because you want to and it makes your life better. This could potentially make your belief stronger as well, because if you believe for the wrong reasons (for example, "god cannot be disproven, therefore he must exist", which is logically incorrect, because seven little midgets on the far side of Jupiter can not be disproven, either), and at some point you realize that your reasons are false, the basis for your religion could disappear. If instead you believe because you want to and it makes your life better, while at the same time acknowledging science and realizing that there's no such thing as certainty, then there is no basis that could disappear.

    I don't believe in any god myself, however, there are things that I do believe in, despite the fact that I can never be 100% certain. I believe, for example, that my family is real, even though in theory, everything around me could be a simulation and I could be a test subject in some experiment. This does seem far fetched, but from a theoretical point of view, it is a possibility. The important thing is that, even though I believe something that I cannot prove, I am well aware of the fact that I might be wrong and I do not believe anything that contradicts science.
Popper
I think that the Column A / Column B method for distinguishing scientific / rational thinking from unscientific / irrational thinking is better than the good old falsifiability criterion of Karl Popper, for the following reasons:

  • Popper's criterion is not easy to understand. In fact, to people who aren't skilled in logic, a theory that is not falsifiable might actually be interpreted as a very strong theory. After all, if it cannot be falsified, then it must be true, right? The Column method on the other hand, is simple and intuitive, even for people without training in logic.

  • Popper's criterion automatically follows from the Column method! After all, a theory that was constructed using Column A (and therefore scientific), is automatically falsifiable, because a change in observation or reasoning can change the conclusion. Conversely, a theory that was constructed using Column B (and therefore unscientific), is automatically unfalsifiable, since the conclusion is fixed. So, when you use the Column method, you get Popper's criterion for free!
So to conclude, I would like to ask everyone to promote this method of distinguishing science from anti-science. It's easier to understand and more likely to make people think about how their minds work. If you have any additions or comments, please don't hesitate to post them below!