An extension of error theory with application to spherical harmonics