Bernoulli polynomials using nested summations

Description

Posted by Namir in the MoHPC - HP Forum

Program calculates Bernoulli polynomials using nested summations (see Wikipedia).

Example 1:

5
ENTER
3.5
f A

output is 220.9375

Example 2:

3
ENTER
5.5
f A

output is 123.7500

Note: I was thinking about writing a second version of the listing for the HP-14C that uses the ISG command for registers 2 and 3. The problem is whenever the listing uses RCL 2 and RCL 3 it must be followed by the INT command. This adds more steps IMHO. So I abandoned the ISG-using version.

Program Resources

Labels

Name Description
 A
 1
 2

Storage Registers

Name Description
 0 x
 1 m
 2 n
 3 5
 4 Bm(x)
 5 inner sum

Program

Line Display Key Sequence Line Display Key Sequence
000 024 45 3 RCL 3
001 42,21,11 f LBL A 025 14
002 44 0 STO 0 026 20 ×
003 34 x↔y 027 44,40, 5 STO + 5
004 44 1 STO 1 028 1 1
005 0 0 029 44,40, 3 STO + 3
006 44 2 STO 2 030 45 2 RCL 2
007 44 4 STO 4 031 45 3 RCL 3
008 42,21, 1 f LBL 1 032 43 10 g x≤y
009 0 0 033 22 2 GTO 2
010 44 3 STO 3 034 45 5 RCL 5
011 44 5 STO 5 035 45 2 RCL 2
012 42,21, 2 f LBL 2 036 1 1
013 45 2 RCL 2 037 40 +
014 45 3 RCL 3 038 10 ÷
015 43 40 g Cy,x 039 44,40, 4 STO + 4
016 45 0 RCL 0 040 1 1
017 45 3 RCL 3 041 44,40, 2 STO + 2
018 40 + 042 45 1 RCL 1
019 45 1 RCL 1 043 45 2 RCL 2
020 14 044 43 10 g x≤y
021 20 × 045 22 1 GTO 1
022 1 1 046 45 4 RCL 4
023 16 CHS 047 43 32 g RTN