Solution (source code)

= Solution

Set $G=\sqrt{g^2+g'^2}$ and $s_W=\sin\theta_W$. First expand the charged term using the <ladder operators>:
$$
\tau^+W^++\tau^-W^-=
\frac{(\tau_1+i\tau_2)(W^1-iW^2)+(\tau_1-i\tau_2)(W^1+iW^2)}{\sqrt2}
=\sqrt2(\tau_1W^1+\tau_2W^2).
$$
Substituting the neutral <gauge fields> as well, the <covariant derivative> becomes
$$
\begin{aligned}
D_\mu={}&\partial_\mu-ig(\tau_1W^1_\mu+\tau_2W^2_\mu)\\
&-i\left[g(\tau_3-Qs_W^2)+\frac{eg'}GQ\right]W^3_\mu\\
&-i\left[-g'(\tau_3-Qs_W^2)+\frac{eg}{G}Q\right]B_\mu.
\end{aligned}
$$
Matching $W^3$ to $g\tau_3$ requires
$$
gs_W^2=\frac{eg'}G.
$$
Matching $B$ to $g'(Q-\tau_3)=g'Y/2$ requires
$$
g's_W^2+\frac{eg}G=g'.
$$
For $g,g'>0$, elimination yields
$$
\boxed{\sin^2\theta_W=\frac{g'^2}{g^2+g'^2},\quad
\tan\theta_W=\frac{g'}g,\quad
\theta_W=\arctan\frac{g'}g,\quad
e=\frac{gg'}{\sqrt{g^2+g'^2}}.}
$$
Equivalently, $e=g\sin\theta_W=g'\cos\theta_W$ and $1/e^2=1/g^2+1/g'^2$. The conventional <Weinberg angle> lies in the first quadrant.