2017年7月2日日曜日

170702

Ruby


Beukers' supercongruence for Apery number

アペリー数A(n) は次のように定義される。
A(n) = Sum_{k=1..n} (binomial(n,k)*binomial(n+k,k))^2.
また、
Product_{n>=1} ((1 - q^n)*(1 -q^(2*n)))^4 = A030211(0) + A030211(1) * q + ...
と展開すると、
m = 2*n + 1 が素数の時、
A(n) = a(n) mod m,
A(n) = a(n) mod m^2
が成り立つ。
例えば、
A(3) = 1445 = 3 mod 7,
A030211(3) = 24 = 3 mod 7,
A(3) = 1445 = 24 mod 7^2,
A030211(3) = 24 = 3 mod 7^2.

二つの合同式について、以下のとおり確認してみた。

require 'prime'

def A005259(n)
  i = 0
  a, b = 1, 5
  ary = [1]
  while i < n
    i += 1
    a, b = b, ((((34 * i + 51) * i + 27) * i + 5) * b - i ** 3 * a) / (i + 1) ** 3
    ary << a
  end
  ary
end

def s(k, n)
  s = 0
  (1..n).each{|i| s += i if n % i == 0 && i % k == 0}
  s
end

def A(ary, n)
  a_ary = [1]
  a = [0] + (1..n).map{|i| ary.inject(0){|s, j| s + j[1] * s(j[0], i)}}
  (1..n).each{|i| a_ary << (1..i).inject(0){|s, j| s - a[j] * a_ary[-j]} / i}
  a_ary
end

n = 300
a = Prime.take(n + 1).to_a
a.shift

ary0 = A005259(a[-1])
p ary01 = a.map{|i| ary0[(i - 1) / 2] % i}
p ary02 = a.map{|i| ary0[(i - 1) / 2] % (i * i)}

ary1 = A([[1, 4], [2, 4]], a[-1])
p ary01 == a.map{|i| ary1[(i - 1) / 2] % i}
p ary02 == a.map{|i| ary1[(i - 1) / 2] % (i * i)}

出力結果
[2, 3, 3, 0, 9, 16, 6, 13, 24, 26, 23, 7, 9, 11, 23, 40, 1, 54, 18, 8, 55, 70, 2, 7, 51, 62, 76, 77, 75, 11, 59, 119, 11, 4, 144, 2, 102, 70, 115, 41, 116, 186, 180, 101, 88, 111, 36, 156, 198, 30, 182, 239, 119, 256, 227, 165, 223, 65, 247, 97, 233, 89, 298, 276, 222, 192, 28, 162, 109, 66, 53, 147, 9, 59, 27, 272, 350, 99, 88, 35, 410, 225, 397, 276, 121, 3, 191, 440, 344, 398, 127, 408, 485, 442, 392, 280, 29, 319, 198, 48, 245, 389, 190, 438, 154, 549, 394, 233, 68, 602, 535, 538, 473, 261, 505, 82, 283, 421, 119, 478, 258, 125, 603, 674, 209, 532, 87, 409, 343, 88, 366, 424, 623, 303, 12, 335, 81, 598, 284, 95, 271, 791, 772, 464, 765, 708, 22, 271, 330, 153, 154, 217, 88, 889, 452, 190, 730, 173, 377, 884, 464, 226, 824, 207, 757, 60, 399, 1008, 18, 978, 472, 684, 752, 808, 997, 584, 677, 25, 998, 704, 16, 346, 442, 845, 784, 20, 403, 179, 432, 934, 62, 575, 882, 106, 109, 641, 632, 471, 258, 82, 98, 805, 1234, 409, 66, 449, 1191, 442, 1073, 204, 334, 56, 447, 815, 1142, 1307, 103, 387, 757, 1127, 283, 418, 85, 1110, 1239, 1065, 383, 1417, 512, 1054, 1334, 953, 748, 596, 1226, 1127, 742, 1067, 1384, 634, 39, 1153, 1194, 839, 209, 927, 175, 924, 1070, 635, 462, 44, 948, 102, 886, 110, 997, 232, 377, 1075, 1224, 1566, 1231, 574, 495, 1319, 1716, 713, 1632, 1626, 704, 1505, 1076, 254, 1173, 1724, 1409, 465, 1069, 307, 340, 14, 1777, 1051, 1181, 1432, 885, 258, 1869, 1740, 1278, 900, 1795, 1431, 954, 1397, 1305, 1377, 353, 382]
[5, 23, 24, 77, 22, 50, 44, 473, 198, 801, 1207, 1483, 52, 528, 2567, 2813, 550, 188, 728, 154, 5585, 236, 714, 8931, 1566, 9641, 10669, 9887, 11827, 1408, 14469, 1626, 18637, 302, 1352, 3142, 3036, 27625, 27103, 3084, 30343, 35521, 2882, 1086, 88, 41045, 928, 156, 50807, 53387, 1616, 4818, 60861, 770, 61769, 69567, 8624, 74855, 3338, 7172, 5214, 396, 92665, 2154, 93103, 108429, 110227, 2244, 115279, 113379, 1848, 7120, 6350, 135741, 10368, 8830, 9878, 147667, 906, 170149, 172599, 656, 9490, 5544, 7652, 201155, 1562, 10582, 203601, 208213, 229089, 221993, 232237, 19404, 16488, 246127, 10970, 256589, 198, 283941, 20854, 297653, 7018, 24420, 23234, 333965, 337811, 354841, 355259, 365409, 373239, 361483, 10996, 391481, 6274, 9084, 394953, 419647, 15276, 11054, 431651, 8926, 8116, 465717, 486703, 24638, 16624, 30216, 533967, 531429, 28600, 534385, 2894, 14762, 583683, 27390, 19756, 38854, 640203, 657005, 650503, 670713, 27236, 12070, 661897, 2414, 696763, 40644, 726113, 756127, 49490, 1100, 772665, 809933, 790289, 5704, 8162, 822859, 16374, 8460, 887707, 898569, 20244, 50034, 37128, 27808, 965495, 3026, 973511, 996541, 39270, 54296, 27610, 1072017, 1081467, 1092573, 5982, 9592, 1092447, 704, 1159749, 22206, 1168747, 1196497, 1201831, 29062, 39708, 53242, 55680, 1288835, 2388, 1370645, 1362575, 1378213, 6074, 1405811, 1401647, 52802, 1488649, 24662, 22256, 46574, 1501283, 1526317, 1615471, 1555713, 1574149, 41690, 1596749, 7986, 1651303, 1677017, 40964, 20600, 48698, 37136, 36850, 4488, 1804879, 1879287, 1905721, 1940611, 2009361, 26796, 85550, 13962, 2069665, 2085097, 41140, 82422, 2062901, 84800, 2096363, 95508, 2203473, 41330, 2193959, 41540, 73912, 2280565, 2305725, 2358857, 44566, 92466, 51656, 49504, 2441509, 2405741, 2402481, 11814, 2544451, 2563209, 2470763, 77526, 2599381, 110, 2565149, 2676727, 2734427, 85888, 101244, 2733719, 60486, 61666, 80348, 2886111, 2918811, 57572, 122942, 2997887, 63596, 31306, 36256, 35794, 10088, 101796, 17510, 2266, 3231893, 93280, 110200, 3274745, 3422295, 3387789, 115312, 110066, 40302, 3489561, 3549411, 3528095, 3626485, 165418, 38484, 3604543, 3791759, 3661473, 3769735, 3840637, 18236, 3836907]
true
true

0 件のコメント:

コメントを投稿

注: コメントを投稿できるのは、このブログのメンバーだけです。