'**************************************************** '* Program to demonstrate LN(X!) Subroutine * '* ------------------------------------------------ * '* Reference: BASIC Scientific Subroutines, Vol. II * '* By F.R. Ruckdeschel, BYTE/McGRAWW-HILL, 1981 [1].* '* ------------------------------------------------ * '* SAMPLE RUN: * '* * '* X LN(X!) EXP(LN(X!)) * '* ---------------------------------- * '* 1 -0.000307 1 * '* 2 0.693146 2 * '* 3 1.791759 6 * '* 4 3.178054 24 * '* 5 4.787492 120 * '* 6 6.579251 720 * '* 7 8.525161 5040 * '* 8 10.604603 40320 * '* 9 12.801827 362880 * '* 10 15.104413 3628800 * '* 11 17.502308 39916800 * '* 12 19.987214 479001600 * '* 13 22.552164 6227020800 * '* 14 25.191221 87178291200 * '* 15 27.899271 1307674368000 * '* * '**************************************************** 'See file chi-sq.txt, equation (2.3.9) DEFINT I-N DEFDBL A-H, O-Z CLS PRINT PRINT " X LN(X!) EXP(LN(X!)) " PRINT "----------------------------------" FOR x = 1 TO 15 GOSUB 1000 PRINT USING " ## ##.###### #############"; x; y; EXP(y) NEXT PRINT END '*************************************************** '* Series approximation subroutine for LN(X!) * '* ----------------------------------------------- * '* Accuracy better then 6 places for x>=3 * '* Accuracy better than 12 places for x>10 * '* Advantage is that very large values of the * '* argument can be used without fear of over flow. * '* x is the input, y is the output. * '* ----------------------------------------------- * '* Reference: CRC Math Tables. * ' ************************************************** 1000 x1 = 1# / (x * x) y = (x + .5#) * LOG(x) - x * (1# - x1 / 12# + x1 * x1 / 360# - x1 * x1 * x1 / 1260# + x1 * x1 * x1 * x1 / 1680#) y = y + .918938533205# RETURN 'End of file Logn!.bas