From wscott%EN.ECN.PURDUE.EDU@VM1.NoDak.EDU Wed Feb 21 09:34:51 1990
Date:         Wed, 21 Feb 90 00:16:06 -0500
Reply-To: HP-28 -  HP-28C and HP-28S Calculators <HP-28@VM1.NoDak.EDU>
Sender: HP-28 -  HP-28C and HP-28S Calculators <HP-28@VM1.NoDak.EDU>
From: Wayne H Scott <wscott%EN.ECN.PURDUE.EDU@VM1.NoDak.EDU>
Subject:      new Bessel
X-To:         HP-28@VM1.NoDak.EDU
To: Multiple recipients of list HP-28 <HP-28@NDSUVM1>

This is a new version of the bessel function program.  It is faster by
using stack functions and it fixes one bug in the previous posting.

This is a function I wrote to aid in my study of FM signal modulation.
It computes the bessel function.
It expects n and x to be on the stack and it returns the result of the
bessel function.
Note it is recursive so it should be named J or change the one reference
to this name within the program.

Works on HP28 or HP48

Jn
<< -> n x <<
   << IF n 0 < THEN
        n NEG x Jn
        n 2 MOD 2 * 1 - * NEG
     ELSE IF x 0 == THEN
     n 0 ==
      ELSE
     17.1032 .2639 n * + .6487 x ABS * + .0018 n * x ABS * -
     .6457 n x ABS MAX * +
     .5 + FLOOR 2 / CEIL 2 *
     1.e-50
     0
     -> m tiny bn <<
       tiny 2 *
       0
       0
       tiny
       m 1 - 0 FOR k
          ROT DROP
          2 k 1 + * OVER * x / 3 PICK -
          IF k n == THEN
             DUP 'bn' STO
          END
          if k 0 == THEN
            DUP 5 ROLL + 4 ROLLD
	  ELSE
            IF k 2 MOD 0 == THEN
              DUP 2 * 5 ROLL + 4 ROLLD
            END
	  END
       -1 STEP
       3 DROPN
       bn SWAP /
         >>
      END
      END
   >>
>>

If entered on a HP-48sx checksum=#9519h  555.5 bytes

Ported from MatLab librarys.

_______________________________________________________________________________
Wayne Scott             |  INTERNET:   wscott@en.ecn.purdue.edu
Electrical Engineering  |  BITNET:     wscott%ea.ecn.purdue.edu@purccvm
Purdue University       |  UUCP:      {purdue, pur-ee}!en.ecn.purdue.edu!wscott


