Associated Legendre functions and differential equations