************80
! SPHY computes spherical Bessel functions yn(x) and their derivatives.
Licensing:
This routine is copyrighted by Shanjie Zhang and Jianming Jin. However,
they give permission to incorporate this routine into a user program
provided that the copyright is acknowledged.
Modified:
15 July 2012
Author:
Shanjie Zhang, Jianming Jin
Reference:
Shanjie Zhang, Jianming Jin,
Computation of Special Functions,
Wiley, 1996,
ISBN: 0-471-11963-6,
LC: QA351.C45.
Parameters:
Input, integer ( kind = 4 ) N, the order.
Input, real ( kind = 8 ) X, the argument.
Output, integer ( kind = 4 ) NM, the highest order computed.
Output, real ( kind = 8 ) SY(0:N), DY(0:N), the values of yn(x) and yn'(x).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=4) | :: | n | ||||
real(kind=8) | :: | x | ||||
integer(kind=4) | :: | nm | ||||
real(kind=8) | :: | sy(0:n) | ||||
real(kind=8) | :: | dy(0:n) |
subroutine sphy ( n, x, nm, sy, dy ) !*****************************************************************************80 ! !! SPHY computes spherical Bessel functions yn(x) and their derivatives. ! ! Licensing: ! ! This routine is copyrighted by Shanjie Zhang and Jianming Jin. However, ! they give permission to incorporate this routine into a user program ! provided that the copyright is acknowledged. ! ! Modified: ! ! 15 July 2012 ! ! Author: ! ! Shanjie Zhang, Jianming Jin ! ! Reference: ! ! Shanjie Zhang, Jianming Jin, ! Computation of Special Functions, ! Wiley, 1996, ! ISBN: 0-471-11963-6, ! LC: QA351.C45. ! ! Parameters: ! ! Input, integer ( kind = 4 ) N, the order. ! ! Input, real ( kind = 8 ) X, the argument. ! ! Output, integer ( kind = 4 ) NM, the highest order computed. ! ! Output, real ( kind = 8 ) SY(0:N), DY(0:N), the values of yn(x) and yn'(x). ! implicit none integer ( kind = 4 ) n real ( kind = 8 ) dy(0:n) real ( kind = 8 ) f real ( kind = 8 ) f0 real ( kind = 8 ) f1 integer ( kind = 4 ) k integer ( kind = 4 ) nm real ( kind = 8 ) sy(0:n) real ( kind = 8 ) x nm = n if ( x < 1.0D-60 ) then do k = 0, n sy(k) = -1.0D+300 dy(k) = 1.0D+300 end do return end if sy(0) = - cos ( x ) / x sy(1) = ( sy(0) - sin ( x ) ) / x f0 = sy(0) f1 = sy(1) do k = 2, n f = ( 2.0D+00 * k - 1.0D+00 ) * f1 / x - f0 sy(k) = f if ( 1.0D+300 <= abs ( f ) ) then exit end if f0 = f1 f1 = f end do nm = k - 1 dy(0) = ( sin ( x ) + cos ( x ) / x ) / x do k = 1, nm dy(k) = sy(k-1) - ( k + 1.0D+00 ) * sy(k) / x end do return end subroutine sphy