blandin-diaz_compositional_bernoulli_numbers_B_Z_1.sf 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/usr/bin/ruby
  2. # Author: Daniel "Trizen" Șuteu
  3. # Date: 23 February 2018
  4. # https://github.com/trizen
  5. # A new recurrence for computing Blandin-Diaz compositional Bernoulli numbers (B^Z)_1,n.
  6. # Formula:
  7. # a(0) = 1
  8. # a(n) = -Sum_{k=0..n-1} a(k) * binomial(n, k) / (n-k+1)^2
  9. # Which gives us the nth Blandin-Diaz compositional Bernoulli number as:
  10. # (B^Z)_1,n = a(n)
  11. # See also:
  12. # https://arxiv.org/abs/0708.0809
  13. # OEIS entries:
  14. # https://oeis.org/A132096 (numerators)
  15. # https://oeis.org/A132097 (denominators)
  16. func a((0)) { 1 }
  17. func a(n) is cached {
  18. -sum(^n, {|k| a(k) * binomial(n, k) / (n - k + 1)**2 })
  19. }
  20. for n in (0..30) {
  21. printf("(B^Z)_1(%2d) = %50s / %s\n", n, a(n) -> nude)
  22. }
  23. __END__
  24. (B^Z)_1( 0) = 1 / 1
  25. (B^Z)_1( 1) = -1 / 4
  26. (B^Z)_1( 2) = 1 / 72
  27. (B^Z)_1( 3) = 1 / 96
  28. (B^Z)_1( 4) = 61 / 21600
  29. (B^Z)_1( 5) = -1 / 640
  30. (B^Z)_1( 6) = -12491 / 5080320
  31. (B^Z)_1( 7) = -479 / 580608
  32. (B^Z)_1( 8) = 530629 / 326592000
  33. (B^Z)_1( 9) = 54979 / 20736000
  34. (B^Z)_1(10) = 1039405 / 2529128448
  35. (B^Z)_1(11) = -4981183 / 1094860800
  36. (B^Z)_1(12) = -9055875786121 / 1298164008960000
  37. (B^Z)_1(13) = 908993573959 / 399435079680000
  38. (B^Z)_1(14) = 288260975797477 / 11298306539520000
  39. (B^Z)_1(15) = 7874837285353 / 231760134144000
  40. (B^Z)_1(16) = -2255621632465386299 / 48978158848819200000
  41. (B^Z)_1(17) = -189404901989770501 / 768284844687360000
  42. (B^Z)_1(18) = -20038592583515962234111 / 81541143706048266240000
  43. (B^Z)_1(19) = 954329155426992424481 / 1009797445276139520000
  44. (B^Z)_1(20) = 1731149375200514221429374109 / 467359502609929273344000000
  45. (B^Z)_1(21) = 8016281400739796361657439 / 4685308296841396224000000
  46. (B^Z)_1(22) = -1964113542866695843598946823499 / 77059691495268338368512000000
  47. (B^Z)_1(23) = -118691634224452471169536026691 / 1489076164159774654464000000
  48. (B^Z)_1(24) = 135434809276184922849073184461382701 / 4161725903949894195845529600000000
  49. (B^Z)_1(25) = 26583901529200186483827848422605931 / 28951136723129698753708032000000
  50. (B^Z)_1(26) = 2091948019281596823581094063056026741 / 921982354105822714156548096000000
  51. (B^Z)_1(27) = -17184038039286229015503662725836073 / 3902570811029937414419251200000
  52. (B^Z)_1(28) = -8419050697190151468948558716310571435121 / 194332621504510501906179686400000000
  53. (B^Z)_1(29) = -13029523224822054632420243355173393801041 / 169761830279802277527237427200000000
  54. (B^Z)_1(30) = 277675025860127837282124790366392259270502106569 / 696429859645093494977344849204740096000000