The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function

 (DM 42) Bernoulli and tangent numbers
03-20-2023, 08:06 PM (This post was last modified: 03-21-2023 10:58 AM by Gjermund Skailand.)
Post: #1
 Gjermund Skailand Member Posts: 78 Joined: Dec 2013
(DM 42) Bernoulli and tangent numbers
B2n, Tn: Fast calculation of Bernoulli numbers based on Tangent numbers

Input: n
output: result in register 0 to n, even Bernoulli numbers b2n
note b1= +/-0.5, all other odd numbers=0. For b1 the latest definition is +0.5
can also provide Tangent numbers depending on flag 00

flag 00 cancelled: Calculate even Bernoulli numbers B2n
flag 00 set : calculate tangent numbers Tn
flag is reset after each run

runs in standard 4 stack mode, uses registers 0-n and flag 00

Calculates Bn60 (n=0..30) in less than a second on batteries.
On USB power, calculates up to n=999, i.e. the 0-1998th Bernoulli numbers in about 5min 40 seconds.
Ref
"Fast computation of Bernoulli, Tangent and Secant Numbers. "
Richard P. Brent and David Harvey
6 Algorithms based three-term recurrences
arXiv:1108.0286v3 [math.CO] 5 Sep 2011

The algorithm is stable, and should return Bernoulli numbers accurate to 31-32 digits
2022-03-20 DM-42 version Gjermund Skailand

00 { 126-Byte Prgm }
01▸LBL "Tn"
02 SF 00
03▸LBL "B2n"
04 1ᴇ3
05 ÷
06 2
07 +
08 ENTER
09 ENTER
10 1
11 STO 01
12 1
13▸LBL 00
14 ×
15 STO IND ST Y
16 RCL ST Y
17 IP
18 ISG ST Z
19 GTO 00
20 R^
21▸LBL 01
22 ENTER
23 ENTER
24 ENTER
25 1
26 -
27 R↓
28 RCL IND ST T
29▸LBL 02
30 RCL ST Y
31 RCL- ST T
32 ×
33 2
34 RCL+ ST L
35 RCL× IND ST Z
36 +
37 STO IND ST Y
38 ISG ST Y
39 GTO 02
40 R↓
41 R↓
42 ISG ST X
43 GTO 01
44 FP
45 1
46 STO 00
47 +
48 FS?C 00
49 RTN
50▸LBL 03
51 ENTER
52 IP
53 RCL× IND ST X
54 2
55 LASTX
56 STO+ ST X
57 DSE ST X
58 Y^X
59 ÷
60 LASTX
61 STO+ ST X
62 1
63 -
64 ÷
65 FS? 00
66 +/-
67 FC?C 00
68 SF 00
69 STO IND ST Y
70 R↓
71 ISG ST X
72 GTO 03
73 CF 00
74 END

Attached File(s)
B2n.zip (Size: 1.18 KB / Downloads: 3)
 « Next Oldest | Next Newest »

 Messages In This Thread (DM 42) Bernoulli and tangent numbers - Gjermund Skailand - 03-20-2023 08:06 PM RE: (DM 42) Bernoulli and tangent numbers - Werner - 03-22-2023, 08:46 AM RE: (DM 42) Bernoulli and tangent numbers - Gjermund Skailand - 03-22-2023, 11:45 AM

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