'**************************************************** '* Program to demonstrate BESSEL series summation * '* ------------------------------------------------ * '* Reference: BASIC Scientific Subroutines, Vol. II * '* By F.R. Ruckdeschel, BYTE/McGRAWW-HILL, 1981 [1].* '* ------------------------------------------------ * '* SAMPLE RUN: * '* * '* BESSEL SERIES SUMMATION * '* * '* What is the order of the Bessel function ? 2 * '* Argument ? 1 * '* Convergence criterion ? 1e-6 * '* * '* J( 1 ) of order 2 = .114903485333478 * '* * '* Number of terms used: 4 * '**************************************************** DEFINT I-N DEFDBL A-H, O-Z CLS PRINT "BESSEL SERIES SUMMATION" PRINT INPUT "What is the order of the Bessel function ? ", n INPUT "Argument ? ", x INPUT "Convergence criterion ? ", e PRINT GOSUB 1000 PRINT "J("; x; ") of order "; n; " = "; y PRINT PRINT "Number of terms used: "; m PRINT END '************************************* '* Bessel function series subroutine * '* The order is n, the argument x. * '* The returned value is in y. * '* The number of terms used is in m. * '* e is the convergence criterion * '* Example: e = 1e-6. * '************************************* 1000 a = 1 IF n <= 1 THEN GOTO 1100 'Calculate N! FOR i = 1 TO n a = a * i NEXT 1100 a = 1 / a IF n = 0 THEN GOTO 1200 'Calculate multiplying term FOR i = 1 TO n a = a * x / 2 NEXT 1200 b0 = 1 b2 = 1: m = 0 'Assemble series sum 1210 m = m + 1 b1 = -(x * x * b0) / (m * (m + n) * 4) b2 = b2 + b1 b0 = b1 'Test for convergence IF ABS(b1) > e THEN GOTO 1210 'Form final answer y = a * b2 RETURN 'End file Besslser.bas 