NormalizedLegendre Function

public 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.

Arguments

TypeIntentOptionalAttributesName
integer, intent(in) :: p
real(kind=real64), intent(in) :: x

Return Value real(kind=real64)


Called by

proc~~normalizedlegendre~~CalledByGraph proc~normalizedlegendre NormalizedLegendre proc~buildmodaltransform BuildModalTransform proc~buildmodaltransform->proc~normalizedlegendre proc~init_refinementindicator2d_t Init_RefinementIndicator2D_t proc~init_refinementindicator2d_t->proc~buildmodaltransform proc~init_refinementindicator2d Init_RefinementIndicator2D proc~init_refinementindicator2d->proc~init_refinementindicator2d_t

Contents

Source Code


Source Code

  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