(12C+) Bernoulli Number

07272019, 06:41 AM
(This post was last modified: 07282019 06:08 AM by Gamo.)
Post: #1




(12C+) Bernoulli Number
In need of the Bernoulli Number using HP12C ?
Here is an attempt to generate a Bernoulli Number constant using 12C Without a Pi function this program use 355/113 which give out about 4 to 5 digits precision.  To run: If you need to know B10 divide it by 2 is 5 5 [R/S] display 0.07576 [R/S] 5 [X<>Y] 66 Answer: B10 is 0.07576 or in fraction is 5/66  B12 12 ÷ 2 = 6 6 [R/S] display 0.25311 [R/S] 61 [X<>Y] 241 Answer: B12 since 12 is divisible by 4 answer is Negative 0.25311 in fraction is 61/241  Remark: To find B(n) divide it by 2 and calculate. This program do not give answer of the alternate negative value such as B2 = 1/6 where B4 = 1/30 For B(n) that divisible by 4 answer is "Negative"  Program: Code:
Formula use to calculate Bernoulli Number B(n) = [2(2n)! ÷ ((2^2n)  1)(Pi^2n)] [1 + (1/3^2n) + (1/5^2n) + ...] Gamo 

07272019, 12:41 PM
(This post was last modified: 07272019 10:41 PM by Albert Chan.)
Post: #2




RE: (12C+) Bernoulli Number
(07272019 06:41 AM)Gamo Wrote: Formula use to calculate Bernoulli Number Hi, Gamo I think there is a typo: B(n) should be abs(B(2n)) Can you provide source ? From https://wstein.org/edu/fall05/168/projec...rnproj.pdf zeta(x) = sum(k^x, where k = 1 to ∞) = 1 / product(1  p^x, where p is prime) B(2n) = (1)^(n+1) * 2*(2n)!/(2 pi)^(2n) * zeta(2n) 

07272019, 01:40 PM
Post: #3




RE: (12C+) Bernoulli Number  
07272019, 07:49 PM
Post: #4




RE: (12C+) Bernoulli Number
It looks like an exact formula to me but it is an infinite series, and I have no idea how fast it converges. The Wikipedia page on Bernoulli numbers has lots of useful information including some exact algorithms. The fastest methods do seem to require a lot of memory so they may not be suitable for a small calculator like the 12C.


07282019, 12:02 AM
(This post was last modified: 08252019 02:59 PM by Albert Chan.)
Post: #5




RE: (12C+) Bernoulli Number
I lookup "A Source Book in Mathematics", chapter "On the Bernoulli numbers":
B(n) is just sum of k^n formula linear term coefficient. Example, this is how B(6) is calculated, by doing k^6 forward difference (see thread: https://www.hpmuseum.org/forum/thread12...#pid110972) 1 64 729 4096 15625 46656 117649 // value of 1^6 to 7^6 63 665 3367 11529 31031 70993 // forward differences 602 2702 8162 19502 39962 2100 5460 11340 20460 3360 5880 9120 2520 3240 720 Sum of k^6 formula = \(1\binom{n}{1}+63\binom{n}{2}+602\binom{n}{3}+2100\binom{n}{4}+3360\binom{n}{5}+2520\binom{n}{6}+720\binom{n}{7}\) B(6) = Linear term coefficient = 1/1  63/2 + 602/3  2100/4 + 3360/5  2520/6 + 720/7 = 1/42 Correction: B(n) is sum of k^n formula, Σ(i^k, i = 0 to n1) linear term coefficient B(1) = linear coefficient of n(n+1)/2  n = 1/2  1 = 1/2 (see http://www.mikeraugh.org/Talks/Bernoulli...nLACC.pdf, slide 31 to 34) The Python code (next post), work for n=1 because it flipped sign for all odd n. The "bug" actually fix the sign 

07282019, 01:08 AM
(This post was last modified: 07282019 05:42 PM by Albert Chan.)
Post: #6




RE: (12C+) Bernoulli Number
Python code for Bernoulli Number (also return the forward difference table)
Code: from fractions import Fraction >>> B_fdiff(6) [Fraction(1, 42), 1, 63, 602, 2100, 3360, 2520, 720] >>> for i in range(13): print i, B_fdiff(i)[0] ... 0 1 1 1/2 2 1/6 3 0 4 1/30 5 0 6 1/42 7 0 8 1/30 9 0 10 5/66 11 0 12 691/2730 

07282019, 02:29 AM
(This post was last modified: 07282019 06:40 AM by Gamo.)
Post: #7




RE: (12C+) Bernoulli Number
I use this same program on RPN67 app the HP67 emulator.
This RPN67 got the printer feature so I did the loop print out. The result give good approximate answer from B2 to B112 B114 just give out incorrect answer to a whole number 107407655 the correct answer should be 5.17567436175..... Correct answer continue from B116 to B124 Then B126 and over all result are 1.000000000 *** Is this have to do with the limited value of the Factorial function? Clip: https://youtu.be/LH7yDHan08M Gamo 

07282019, 11:21 AM
(This post was last modified: 07282019 02:13 PM by John Keith.)
Post: #8




RE: (12C+) Bernoulli Number
(07282019 12:02 AM)Albert Chan Wrote: I lookup "A Source Book in Mathematics", chapter "On the Bernoulli numbers": That is a very neat method, I was not aware of that one. However, it seems that all similar exact methods require n+(n1) storage registers to calculate B(n) since one needs to keep the (n1)th row of the difference table in memory while calculating the nth row. EDIT: I tried your program as well as the AkiyamaTanagiwa method as used in the third program here on the HP48G and both methods fail due to catastrophic rounding error for n>10. These methods may only be practical for languages that use exact rational arithmetic. 

07312019, 05:14 PM
(This post was last modified: 07312019 11:04 PM by Albert Chan.)
Post: #9




RE: (12C+) Bernoulli Number
Knowing the pattern of s_{k}(n) = (Σi^k, k=0 to n1) = n^(k+1)/(k+1)  n^k/2 + k/12 * n^(k1) + 0 * x^(k2) + ...,
we can get Bernoulli constants another way. Example: to get upto B(6), s_{6}(n) = n^7/7  n^6/2 + n^5/2 + a*n^3 + b*n, where a, b are unknown → a*n^2 + b = s_{6}(n)/n  n^4*(n^2/7  (n1)/2) For n=1, eqn1 = a + b = 0/1  1*(1/7  0/2) = 1/7 For n=2, eqn2 = 4a + b = 1/2  16*(4/7  1/2) = 9/14 eqn2  eqn1: 3a = 9/14 + 2/14 = 1/2 → a = 1/6 B(6) = b = 1/7  a = 1/42 B(4) = a * 3 / \(\binom{6}{4}\) = 1/30 B(2) = (1/2) * 5 / \(\binom{6}{2}\) = 1/6 B(1) = (1/2) * 6 / \(\binom{6}{1}\) = 1/2 B(0) = (1/7) * 7 / \(\binom{6}{0}\) = 1 

« Next Oldest  Next Newest »

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