Advertisement
Guest User

Untitled

a guest
Apr 1st, 2024
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.55 KB | None | 0 0
  1. from sympy import *
  2. from collections import defaultdict
  3. from sympy.abc import n
  4.  
  5. init_printing()
  6.  
  7. dat = '''0 0 1
  8. 0 1 1
  9. 0 2 1
  10. 1 0 1
  11. 1 1 2
  12. 1 2 4
  13. 2 0 1
  14. 2 1 4
  15. 2 2 15
  16. 2 3 54
  17. 3 0 1
  18. 3 1 8
  19. 3 2 54
  20. 3 3 330
  21. 3 4 1888
  22. 3 5 10304
  23. 4 0 1
  24. 4 1 16
  25. 4 2 189
  26. 4 3 1888
  27. 4 4 16927
  28. 4 5 140626
  29. 4 6 1103671
  30. 4 7 8286710
  31. 4 8 60046325
  32. 5 0 1
  33. 5 1 32
  34. 5 2 648
  35. 5 3 10304
  36. 5 4 140626
  37. 5 5 1725320
  38. 5 6 19559448
  39. 5 7 208565440
  40. 5 8 2117507628
  41. 5 9 20649603936
  42. 5 10 194687234864
  43. 5 11 1783505249664
  44. 5 12 15937730033472
  45. 6 0 1
  46. 6 1 64
  47. 6 2 2187
  48. 6 3 54272
  49. 6 4 1103671
  50. 6 5 19559448
  51. 6 6 313163337
  52. 6 7 4635587588
  53. 6 8 64446341025
  54. 6 9 851031051676
  55. 6 10 10764130918223
  56. 6 11 131242963706420
  57. 6 12 1550284506039087
  58. 6 13 17812423417528860
  59. 6 14 199720932121738205
  60. 6 15 2191182598921033616
  61. 6 16 23575546132414375505
  62. 6 17 249227514992322651176
  63. 7 0 1
  64. 7 1 128
  65. 7 2 7290
  66. 7 3 278016
  67. 7 4 8286710
  68. 7 5 208565440
  69. 7 6 4635587588
  70. 7 7 93615162116
  71. 7 8 1751350189068
  72. 7 9 30773682154624
  73. 7 10 513102304343856
  74. 7 11 8181505666695884
  75. 7 12 125520886563885116
  76. 7 13 1861944616091620784
  77. 7 14 26810391515870135532
  78. 7 15 375959800033808382388
  79. 7 16 5148306701158385414624
  80. 7 17 69003546264747960782096
  81. 7 18 907016113659165675053712
  82. 7 19 11711948080726210482722704
  83. 7 20 148782097933699094552599552
  84. 7 21 1861813610448191131745281664
  85. 7 22 22976045459429544004938037248
  86. 7 23 279898841541629649101051142144
  87. 8 0 1
  88. 8 1 256
  89. 8 2 24057
  90. 8 3 1392640
  91. 8 4 60046325
  92. 8 5 2117507628
  93. 8 6 64446341025
  94. 8 7 1751350189068
  95. 8 8 43484996560869
  96. 8 9 1002769793880456
  97. 8 10 21737393655324605
  98. 8 11 447051449235086248
  99. 8 12 8785688231590540441
  100. 8 13 165941330019166136436
  101. 8 14 3026335875525170570561
  102. 8 15 53497189587997717739724
  103. 8 16 919577683765754911344473
  104. 8 17 15412227305493738808094444
  105. 8 18 252444018099596868815632973
  106. 8 19 4049029511226047558786744616
  107. 8 20 63704804290412577946512331473
  108. 8 21 984653784433003691108942663020
  109. 8 22 14971349841062828722563468501585
  110. 8 23 224188829660305348625670791012312
  111. 8 24 3309755357891192251564304397124069
  112. 8 25 48218309405388909504068233279542660
  113. 8 26 693787001433516022490551805234594369
  114. 8 27 9866579772326934727312762028515062568
  115. 8 28 138781162713778688975319134745135458037
  116. 8 29 1931913998414986541787014648173621019676
  117. 8 30 26630819846244266975401905368463578021721'''
  118.  
  119. data = defaultdict(list)
  120.  
  121. for l in dat.split('\n'):
  122.     m, b, v = map(int, l.split(' '))
  123.     data[m].append((b, v / Number(m+1)**b))
  124.  
  125. for m in data:
  126.     pr = interpolate(data[m], n).as_poly(n)
  127.     v, pr = primitive(pr)
  128.     pr = pr.as_expr()
  129.     print(f'G_{{{m}, n}} = ', ((m+1)**n * v) * pr, sep='')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement