L2-normalized Legendre polynomial Ltilde_p(x) = L_p(x)*sqrt((2p+1)/2) on [-1,1], evaluated with the standard three-term recurrence. The normalization gives int_{-1}^{1} Ltilde_p Ltilde_q dx = delta_pq.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | p | |||
| real(kind=real64), | intent(in) | :: | x |
pure function NormalizedLegendre(p,x) result(Lp)
!! L2-normalized Legendre polynomial Ltilde_p(x) = L_p(x)*sqrt((2p+1)/2) on [-1,1],
!! evaluated with the standard three-term recurrence. The normalization gives
!! int_{-1}^{1} Ltilde_p Ltilde_q dx = delta_pq.
implicit none
integer,intent(in) :: p
real(real64),intent(in) :: x
real(real64) :: Lp
! Local
integer :: k
real(real64) :: lkm1,lk,lkp1
if(p == 0) then
Lp = 1.0_real64
elseif(p == 1) then
Lp = x
else
lkm1 = 1.0_real64
lk = x
do k = 1,p-1
lkp1 = (real(2*k+1,real64)*x*lk-real(k,real64)*lkm1)/real(k+1,real64)
lkm1 = lk
lk = lkp1
enddo
Lp = lk
endif
Lp = Lp*sqrt((2.0_real64*real(p,real64)+1.0_real64)/2.0_real64)
endfunction NormalizedLegendre