Bessel Function (4 versions)
|
12-24-2013, 12:38 PM
(This post was last modified: 12-24-2013 12:46 PM by Namir.)
Post: #1
|
|||
|
|||
Bessel Function (4 versions)
This document presents a set of programds that implement the Bessel Function Jn(x).
Version 1 The first version is based on an HP-25 program by Peter Henrici. The HP-41C implementation extends the original HP-25 program to calculate the Bessel functions to any non-negative integer order. The original HP-25 calculated J(0,x) through J(4,x). The HP-41C implementation also does that and then determines if the targeted order is in the range of 0 to 4. If, so, the program simply returns the result already available. If the targetd order is 5 and up, the program uses a recurive relation to calculate the higher order function starting with the values of J(3,x) and J(4,x) which are already available. Algorithm Given Bessel order N, argument x, and maximum number of iterations m: Code: Let y0 = 1 Memory Map R00 = J0 R01 = J1 R02 = J2 R03 = J3 R04 = J4 R05 = R06 = x R07 = m R08 = n R09 = i Listing Code:
Usage 1. To store the maximum number of iterations, press [f][A]. The program displays the "M?" prompt to ask you for the maximum number of iterations. Enter that value and press [R/S]. If enter 0 or if you skip this value, the program assigns 50 to the maximum number of iterations. 2. To enter the order of the Bessel function and its argument, press [A]. The program displays the "N^X?" prompt to request these values. Enter the order of the Bessel function and its argument, and then press [R/S]. 3. The program iterates and then displays the result as "J=<value>". 4. To enter a new function order and argument resume at step 2. Version 2 The second version uses the definition of Bessel function that is based on an integral. The program uses the INTEG command found in the Advantage Module to perform required numerical integration. Using the INTEG command shortens the code significantly, while gaining speed, and without compromise of the accuracy of the results. Algorithm Code:
For n being a non-negative integer. Memory Map R00 = x R01 = n Listing Code: LBL "BESSL2" Usage 1. To enter the order of the Bessel function and its argument, press [A]. The program displays the "N^X?" prompt to request these values. Enter the order of the Bessel function and its argument, and then press [R/S]. 2. The program calculates the Bessel function and then displays its value as "J=<value>". Version 3 The third version uses the definition of Bessel function that is also based on an integral and also works with non-integer Bessel function orders. The program uses the INTEG command found in the Advantage Module to perform required numerical integration. Using the INTEG command shortens the code significantly, while gaining speed, and without compromise of the accuracy of the results. Algorithm Code:
For n being the order of the Bessel function. Memory Map R00 = x R01 = n R02 = argument for calculating the gamma function and for calculating the integral R03 = used to calculate the result Listing Code: LBL "BESSL3" Usage 1. To enter the order of the Bessel function and its argument, press [A]. The program displays the "N^X?" prompt to request these values. Enter the order of the Bessel function and its argument, and then press [R/S]. 2. The program calculates the Bessel function and then displays its value as "J=<value>". Version 4 The fourth version uses the definition of Bessel function that uses a summation and one value for the Gamma function. The implementation calculates the Bessel function for any non-negative integer and non-integer order. Algorithm J(n,x) = (x/2^n / Gamma(n+1) * sum((-1)^i * (x/2)^(2*i) / (n+1) / (i!), for i = 0 to infinity) For n being the order of the Bessel function. Given tolerance, x, and order n: Code: Let y = x/2 Note: In Henrici's book the flow chart shows J being calculated as a * b. This is an error. The book's listing for the HP-25 multiplies the correct operands. Memory Map R00 = n R01 = Gamma(n+1) R02 = tolerance R03 = a R04 = sum R05 = b R06 = N R07 = x/2 R08 = used to calculate the gamma function in LBL 00 Listing Code: LBL "BESSL4" Usage 1. To enter the tolerance value press [f][A]. The program uses the "TOLER?" prompt you to ask for the toelrance value. Enter this value and press [R/S]. The program resumes to step 2 without the need to press [A]/ 2. To enter the order of the Bessel function and its argument, press [A]. The program displays the "N^X?" prompt to request these values. Enter the order of the Bessel function and its argument, and then press [R/S]. 3. The program calculates the Bessel function and then displays its value as "J=<value>". Test Data Code:
Code: n x J(n,x) |
|||
12-25-2013, 02:31 PM
(This post was last modified: 12-25-2013 02:34 PM by aurelio.)
Post: #2
|
|||
|
|||
RE: Bessel Function (4 versions)
(12-24-2013 12:38 PM)Namir Wrote: This document presents a set of programds that implement the Bessel Function Jn(x). thank-you Namir, I have that book (computational analysis with the HP25 pocket calculator, isn't it?) and I was reading it in train just this morning..... I started with programs designed for the numeric series........... I would like to transport any of the programs suited for the HP25 and HP33 to the HP41C....what a big enterprise for a "old" beginner like me.. |
|||
12-28-2013, 04:41 AM
Post: #3
|
|||
|
|||
RE: Bessel Function (4 versions)
The older the programmable calculator is the easier it is to translate its commands to a newer one. Just today, I easily keyed in 2 HP-65 programs in an HP-41CX. I had no trouble entering and running the HP-65 program in the HP-41CX.
|
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)