Orthogonal polynomial solutions to ordinary and partial differential equations