# Legendre Polynomial equation in Spherical Harmonics

The notation Re() and Im() refer to the real and imaginary parts of a complex number. Mathematicians and physicists are accustomed to using spherical harmonics (and Fourier transforms too) that are complex-valued, due to the factor $e^{im\phi}$. You would then also have complex coefficients, in general, in the spherical harmonic expansion of a (real or complex) function.
Using Euler's formula, $e^{im\phi} = \cos(m\phi) + i\sin(m\phi)$. So that factor encodes cosine and sine waves (that oscillate $m$ times as you move around the equator of the sphere) in its real and imaginary parts, respectively.
When we know we're going to be working strictly with real-valued functions, it may be more convenient to use real-valued variants of the spherical harmonics, where $e^{im\phi}$ is replaced by either $\cos(m\phi)$ or $\sin(m\phi)$, and using real coefficients instead of complex ones. We trade a single complex coefficient for two real coefficients, so we haven't lost any information or flexibility; it's essentially a change of basis. This formulation just explicitly ensures that everything always comes out real.