How are the "real" spherical harmonics derived?

The page actually suggests the answer when it says "The harmonics with $m > 0$ are said to be of cosine type, and those with $m < 0$ of sine type." Recall how one switches between the complex exponential functions $\{e^{imx}\colon m\in \mathbb Z\}$ and the trigonometric functions: it's done with the formulas $$\cos mx=\frac{e^{imx}+e^{-imx}}{2}$$ and $$\sin mx=\frac{e^{imx}-e^{-imx}}{2i}$$ Taking only real parts would not give you the sines.

Since $\cos (-mx)=\cos mx$ and $\sin(-mx)=-\sin mx$, we don't need all values of $m$ in both families. We can remove the redundant functions and enumerate the entire trigonometric basis by $m\in\mathbb Z$ as follows: $\{\cos mx\colon m\ge 0\}\cup \{\sin mx\colon m<0\}$. This is essentially what the wiki page does.


Laplace equation in spherical coordinates

First we need to understand where spherical harmonics come from. The spherical harmonics come from the solutions of the Laplace equation in the spherical coordinates by the separation of variables.

The solution has the general form: $$ V(r, \theta, \varphi) = R(r)\Theta(\theta)\Phi(\varphi) $$

For each of the components $R(r)$, $\Theta(\theta)$, $\Phi(\varphi)$ we have separate ordinary differential equation with the following solutions $$ R(r) \rightarrow A_{lm} r^l + \frac{B_{lm}}{r^{l+1}} $$ $$ \Theta(\theta) \rightarrow P_l^m(\cos\theta) $$ $$ \Phi(\varphi) \rightarrow e^{im\varphi} $$

Combining all together we get $$ V(r, \theta, \varphi) = \sum_{l=0}^{\infty} \sum_{m=-l}^{l} \left( A_{lm}r^l + \frac{B_{lm}}{r^{l+1}} \right) P_l^m(\cos \theta) e^{im\varphi} = \sum_{l=0}^{\infty} \sum_{m=-l}^{l} \left( A_{lm}r^l + \frac{B_{lm}}{r^{l+1}} \right) Y_l^m(\theta, \varphi) $$ where $Y_l^m(\theta, \varphi)$ is the complex spherical harmonics

Ordinary differential equation for the $\Phi(\varphi)$

Now let us look at the details for the ordinary differential equation for the component $\Phi(\varphi)$. This is the simplest form of the wave equation: $$ \frac{1}{\Phi}\frac{d^2 \Phi}{d\varphi^2} = -m^2 $$

The solution is well known and may be defined either as a complex function $$ \Phi(\varphi) = A_me^{im\varphi} $$ or as a combination of real sinus and cosines functions $$ \Phi(\varphi) = C \sin m \varphi + D \cos m \varphi $$

If we use the complex solution we get the complex spherical harmonics. If we use the real sin/cos solutions we get the real spherical harmonics.

How to convert complex spherical harmonics to real harmonics

To convert complex spherical harmonics to the real one we need to convert $$ A_m e^{im\varphi} \rightarrow C \sin m \varphi + D \cos m \varphi $$

By the Euler formula: $$ Z = A e^{im\varphi} = A (\cos\varphi + i \sin \varphi) $$ $$ Z^* = A e^{-im\varphi} = A (\cos\varphi - i \sin \varphi) $$

It means $$ A \cos \varphi = \frac{Z + Z^*}{2} $$ $$ A \sin \varphi = \frac{Z - Z^*}{2 i} $$

This definition is near the same as you write for real harmonics in the initial question. But we need to scale it by the some normalization coefficient to keep orthogonality properties.


Why are the real spherical harmonics defined this way and not simply as $\Re{(Y_l^m)}$?

Well yes it is! The real spherical harmonics can be rewritten as followed: $$Y_{lm} = \begin{cases} \sqrt{2}\Re{(Y_l^m)}=\sqrt{2}N_l^m\cos{(m\phi)}P_l^m(\cos \theta) & \text{if } m > 0 \\ Y_l^0=N_l^0P_l^0(\cos \theta) & \text{if } m = 0 \\ \sqrt{2}\Im{(Y_l^m)}=\sqrt{2}N_l^{|m|}\sin{(|m|\phi)}P_l^{|m|}(\cos \theta) & \text{if } m < 0 \end{cases} $$

(Some texts denote lowercase $y$ for real harmonics). If you look at the table, the negative $m$ is the imaginary part of the positive $m$ (but not vice versa).