Skip to content
brickpool edited this page Jul 22, 2020 · 2 revisions

Machine Related Operations

Source: HP-45 Applications Book (HP 00045-90320 Rev. B Reorder 00045-66001, Dec 1974)


Numbers

Fibonacci numbers

Formula:

In a Fibonacci sequence, each term is the sum of the two preceding terms.

fi = fi-1 + fi-2

fi represents the ith term in the sequence.

Example:

Develop the Fibonacci sequence with f1 = 1, f2 = 1.

Answer:

1, 1, 2, 3, 5, 8, 13, 21, …

LINE DATA OPERATIONS DISPLAY REMARKS
1 f1 ENTER
2 f2
3 ENTER ENTER R↓ R↓ + fi Perform 3 for i=3,4,…
; XEQ F ENTER
        LBL     F
        CLx
        ENTER
        !
@005:   PSE
        eqn     'REGX+REGY'
        GTO     @005

Source: Morten Nygaard Åsnes (208623)

Finding the nth Fibonacci number

Formula:

f_{n}=\left\lfloor\frac{1}{\sqrt{5}}\left(\frac{1+\sqrt{5}}{2}\right)^{n}+\frac{1}{2}\right\rfloor

Example:

Find the 12th Fibonacci number in the sequence 1, 1, 2, 3, 5, 8 …

Answer:

144

LINE DATA OPERATIONS DISPLAY REMARKS
1 n ENTER 5 √x +> STO
2 A ENTER 1 + 2
3 ÷ x<>y RCL A
4 ÷ <+ DISPLAY 1'FIX 0

Harmonic numbers

Formula:

The Harmonic numbers Hi (i = 1, 2, …) are

1, 1+12, 1+12+13, 1+12+13+14, …

or

1, 32, 116, 2512, …

Example:

Display the sequence in decimal form.

Answer:

1.00, 1.50, 1.83, 2.08, …

LINE DATA OPERATIONS DISPLAY REMARKS
1 \CC ENTER +> STO H
2 \CC Perform 2-4 for i=1,2,…
3 1 + ENTER 1/x RCL
4 H + +> STO H Hi

nth harmonic number

Formula:

H_{n}=\sum_{k=1}^{1}\frac{1}{k}=\ln{n}+\gamma+\frac{1}{2n}-\frac{1}{12n^{2}}+\frac{1}{120n^{4}}-\cdots

Example:

Find the 7th Harmonic number.

Answer:

2.59

Note:

E = 0.5772156649 is Euler's constant (usually denoted by the lowercase Greek letter γ).

LINE DATA OPERATIONS DISPLAY REMARKS
1 +> STO A 1/x ENTER
2 ENTER ENTER 1 2 0
3 1/x × × 1 2
4 1/x - × 2 1/x
5 + ×
6 E + RCL A +> ln
7 +

Bernoulli Numbers

The Bernoulli numbers Bl, B2, B3 … are defined by

B_{n}=\frac{2(2n)!}{(2^{2n}-1)\pi^{2n}}\left[1+\frac{1}{3^{2n}}+\frac{1}{5^{2n}}+\cdots\right]

specifically

16, 130, 142, 130, 566, 6912730, 76, …

Example:

The 16th Bernoulli number = 7.09 (i takes the values 1, 2).

LINE DATA OPERATIONS DISPLAY REMARKS
1 n ENTER 2 × ENTER ENTER
2 ENTER ENTER
3 +> STO B \CC Perform 3-6 for i=1,2,…
4 i ENTER 2 × 1 + until change Ai does not change
5 x<>y 1/x RCL B
6 + Ai
7 R↓ +> ! 2 ×
8 RCL B × R↓ R↓
9 2 x<>y 1 -
10 x<>y <+ π x<>y
11 × ÷
; XEQ B ENTER
        LBL     B
        STO     C
        1
        x>y?
        RTN
        STO     X
        RCL+    X
        x<=y?
        GTO     @12
        1/x
        +/-
        RTN
@12:
        x!=y?
        GTO     @18
        6
        1/x
        RTN
@18:
        RMDR
        0
        x!=y?
        RTN
        4
        RCL     C
        x!=y?
        GTO     @31
        30
        1/x
        +/-
        RTN
@31:
        6
        x!=y?
        GTO     @38
        42
        1/x
        RTN
@38:
        x<>y
        FIX     9
        XEQ     ZETA
        STO     X
        RCL+    X
        1
        +/-
        RCL     C
        2
        /
        y^x
        *
        +/-
        pi
        STO     X
        RCL+    X
        1e-9
        -
        RCL     C
        y^x
        /
@58:
        RCL     C
        *
        DSE     C
        GTO     @58
        RTN
ZETA:
        +/-
        STO     B
        1
        STO     A
        ENTER
@07:
        CLx
        !               ; REGX = 1
        RCL     A
        +
        STO     A
        RCL     B
        y^x
        -
        +/-
        LASTx
        RND             ; the accuracy is determined by the display format.
        x!=0?
        GTO     @07
        !               ; REGX = 1
        2
        RCL     B
        y^x
        STO     X
        RCL+    X
        -
        /
        ABS
        RTN

Source: Jean-Marc Baillard (41bernu)

Euler Numbers

Compute the nth Euler number

Note:

The Euler numbers are 1, 5, 61, 1385, 50521, …

Formula:

The Euler numbers E1, E2, E3, … are defined by

E_{n}=\frac{2^{2n+2},(2n)!}{\pi^{2n+1}}\left[1-\frac{1}{3^{2n+1}}+\frac{1}{5^{2n+1}}-\frac{1}{7^{2n+1}}+\cdots\right]

Example:

The 5th Euler number = 50521.

LINE DATA OPERATIONS DISPLAY REMARKS
1 n ENTER 2 × ENTER ENTER
2 ENTER +> ! x<>y 2
3 + 2 x<>y ×
4 x<>y 1 ÷ <+ π
5 x<>y ÷ <+ DISPLAY
6 1'FIX 0
Clone this wiki locally