'************************************************************************ '* * '* Program to calculate the second kind Bessel function of integer * '* order N, for any REAL X, using the function BESSY(N,X). * '* * '* -------------------------------------------------------------------- * '* * '* SAMPLE RUN: * '* * '* (Calculate Bessel function for N=2, X=0.75). * '* * '* Second kind Bessel function of order 2 for X = 0.7500: * '* * '* Y = -2.629746036321392 * '* * '* -------------------------------------------------------------------- * '* Reference: From Numath Library By Tuan Dang Trong in Fortran 77. * '* * '* Basic Release 1.0 By J-P Moreau, Paris. * '* (www.jpmoreau.fr) * '************************************************************************ 'PROGRAM TBESSY DEFINT I-N DEFDBL A-H, O-Z ' X, Y: Double ' N: Integer CLS PRINT PRINT " BESSEL FUNCTIONS OF SECOND KIND" PRINT INPUT " ORDER = ", N PRINT INPUT " X = ", X GOSUB 500 'CALL BESSY(N, X) PRINT PRINT " BESSY OF ORDER "; N; " = "; BESSY PRINT END 'of main program 500 'FUNCTION BESSY (N, X) ' ---------------------------------------------------------------- ' This function calculates the second kind Bessel Function of ' integer order N, for any real X. We use here the classical ' recursive formula. ' ---------------------------------------------------------------- IF N = 0 THEN GOSUB 800 BESSY = BESSY0 RETURN END IF IF N = 1 THEN GOSUB 900 BESSY = BESSY1 RETURN END IF IF X = 0# THEN BESSY = -1D+30 RETURN END IF TOX = 2# / X GOSUB 900: BY = BESSY1 GOSUB 800: BYM = BESSY0 FOR J = 1 TO N - 1 BYP = J * TOX * BY - BYM BYM = BY BY = BYP NEXT J BESSY = BY RETURN 600 'FUNCTION BESSJ0 (X) ' THIS FUNCTION RETURNS THE VALUE OF THE FIRST KIND BESSEL FUNCTION ' OF ORDER 0 FOR ANY REAL X. WE USE HERE THE POLYNOMIAL APPROXIMATION ' BY SERIES OF CHEBYSHEV POLYNOMIALS FOR 0= 0# THEN SIGN = ABS(S6) ELSE SIGN = -ABS(S6) END IF BESSJ1 = SQR(P6 / AX) * (COS(XX) * FP - Z * SIN(XX) * FQ) * SIGN END IF RETURN 800 'FUNCTION BESSY0 (X) ' ---------------------------------------------------------------------- ' This subroutine calculates the Second Kind Bessel Function of ' order 0, for any real number X. The polynomial approximation by ' series of Chebyshev polynomials is used for 0