Post Reply 
(HP71B) Euler Polynomials
07-17-2023, 05:16 PM
Post: #1
(HP71B) Euler Polynomials
Euler Polynomials for HP-17B
================================

Memory Map
==========

N: Order (Integer)
N0:Last N (Integer)
N9: N!
X: X argument (Floating point)
X9: X-0.5
E(): Bernoulli number array (Floating point)
E0: Bernoulli polynomial Bern(N,X) (Floating point)
I, J, K, M: Loop control variables (Integer)


Usage
=====

1) Press RUN key.
2) The program displays the prompt "N? ".
3) Enter N and press the END LINE key.
4) The program displays the prompt "X? ".
5) Enter X and press the END LINE key.
6) The program displays N, X, and the value of the Euler polynomial.
7) Press the [f][+] keys and go to step 2.

Example
=======

Examples of B(N,X) are:

B(8,2.5) = 56.66015625
B(6,2.5) = 21.796875
B(4,2.5) = 10.3125

Listing
=======

Code:
Line     Step
10    REM EULER POLYNOMIAL
20    DESTROY ALL
30    N0=0
40    INPUT "N? ";N
50    INPUT X? ";X
60    IF N=N0 THEN GOTO 100
70    DIM E(N)
80    CALL EULR(E(),N)
90    N0=N
100    E0=0
110    N9=FACT(N)
120    X9=X-0.5
130    FOR K=0 TO N
140    E0=E0+N9/FACT(K)/FACT(N-K)/2^K*E(K)*X9^(N-K)
150    NEXT K
160    DISP "E(";N;",";X;"=";E0
170    PAUSE
180    GOTO 40
190    END
200    SUB EULR(E(),N)
210    E(0)=1
220    FOR M=1 TO INT(N/2)
230    S=1
240    FOR K=1 TO M-1
250    R=1
260    FOR J=2 TO 2* K
270    R=R*(2*(M-K)+J)/J
280    NEXT J
290    S=S+R*E(2*K)
300    NEXT K
310    E(2*M) = -S
320    NEXT M
330    END SUB


The above code checks if the value of N you enter is the same one you entered the last time. If so, the code skips calling the subroutine EULR since it already has the values of the Euler numbers from the last round of calculations.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)