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.

To anyone who enjoys HP28 optimization please work on this.  I know it can be
much faster but I just haven't had the time.

J
<< -> n x <<
   << IF n 0 < THEN
	 n NEG x J
	 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 *
	 0
	 1.e-50
	 DUP
	 DUP 2 *
	 0
	 0
	 -> m bkp1 tiny bk t bn bkp2 <<
	   m 1 - 0 FOR k
	      bkp1 'bkp2' STO
	      bk 'bkp1' STO
	      2 k 1 + * bkp1 * x / bkp2 - 'bk' STO
	      IF k n == bk THEN 
		 bk 'bn' STO 
	      END
	      IF k 0 > k 2 MOD 0 == AND THEN
		 t 2 bk * + 't' STO
	      END
	      if k 0 == THEN
		 t bk + 't' STO
	      END
	   -1 STEP
	   bn t /
         >>
      END
      END
   >>
>>

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

-------------------------------------------------------------------------------

From: wscott@EN.ECN.PURDUE.EDU (Wayne H Scott)
Newsgroups: comp.sys.handhelds
Subject: new Bessel function
Date: 21 Feb 90 05:14:53 GMT


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.

J
<< -> n x <<
   << IF n 0 < THEN
        n NEG x J
        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
   >>
>>

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







