Where does the negative cosine relation for quantum mechanical CHSH correlations come from? I have been lately looking into Bell's inequality. I have noticed a recurring graph that depicts the correlation of two spins when measured at different angles, for the quantum and the classical case:
From my understanding, the linear relation is shown just to prove how the classical case differs from the quantum case. Although I do not see where does the negative cosine relation (blue line) arises from.
Could anyone help?
 A: Experimental Setup
The quantum correlation in the graph (following a cosine) is the one appearing in the CHSH-experiment. To understand how it is derived, it is good to start with the setup:

In this setup, the source $S$ creates two photons which are either both vertically ($|\uparrow\rangle = \begin{pmatrix} 1 \\ 0 \end{pmatrix}$) or horizontally ($|\downarrow\rangle = \begin{pmatrix} 0 \\ 1 \end{pmatrix}$) aligned. I.e., it creates the Bell-state $|\psi\rangle = \frac{1}{\sqrt{2}} (|\uparrow\rangle \otimes |\uparrow\rangle + |\downarrow\rangle \otimes |\downarrow\rangle)$.
The polarizers $A$ ($B$) is aligned at an angle $a$ ($b$) w.r.t. the vertical axis. They let the photon pass when it is aligned with the polarizer (this is the $D+$ in the diagram) or reflect them when they are aligned perpendicular to the polarizer ($D-$ in the diagram).
In the end, we observe whether each of the photons passes its polarizer or is reflected. We say that $A=+1$ if the first photon passed and $A=-1$ if it was reflected (the same for $B$ and the second photon). So we have four possible outcomes: $\begin{pmatrix} A=+1 \\ B=+1 \end{pmatrix}, \begin{pmatrix} A=-1 \\ B=+1 \end{pmatrix}, \begin{pmatrix} A=+1 \\ B=-1 \end{pmatrix}, \begin{pmatrix} A=-1 \\ B=-1 \end{pmatrix}$
The Math
We want to compute the correlation of $A\cdot B$ (meaning, their product) under the state $|\psi\rangle$, given by the sum
$$ \langle AB \rangle_{\psi} = \sum_{A=\pm1} \sum_{B=\pm1} A\cdot B \cdot P_{a,b}(A,B). $$
Here, $P_{a,b}(A,B)$ is the probability that $A$ and $B$ have a certain outcome given the angles $a$ and $b$.
The polarizers $A$ is described mathematically by the linear combination of pauli matrices (for $B$, use $b$)
$$ \sigma_a = \cos(2a) \sigma_z + \sin(2a) \sigma_x = \begin{pmatrix} \cos(2a) & \sin(2a) \\ \sin(2a) & -\cos(2a) \end{pmatrix} $$
which has the eigenvectors $|p_a\rangle = \begin{pmatrix} \cos(a) \\ \sin(a) \end{pmatrix}$ (the state of the photon if it passed) and $|r_a\rangle = \begin{pmatrix} -\sin(a) \\ \cos(a) \end{pmatrix}$ (the state of the photon if it was reflected).
The probability, that a vertically polarized photon is passing $A$ is given by the state times the eigenvector squared $|\langle p | \uparrow \rangle|^2$.
We are interested in the probability that the state $|\psi\rangle$ gives us one of the four possible outcomes, so we have to square the scalar product of the state with tensor products of the eigenstates. The probability for each of these cases is computed as follows:
\begin{align*} 
    &P_{a,b}(+1,+1) = |(\langle p_a| \otimes \langle p_b|) |\psi\rangle|^2 = \frac{1}{2} \Big| \langle p_a|\uparrow\rangle \langle p_b|\uparrow\rangle + \langle p_a|\downarrow\rangle \langle p_b|\downarrow\rangle \Big|^2 \\ 
    &P_{a,b}(+1,-1) = |(\langle p_a| \otimes \langle r_b|) |\psi\rangle|^2 = \frac{1}{2} \Big| \langle p_a|\uparrow\rangle \langle r_b|\uparrow\rangle + \langle p_a|\downarrow\rangle \langle r_b|\downarrow\rangle \Big|^2 \\
    &P_{a,b}(-1,+1) = |(\langle r_a| \otimes \langle p_b|) |\psi\rangle|^2 = \frac{1}{2} \Big| \langle r_a|\uparrow\rangle \langle p_b|\uparrow\rangle + \langle r_a|\downarrow\rangle \langle p_b|\downarrow\rangle \Big|^2 \\
    &P_{a,b}(-1,-1) = |(\langle r_a| \otimes \langle r_b|) |\psi\rangle|^2 = \frac{1}{2} \Big| \langle r_a|\uparrow\rangle \langle r_b|\uparrow\rangle + \langle r_a|\downarrow\rangle \langle r_b|\downarrow\rangle \Big|^2 
\end{align*}
If you work these out carefully (in principle, its just vector multiplication), you'll find that generally:
$$ P_{a,b}(A,B) = \frac{1}{4} \Big( 1 + AB \cos[2(a-b)] \Big) $$
Now, we only have to plug this into the equation for the correlation and use that $A^2 = B^2 = 1$ to find that
$$ \langle AB \rangle_{\psi} = \cos[2(a-b)]. $$
This is how you compute the correlation in the quantum mechanical framework.
The Result
The cosine here is slightly different from the graph you got (where instead is plotted $\cos(a-b - 180^\circ$), but it explains the setup I introduced.
At $a-b=0^\circ$, $A$ and $B$ should be perfectly correlated, i.e., $\langle AB \rangle_{\psi}=1$.
For $a-b=90^\circ$, they should indeed be anti-correlated ($\langle AB \rangle_{\psi}=-1$), because one polarizer is vertically aligned while the other is horizontal.
At $a-b=180^\circ$, we should be back at the beginning because rotating a polarizer by $180^\circ$ brings it back to being horizontally aligned.
I assume the difference comes from a different Bell state and maybe the fact that spin-$1/2$ is considered after all. But this is the standard CHSH experiment.
