laguerre_l Function

private elemental function laguerre_l(n, x)

Returns L_n(x) where L_n(x) is an ordinary Laguerre polynomial

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n
double precision, intent(in) :: x

Return Value double precision


Contents

Source Code


Source Code

  elemental function laguerre_l (n, x)
    implicit none
    integer, intent (in) :: n
    double precision, intent (in) :: x
    integer :: k
    double precision :: laguerre_l, p, p1, p2

    ! returns L_n(x)
    ! where L_n(x) is an ordinary Laguerre polynomial

    p1 = dble(1.0) - x
    p2 = dble(1.0)

    if (n==0) then
       laguerre_l = p2
       return
    else if (n==1) then
       laguerre_l = p1
       return
    end if

    do k=2, n
       p = ((2*k-1-x) * p1 - (k-1) * p2) / k
       p2 = p1
       p1 = p
    end do

    laguerre_l = p

  end function laguerre_l