Gauss-Legendre quadrature nodes and weights, exact for integrating any polynomial of degree using only points -- the natural quadrature for spherical harmonic transforms, since is a polynomial in times , and the transform integral separates exactly into this -quadrature times a uniform sum over (itself exact for finite Fourier content). Nodes are the zeros of , found by Newton iteration (converges to machine precision in under 10 steps); weights are .
ascending from -1 to +1.
\sum_i w_i f(x_i) ), size LMAX+1.
uses LMAX+1 quadrature points.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(out) | :: | ZERO(LMAX+1) | |||
| real(kind=dp), | intent(out) | :: | W(LMAX+1) | |||
| integer(kind=i4), | intent(in) | :: | LMAX |
Requested exactness is degree ; |
SUBROUTINE SHGLQ_DP(ZERO, W, LMAX) IMPLICIT NONE INTEGER(KIND=i4), INTENT(IN) :: LMAX REAL(KIND=dp), INTENT(OUT) :: ZERO(LMAX+1) REAL(KIND=dp), INTENT(OUT) :: W(LMAX+1) INTEGER(KIND=i4) :: N, I, J, K, NHALF REAL(KIND=dp) :: X, P0, P1, P2, DPN, DX, TOL TOL = 1.0e-15_dp N = LMAX + 1 NHALF = (N + 1) / 2 DO I = 1, NHALF X = DCOS(pi * (I - 0.25_dp) / (N + 0.5_dp)) DO J = 1, 100 P0 = 1.0_dp P1 = X DO K = 2, N P2 = ((2*K - 1) * X * P1 - (K-1) * P0) / K P0 = P1 P1 = P2 END DO DPN = N * (P0 - X * P1) / (1.0_dp - X**2) DX = P1 / DPN X = X - DX IF (ABS(DX) .LE. TOL) EXIT END DO ZERO(I) = -X ZERO(N + 1 - I) = X W(I) = 2.0_dp / ((1.0_dp - X**2) * DPN**2) W(N + 1 - I) = W(I) END DO END SUBROUTINE SHGLQ_DP