| New Reply |
Need help with a fortran-routine that calculates the associated Laguerre function |
Share Thread | Thread Tools |
| Aug10-11, 04:33 PM | #1 |
|
|
Need help with a fortran-routine that calculates the associated Laguerre function
Hi!
Im trying to do some rather easy QM-calculations in Fortran. To do that i need a routine that calculates the generalized Laguerre polynomials. I just did the simplest implementation of the equation: [tex]L^l_n(x)=\sum_{k=0}^n\frac{(n+l)!(-x^2)^k}{(n-k)!k!}[/tex] I implemented this in the following way: Code:
SUBROUTINE LAGUERRE(n,l,r,u,arraylength)
Implicit none
INTEGER, INTENT(IN) :: arraylength,n
real(kind=kind(0.d0)), INTENT(IN) :: l
REAL(kind=kind(0.d0)), INTENT(IN),DIMENSION(arraylength) :: r
REAL(kind=kind(0.d0)), INTENT(OUT),DIMENSION(arraylength) :: u
REAL(kind=kind(0.d0)), DIMENSION(arraylength) :: temp
Integer :: m
temp=0.d0
do m=0,n
temp=temp+gamma(real(n)+l+1.0)*(-r)**m/
+ (gamma(real(n)-real(m)+1.0)*gamma(l+real(m)+1.0)
+ *gamma(real(m)+1.0))
end do
u=temp
END SUBROUTINE LAGUERRE
So my questions are: Do you see some obvious mistakes? Do you think there are possibilities for numerical errors? (In such a case, do you have any advices on improvments?) When i have been googling around, it looks like alot of the numerical implementations are using recursive relations. What are the pro's and con's for doing this kind of calculation in such a manner? |
| Aug12-11, 06:42 AM | #2 |
|
Recognitions:
|
What is gamma? Is it an array, a function, a subroutine?
|
| Aug12-11, 08:44 AM | #3 |
|
Recognitions:
|
I just did the simplest implementation of the equation: [tex]L^l_n(x)=\sum_{k=0}^n\frac{(n+l)!(-x^2)^k}{(n-k)!k!}[/tex] I implemented this in the following way: Code:
SUBROUTINE LAGUERRE(n,l,r,u,arraylength)
Implicit none
INTEGER, INTENT(IN) :: arraylength,n
real(kind=kind(0.d0)), INTENT(IN) :: l
REAL(kind=kind(0.d0)), INTENT(IN),DIMENSION(arraylength) :: r
REAL(kind=kind(0.d0)), INTENT(OUT),DIMENSION(arraylength) :: u
REAL(kind=kind(0.d0)), DIMENSION(arraylength) :: temp
Integer :: m
temp=0.d0
do m=0,n
temp=temp+gamma(real(n)+l+1.0)*(-r)**m/
+ (gamma(real(n)-real(m)+1.0)*gamma(l+real(m)+1.0)
+ *gamma(real(m)+1.0))
end do
u=temp
END SUBROUTINE LAGUERRE
Where did the (l+k)! term come from? Why isn't "r" squared. |
| New Reply |
| Tags |
| fortran, numerical analysis, qm calculation |
| Thread Tools | |
Similar Threads for: Need help with a fortran-routine that calculates the associated Laguerre function
|
||||
| Thread | Forum | Replies | ||
| Fortran Routine calling a Python Function | Programming & Comp Sci | 2 | ||
| Function with calculates the profit in terms of qty sold! | Calculus & Beyond Homework | 3 | ||
| Dot product calculates what exactly? | General Math | 14 | ||
| Determine a function that calculates the nth weight factor of a wave function | Advanced Physics Homework | 0 | ||
| Calculates a moment of inertia for Circle | General Math | 1 | ||