2017年6月25日日曜日

170625

A195264

2 prime,
3 prime,
4 = 2^2 -> 22 = 2 * 11 -> 211 prime,
5 prime,
6 = 2 * 3 -> 23 prime,
7 prime,
8 = 2^3 -> 23 prime,
9 = 3^2 -> 32 = 2^5 -> 25 = 5^2 -> 52 = 2^2 * 13 -> 2213 prime,
...
19 prime,
(20 は挑戦しない方がいいでしょう。)
21 = 3 * 7 -> 37 prime,
...
しかし
13532385396179 = 13 * 53^2 * 3853 * 96179 -> 13532385396179 = 13 * 53^2 * 3853 * 96179 -> ...
となってしまう。

2017年6月24日土曜日

170624

Ruby


Borcherds Products(1)

R. E. Borcherds, Automorphic forms on O_{s+2,2}(R)^{+} and generalized Kac-Moody algebras
に載っている
1 - 504*q - 16632*q^2 - 122976*q^3 - ...
= (1 - q)^504 * (1 - q^2)^143388 * (1 - q^3)^51180024 * ...
を両辺log をとることで確認してみた。
他にE_2, E_4, E_8, E_12 の場合も確認してみた。

require 'prime'

def power0(a, n)
  return 1 if n == 0
  k = power0(a, n >> 1)
  k *= k
  return k if n & 1 == 0
  return k * a
end

# x > 0
def sigma(x, i)
  sum = 1
  pq = i.prime_division
  pq.each{|a, n| sum *= (power0(a, (n + 1) * x) - 1) / (power0(a, x) - 1)}
  sum
end

def bernoulli(n)
  ary = []
  a = []
  (0..n).each{|i|
    a << 1r / (i + 1)
    i.downto(1){|j| a[j - 1] = j * (a[j - 1] - a[j])}
    ary << a[0] # Bn = a[0]
  }
  ary
end

def E0_2k(k, n)
  a = -4 * k / bernoulli(2 * k)[-1]
  [1] + (1..n).map{|i| a * sigma(2 * k - 1, i)}
end

# m次以下を取り出す
def mul(f_ary, b_ary, m)
  s1, s2 = f_ary.size, b_ary.size
  ary = Array.new(s1 + s2 - 1, 0)
  (0..s1 - 1).each{|i|
    (0..s2 - 1).each{|j|
      ary[i + j] += f_ary[i] * b_ary[j]
    }
  }
  ary[0..m]
end

def S(c_ary, x_ary, n)
  ary = Array.new(n + 1, 0)
  tq = x_ary
  tqn = [1] + Array.new(n, 0)
  (0..c_ary.size - 1).each{|i|
    (0..n).each{|j|
      ary[j] += c_ary[i] * tqn[j]
    }
    tqn = mul(tqn, tq, n)
  }
  ary
end

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

def A008683(n)
  ary = n.prime_division
  return (-1) ** (ary.size % 2) if ary.all?{|i| i[1] == 1}
  0
end

def A(k, m, n)
  a = I(E0_2k(k, n), n)
  b = E0_2k(k + 1, n)
  # E_{2k+2}/E_{2k}を出力
  p c = mul(a, b, n)
  m_ary = [0] + (1..n).map{|i| A008683(i)}
  ary = []
  (1..n).each{|i|
    s = 0
    (1..i).each{|j|
      s += m_ary[i / j] * c[j] if i % j == 0
    }
    ary << m + m * s / (24 * i)
  }
  ary
end

# c_ary は1次から
def T(c_ary, n)
  ary = Array.new(n + 1, 0)
  tq = [0] + (1..n).map{|i| -1r / i}
  (1..c_ary.size).each{|i|
    tqn = Array.new(n + 1, 0)
    (0..n / i).each{|j| tqn[i * j] = tq[j]}
    (0..n).each{|j|
      ary[j] += c_ary[i - 1] * tqn[j]
    }
  }
  ary
end

# 二通りで求め、一致することを確認
def f(k, m, n)
  p 2 * k
  x_ary = E0_2k(k, n)
  x_ary[0] = 0
  p s_ary = S(@c_ary, x_ary, n)
  p t_ary = T(A(k, m, n), n)
  p s_ary == t_ary
end

n = 10
@c_ary = [0] + (1..n).map{|i| (-1) ** (i % 2 + 1) * 1r / i}
f(1, 2, n)
f(2, 8, n)
f(3, 12, n)
f(4, 16, n)
f(6, 24, n)

出力結果
2
[(0/1), (-24/1), (-360/1), (-6432/1), (-129480/1), (-13893264/5), (-62117856/1), (-9998360256/7), (-33527414664/1), (-799482199416/1), (-19302455707056/1)]
[1, (264/1), (8568/1), (231456/1), (6214872/1), (166719024/1), (4472485344/1), (119980322880/1), (3218631807384/1), (86344077536616/1), (2316294684846288/1)]
[(0/1), (-24/1), (-360/1), (-6432/1), (-129480/1), (-13893264/5), (-62117856/1), (-9998360256/7), (-33527414664/1), (-799482199416/1), (-19302455707056/1)]
true
4
[(0/1), (240/1), (-26640/1), (4096320/1), (-708952080/1), (130880766240/1), (-25168871459520/1), (34848505552897920/7), (-1005225129672310800/1), (206195878414964053680/1), (-42824436295980177980640/1)]
[1, (-744/1), (159768/1), (-36866976/1), (8507424792/1), (-1963211493744/1), (453039686271072/1), (-104545516658693952/1), (24125403112135458840/1), (-5567288717204029449672/1), (1284733088879405339418768/1)]
[(0/1), (240/1), (-26640/1), (4096320/1), (-708952080/1), (130880766240/1), (-25168871459520/1), (34848505552897920/7), (-1005225129672310800/1), (206195878414964053680/1), (-42824436295980177980640/1)]
true
6
[(0/1), (-504/1), (-143640/1), (-51180192/1), (-20556650520/1), (-44031499226064/5), (-3929750687018016/1), (-1803727445909594688/1), (-845145871858011095064/1), (-402283166289266889884376/1), (-193877350835491674934518096/1)]
[1, (984/1), (574488/1), (307081056/1), (164453203992/1), (88062998451984/1), (47157008244215904/1), (25252184242734325440/1), (13522333949728177520664/1), (7241096993206804017918456/1), (3877547016709833498690361488/1)]
[(0/1), (-504/1), (-143640/1), (-51180192/1), (-20556650520/1), (-44031499226064/5), (-3929750687018016/1), (-1803727445909594688/1), (-845145871858011095064/1), (-402283166289266889884376/1), (-193877350835491674934518096/1)]
true
8
[(0/1), (480/1), (-53280/1), (8192640/1), (-1417904160/1), (261761532480/1), (-50337742919040/1), (69697011105795840/7), (-2010450259344621600/1), (412391756829928107360/1), (-85648872591960355961280/1)]
[1, (-744/1), (159768/1), (-36866976/1), (8507424792/1), (-1963211493744/1), (453039686271072/1), (-104545516658693952/1), (24125403112135458840/1), (-5567288717204029449672/1), (1284733088879405339418768/1)]
[(0/1), (480/1), (-53280/1), (8192640/1), (-1417904160/1), (261761532480/1), (-50337742919040/1), (69697011105795840/7), (-2010450259344621600/1), (412391756829928107360/1), (-85648872591960355961280/1)]
true
12
[(0/1), (65520/691), (90620646480/477481), (-442346531739840/329939371), (-4181632252548250958640/227988105361), (42458488606933509112722720/157539780804451), (254774946968486556568732840559040/108859988535875641), (-3880639008647134201555086919223041920/75222252078290067931), (-17460929864122236834882554512696144803620400/51978576186098436940321), (354829247093611920019527363838479842967750379440/35917196144594019925761811), (1276094183659938234585318200922032531674640614094890080/24818782535914467768701411401)]
[1, (-82104/691), (-181275671592/477481), (1327007921039904/329939371), (16726528971891002133912/227988105361), (-212292443057353273999454544/157539780804451), (-1528649681810950691089095375538848/108859988535875641), (27164473060529924968213209402868250688/75222252078290067931), (139687438912977894660348148674573721130447640/51978576186098436940321), (-3193463223842507280186952439743431920926591099992/35917196144594019925761811), (-12760941836599382345853192730934380831796482219958626032/24818782535914467768701411401)]
[(0/1), (65520/691), (90620646480/477481), (-442346531739840/329939371), (-4181632252548250958640/227988105361), (42458488606933509112722720/157539780804451), (254774946968486556568732840559040/108859988535875641), (-3880639008647134201555086919223041920/75222252078290067931), (-17460929864122236834882554512696144803620400/51978576186098436940321), (354829247093611920019527363838479842967750379440/35917196144594019925761811), (1276094183659938234585318200922032531674640614094890080/24818782535914467768701411401)]
true

2017年6月15日木曜日

170615

Ruby


Wolstenholme's theorem

1 + 1/2 + ... + 1/(p - 1) ≡ 0 mod p^2,
1 + 1/2^2 + ... + 1/(p - 1)^2 ≡ 0 mod p
を次の方法で確認してみた。

1 + 1/2 + 1/3 + 1/4 ≡ 1 + 13 + 17 + 19 ≡ 50 ≡ 0 mod 5^2,
1 + 1/2^2 + 1/3^2 + 1/4^2 ≡ 1 + 4 + 4 + 1 ≡ 10 ≡ 0 mod 5.

require 'prime'

def f(m, n)
  (0..m - 1).each{|i|
    return i if (i * n - 1) % m == 0
  }
end

n = 50
Prime.each(n){|pr|
  q = pr * pr
  a = []
  (1..pr - 1).each{|i|
    a << f(q, i)
  }
  j = a.inject(:+)
  p [a, j, j % q]
}

Prime.each(n){|pr|
  a = []
  (1..pr - 1).each{|i|
    a << f(pr, i * i)
  }
  j = a.inject(:+)
  p [a, j, j % pr]
}

出力結果
[[1], 1, 1]
[[1, 5], 6, 6]
[[1, 13, 17, 19], 50, 0]
[[1, 25, 33, 37, 10, 41], 147, 0]
[[1, 61, 81, 91, 97, 101, 52, 106, 27, 109], 726, 0]
[[1, 85, 113, 127, 34, 141, 145, 148, 94, 17, 123, 155], 1183, 0]
[[1, 145, 193, 217, 58, 241, 124, 253, 257, 29, 184, 265, 89, 62, 212, 271], 2601, 0]
[[1, 181, 241, 271, 289, 301, 258, 316, 321, 325, 197, 331, 250, 129, 337, 158, 85, 341], 4332, 0]
[[1, 265, 353, 397, 106, 441, 378, 463, 294, 53, 481, 485, 407, 189, 388, 496, 249, 147, 362, 291, 126, 505], 6877, 0]
[[1, 421, 561, 631, 673, 701, 721, 736, 187, 757, 153, 771, 647, 781, 785, 368, 99, 514, 664, 799, 801, 497, 256, 806, 471, 744, 623, 811], 15979, 0]
[[1, 481, 641, 721, 769, 801, 412, 841, 534, 865, 699, 881, 74, 206, 897, 901, 848, 267, 607, 913, 778, 830, 585, 921, 346, 37, 178, 103, 232, 929], 17298, 0]
[[1, 685, 913, 1027, 274, 1141, 978, 1198, 1217, 137, 249, 1255, 316, 489, 1004, 599, 1208, 1293, 1297, 753, 326, 809, 1250, 1312, 1150, 158, 862, 929, 1133, 502, 265, 984, 83, 604, 1017, 1331], 28749, 0]
[[1, 841, 1121, 1261, 1345, 1401, 1441, 1471, 934, 1513, 917, 1541, 388, 1561, 1569, 1576, 890, 467, 177, 1597, 1601, 1299, 804, 1611, 269, 194, 1432, 1621, 58, 1625, 1193, 788, 866, 445, 1633, 1074, 1363, 929, 1250, 1639], 43706, 0]
[[1, 925, 1233, 1387, 370, 1541, 1585, 1618, 411, 185, 1681, 1695, 569, 1717, 1356, 809, 1414, 1130, 292, 1017, 1761, 1765, 402, 1772, 74, 1209, 137, 1783, 1594, 678, 1014, 1329, 1793, 707, 317, 565, 50, 146, 806, 1433, 451, 1805], 42527, 0]
[[1, 1105, 1473, 1657, 442, 1841, 1578, 1933, 491, 221, 1205, 2025, 170, 789, 1620, 2071, 130, 1350, 1744, 1215, 526, 1707, 2113, 2117, 972, 85, 900, 1499, 1752, 810, 1924, 2140, 1138, 65, 1641, 675, 1612, 872, 793, 1712, 1778, 263, 411, 1958, 540, 2161], 55225, 0]
[[1], 1, 1]
[[1, 1], 2, 2]
[[1, 4, 4, 1], 10, 0]
[[1, 2, 4, 4, 2, 1], 14, 0]
[[1, 3, 5, 9, 4, 4, 9, 5, 3, 1], 44, 0]
[[1, 10, 3, 9, 12, 4, 4, 12, 9, 3, 10, 1], 78, 0]
[[1, 13, 2, 16, 15, 9, 8, 4, 4, 8, 9, 15, 16, 2, 13, 1], 136, 0]
[[1, 5, 17, 6, 16, 9, 7, 11, 4, 4, 11, 7, 9, 16, 6, 17, 5, 1], 152, 0]
[[1, 6, 18, 13, 12, 16, 8, 9, 2, 3, 4, 4, 3, 2, 9, 8, 16, 12, 13, 18, 6, 1], 184, 0]
[[1, 22, 13, 20, 7, 25, 16, 5, 24, 9, 6, 28, 23, 4, 4, 23, 28, 6, 9, 24, 5, 16, 25, 7, 20, 13, 22, 1], 406, 0]
[[1, 8, 7, 2, 5, 25, 19, 16, 18, 9, 10, 14, 20, 28, 4, 4, 28, 20, 14, 10, 9, 18, 16, 19, 25, 5, 2, 7, 8, 1], 372, 0]
[[1, 28, 33, 7, 3, 36, 34, 11, 16, 10, 26, 9, 30, 27, 25, 12, 21, 4, 4, 21, 12, 25, 27, 30, 9, 26, 10, 16, 11, 34, 36, 3, 7, 33, 28, 1], 666, 0]
[[1, 31, 32, 18, 23, 8, 36, 25, 40, 16, 20, 2, 33, 9, 39, 37, 21, 10, 5, 4, 4, 5, 10, 21, 37, 39, 9, 33, 2, 20, 16, 40, 25, 36, 8, 23, 18, 32, 31, 1], 820, 0]
[[1, 11, 24, 35, 31, 6, 36, 41, 17, 40, 16, 23, 14, 9, 13, 21, 25, 15, 38, 10, 4, 4, 10, 38, 15, 25, 21, 13, 9, 14, 23, 16, 40, 17, 41, 36, 6, 31, 35, 24, 11, 1], 860, 0]
[[1, 12, 21, 3, 32, 17, 24, 36, 18, 8, 7, 16, 42, 6, 14, 9, 27, 28, 25, 2, 34, 37, 4, 4, 37, 34, 2, 25, 28, 27, 9, 14, 6, 42, 16, 7, 8, 18, 36, 24, 17, 32, 3, 21, 12, 1], 846, 0]

2017年6月12日月曜日

170612(2)

Ruby


The Irrationality of ζ(3)

Apery がζ(3) の無理数性を示すのに用いた
{a_n} = {1, 5, 73, 1445, ... }

{b_n} = {0, 6, 351/4, 62531/36, ... }
について以下の性質がある。

まず、f とg を次のように定める。
f(q) = 5*E_2(q) - 2*E_2(q^2) + 3*E_2(q^3) - 30*E_2(q^6).
E_4(q) - 28*E_4(q^2) + 63*E_4(q^3) - 36*E_4(q^6) = Sum_{n >= 1} c_n * q^n と展開し、
g(q) = Sum_{n >= 1} c_n /n^3 * q^n.

ここで、
t(q) = (eta(q)*eta(q^6)/(eta(q^2)*eta(q^3))^12
を準備すると、
f(q) = Sum_{n>=0} a_n * t(q)^n,
6*f(q)*g(q) = Sum_{n>=0} b_n * t(q)^n.

このことを確認してみた。

# m次以下を取り出す
def mul(f_ary, b_ary, m)
  s1, s2 = f_ary.size, b_ary.size
  ary = Array.new(s1 + s2 - 1, 0)
  (0..s1 - 1).each{|i|
    (0..s2 - 1).each{|j|
      ary[i + j] += f_ary[i] * b_ary[j]
    }
  }
  ary[0..m]
end

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

def A006353(n)
  a = [0] + (1..n).map{|i| A000203(i)}
  ary = [1]
  (1..n).each{|i|
    ary[i] = 5 * a[i]
    ary[i] -=  2 * a[i / 2] if i % 2 == 0
    ary[i] +=  3 * a[i / 3] if i % 3 == 0
    ary[i] -= 30 * a[i / 6] if i % 6 == 0
  }
  ary
end

def Apery(a, b, n)
  i = 0
  ary = [a]
  while i < n
    i += 1
    a, b = b, ((((34 * i + 51) * i + 27) * i + 5) * b - i ** 3 * a) / (i + 1r) ** 3
    a = a.to_i if a.denominator == 1
    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

def f(n)
  [0] + A([[1, 12], [6, 12], [2, -12], [3, -12]], n)[0..-2]
end

def S(c_ary, x_ary, n)
  ary = Array.new(n + 1, 0)
  tq = x_ary
  tqn = [1] + Array.new(n, 0)
  (0..c_ary.size - 1).each{|i|
    (0..n).each{|j|
      ary[j] += c_ary[i] * tqn[j]
    }
    # 計算の途中経過を表示
    p [c_ary[i], (0..8).map{|j| tqn[j]}] if i < 9
    tqn = mul(tqn, tq, n)
  }
  ary
end

def A001158(n)
  s = 0
  (1..n).each{|i| s += i * i * i if n % i == 0}
  s
end

def g(n)
  a = [0] + (1..n).map{|i| A001158(i)}
  ary = a.clone
  (1..n).each{|i|
    ary[i] -= 28 * a[i / 2] if i % 2 == 0
    ary[i] += 63 * a[i / 3] if i % 3 == 0
    ary[i] -= 36 * a[i / 6] if i % 6 == 0
  }
  [0] + (1..n).map{|i| ary[i] / (i ** 3).to_r}
end

n = 20
x_ary = f(n)
p a = A006353(n)
p ary1 = S(Apery(1, 5, n), x_ary, n)
p a == ary1

p b = g(n)
# 6*f(q)*g(q)
p c = mul(a, b, n).map{|i| i * 6}
p ary2 = S(Apery(0, 6, n), x_ary, n)
p c == ary2

出力結果
[1, 5, 13, 23, 29, 30, 31, 40, 61, 77, 78, 60, 47, 70, 104, 138, 125, 90, 85, 100, 174]
[1, [1, 0, 0, 0, 0, 0, 0, 0, 0]]
[5, [0, 1, -12, 66, -220, 495, -804, 1068, -1596]]
[73, [0, 0, 1, -24, 276, -2024, 10626, -42528, 135172]]
[1445, [0, 0, 0, 1, -36, 630, -7140, 58905, -377028]]
[33001, [0, 0, 0, 0, 1, -48, 1128, -17296, 194580]]
[819005, [0, 0, 0, 0, 0, 1, -60, 1770, -34220]]
[21460825, [0, 0, 0, 0, 0, 0, 1, -72, 2556]]
[584307365, [0, 0, 0, 0, 0, 0, 0, 1, -84]]
[16367912425, [0, 0, 0, 0, 0, 0, 0, 0, 1]]
[1, 5, 13, 23, 29, 30, 31, 40, 61, 77, 78, 60, 47, 70, 104, 138, 125, 90, 85, 100, 174]
true
[0, (1/1), (-19/8), (91/27), (-179/64), (126/125), (-1/216), (344/343), (-1459/512), (2521/729), (-1197/500), (1332/1331), (-737/1728), (2198/2197), (-817/343), (1274/375), (-11699/4096), (4914/4913), (485/5832), (6860/6859), (-11277/4000)]
[0, (6/1), (63/4), (971/36), (10679/288), (1126103/36000), (105401/2400), (536870027/12348000), (6914199661/98784000), (287234243731/2667168000), (180215848643/2667168000), (372368618068019/3550000608000), (91108455284929/3550000608000), (375230372846413103/3899675667888000), (11572107009689143/74279536531200), (362633909676097/4687110177750), (17569994567535455953/62394810686208000), (-6580051272057008432923/306545704901339904000), (18203831262802264966759/102181901633779968000), (11825963366918039995022749/84103879596731616061440), (11558953346115895446260749/191145180901662763776000)]
[0, [1, 0, 0, 0, 0, 0, 0, 0, 0]]
[6, [0, 1, -12, 66, -220, 495, -804, 1068, -1596]]
[(351/4), [0, 0, 1, -24, 276, -2024, 10626, -42528, 135172]]
[(62531/36), [0, 0, 0, 1, -36, 630, -7140, 58905, -377028]]
[(11424695/288), [0, 0, 0, 0, 1, -48, 1128, -17296, 194580]]
[(35441662103/36000), [0, 0, 0, 0, 0, 1, -60, 1770, -34220]]
[(20637706271/800), [0, 0, 0, 0, 0, 0, 1, -72, 2556]]
[(963652602684713/1372000), [0, 0, 0, 0, 0, 0, 0, 1, -84]]
[(43190915887542721/2195200), [0, 0, 0, 0, 0, 0, 0, 0, 1]]
[(0/1), (6/1), (63/4), (971/36), (10679/288), (1126103/36000), (105401/2400), (536870027/12348000), (6914199661/98784000), (287234243731/2667168000), (180215848643/2667168000), (372368618068019/3550000608000), (91108455284929/3550000608000), (375230372846413103/3899675667888000), (11572107009689143/74279536531200), (362633909676097/4687110177750), (17569994567535455953/62394810686208000), (-6580051272057008432923/306545704901339904000), (18203831262802264966759/102181901633779968000), (11825963366918039995022749/84103879596731616061440), (11558953346115895446260749/191145180901662763776000)]
true

170612

Ruby


n の4*k+1 乗

一の位は変わらない。

1.step(50, 4){|i|
  (0..19).each{|j|
    str = (j ** i).to_s
    p [i, str[0..-2] + ' ' + str[-1]]
  }
  p ''
}

出力結果
[1, " 0"]
[1, " 1"]
[1, " 2"]
[1, " 3"]
[1, " 4"]
[1, " 5"]
[1, " 6"]
[1, " 7"]
[1, " 8"]
[1, " 9"]
[1, "1 0"]
[1, "1 1"]
[1, "1 2"]
[1, "1 3"]
[1, "1 4"]
[1, "1 5"]
[1, "1 6"]
[1, "1 7"]
[1, "1 8"]
[1, "1 9"]
""
[5, " 0"]
[5, " 1"]
[5, "3 2"]
[5, "24 3"]
[5, "102 4"]
[5, "312 5"]
[5, "777 6"]
[5, "1680 7"]
[5, "3276 8"]
[5, "5904 9"]
[5, "10000 0"]
[5, "16105 1"]
[5, "24883 2"]
[5, "37129 3"]
[5, "53782 4"]
[5, "75937 5"]
[5, "104857 6"]
[5, "141985 7"]
[5, "188956 8"]
[5, "247609 9"]
""
[9, " 0"]
[9, " 1"]
[9, "51 2"]
[9, "1968 3"]
[9, "26214 4"]
[9, "195312 5"]
[9, "1007769 6"]
[9, "4035360 7"]
[9, "13421772 8"]
[9, "38742048 9"]
[9, "100000000 0"]
[9, "235794769 1"]
[9, "515978035 2"]
[9, "1060449937 3"]
[9, "2066104678 4"]
[9, "3844335937 5"]
[9, "6871947673 6"]
[9, "11858787649 7"]
[9, "19835929036 8"]
[9, "32268769777 9"]
""
[13, " 0"]
[13, " 1"]
[13, "819 2"]
[13, "159432 3"]
[13, "6710886 4"]
[13, "122070312 5"]
[13, "1306069401 6"]
[13, "9688901040 7"]
[13, "54975581388 8"]
[13, "254186582832 9"]
[13, "1000000000000 0"]
[13, "3452271214393 1"]
[13, "10699320537907 2"]
[13, "30287510659225 3"]
[13, "79371477325414 4"]
[13, "194619506835937 5"]
[13, "450359962737049 6"]
[13, "990457803290593 7"]
[13, "2082296486567116 8"]
[13, "4205298346225705 9"]
""
[17, " 0"]
[17, " 1"]
[17, "13107 2"]
[17, "12914016 3"]
[17, "1717986918 4"]
[17, "76293945312 5"]
[17, "1692665944473 6"]
[17, "23263051398720 7"]
[17, "225179981368524 8"]
[17, "1667718169966656 9"]
[17, "10000000000000000 0"]
[17, "50544702849929377 1"]
[17, "221861110674043699 2"]
[17, "865041591938133793 3"]
[17, "3049134672933119590 4"]
[17, "9852612533569335937 5"]
[17, "29514790517935282585 6"]
[17, "82724026188633676417 7"]
[17, "218591155973869653196 8"]
[17, "548038685778480218593 9"]
""
[21, " 0"]
[21, " 1"]
[21, "209715 2"]
[21, "1046035320 3"]
[21, "439804651110 4"]
[21, "47683715820312 5"]
[21, "2193695064037785 6"]
[21, "55854586408328400 7"]
[21, "922337203685477580 8"]
[21, "10941898913151235920 9"]
[21, "100000000000000000000 0"]
[21, "740024994425816010121 1"]
[21, "4600511990936970146611 2"]
[21, "24706452907345039270441 3"]
[21, "117135557595398722184806 4"]
[21, "498788509511947631835937 5"]
[21, "1934281311383406679529881 6"]
[21, "6909193391300873288082721 7"]
[21, "22946825189512940713987276 8"]
[21, "71420949569337320567375641 9"]
""
[25, " 0"]
[25, " 1"]
[25, "3355443 2"]
[25, "84728860944 3"]
[25, "112589990684262 4"]
[25, "29802322387695312 5"]
[25, "2843028802992970137 6"]
[25, "134106861966396490080 7"]
[25, "3777893186295716170956 8"]
[25, "71789798769185258877024 9"]
[25, "1000000000000000000000000 0"]
[25, "10834705943388372204183025 1"]
[25, "95396216644069012960129843 2"]
[25, "705641001486681666603073969 3"]
[25, "4499879580584837311451522662 4"]
[25, "25251168294042348861694335937 5"]
[25, "126765060022822940149670320537 6"]
[25, "577062741234840237893956999105 7"]
[25, "2408865921094310464391528369356 8"]
[25, "9307649568825608953660961028049 9"]
""
[29, " 0"]
[29, " 1"]
[29, "53687091 2"]
[29, "6863037736488 3"]
[29, "28823037615171174 4"]
[29, "18626451492309570312 5"]
[29, "3684565328678889298329 6"]
[29, "321990575581317972683760 7"]
[29, "15474250491067253436239052 8"]
[29, "471012869724624483492160368 9"]
[29, "10000000000000000000000000000 0"]
[29, "158630929717149157441443670489 1"]
[29, "1978135948331415052741252428595 2"]
[29, "20153812643461115079850395637177 3"]
[29, "172867373967747110156721694598758 4"]
[29, "1278340394885893911123275756835937 5"]
[29, "8307674973655724205648794126752153 6"]
[29, "48196857210675091509141182522307169 7"]
[29, "252873108932796335309965082101599436 8"]
[29, "1212982199458922184450050102136491017 9"]
""
[33, " 0"]
[33, " 1"]
[33, "858993459 2"]
[33, "555906056655552 3"]
[33, "7378697629483820646 4"]
[33, "11641532182693481445312 5"]
[33, "4775196665967840530635161 6"]
[33, "773099371970744452413709440 7"]
[33, "63382530011411470074835160268 8"]
[33, "3090315438263261236192064180352 9"]
[33, "100000000000000000000000000000000 0"]
[33, "2322515441988780814100176779630913 1"]
[33, "41018627024600222533642610359350067 2"]
[33, "575613042909892907795607149793420865 3"]
[33, "6640873038344972983780620619705902694 4"]
[33, "64715982491098379250615835189819335937 5"]
[33, "544451787073501541541399371890829138329 6"]
[33, "4025449711092794317934980705445617120513 7"]
[33, "26545607483329228095498894458697502477516 8"]
[33, "158077053215686197999714979360529645943745 9"]
""
[37, " 0"]
[37, " 1"]
[37, "13743895347 2"]
[37, "45028390589099736 3"]
[37, "1888946593147858085478 4"]
[37, "7275957614183425903320312 5"]
[37, "6188654879094321327703169433 6"]
[37, "1856211592101757430245316367120 7"]
[37, "259614842926741381426524816461004 8"]
[37, "20275559590445256970656133087295376 9"]
[37, "1000000000000000000000000000000000000 0"]
[37, "34003948586157739899240688230576198697 1"]
[37, "850562249982110214457613168411482993459 2"]
[37, "16440084118549451339550335805249893333833 3"]
[37, "255115778641060482144916321726621957908070 4"]
[37, "3276246613611855449562426656484603881835937 5"]
[37, "35681192317648997026457149236237378409568665 6"]
[37, "336209585320181274228247523499523387522424737 7"]
[37, "2786651691169969048553091944696229020079803596 8"]
[37, "20600759652121441009520855825243583989034909433 9"]
""
[41, " 0"]
[41, " 1"]
[41, "219902325555 2"]
[41, "3647299637717078640 3"]
[41, "483570327845851669882470 4"]
[41, "4547473508864641189575195312 5"]
[41, "8020496723306240440703307585945 6"]
[41, "4456764032636319590019004597456800 7"]
[41, "1063382396627932698323045648224275660 8"]
[41, "133027946472911330984474889185744967840 9"]
[41, "10000000000000000000000000000000000000000 0"]
[41, "497851811249935469864782916383866125124241 1"]
[41, "17637258815629037406993066660180511352369971 2"]
[41, "469545242509890879708897140933742203507612881 3"]
[41, "9800527752274979482079105415449909134996432486 4"]
[41, "165859984814100182134097849484533071517944335937 5"]
[41, "2338402619729444669125895732346052831449492068761 6"]
[41, "28080560775526860204817461410203692849260436517441 7"]
[41, "292531547932258670840909379986431337611897462377676 8"]
[41, "2684711598624118313801767452001569109035018432335281 9"]
""
[45, " 0"]
[45, " 1"]
[45, "3518437208883 2"]
[45, "295431270655083369864 3"]
[45, "123794003928538027489912422 4"]
[45, "2842170943040400743484497070312 5"]
[45, "10394563753404887611151486631385497 6"]
[45, "10700690442359803335635630038493778480 7"]
[45, "4355614296588012332331194975126633106636 8"]
[45, "872796356808771242589139747947672734004144 9"]
[45, "100000000000000000000000000000000000000000000 0"]
[45, "7289048368510305214290286678776183937944013945 1"]
[45, "365726198800883719671408230265503083402743722803 2"]
[45, "13410681671324993415365811242208611074380931502809 3"]
[45, "376497074131395611783550913639923709330022950397542 4"]
[45, "8396661731213821720538703630154486745595932006835937 5"]
[45, "153249554086588885835834702715030918361873912218360217 6"]
[45, "2345316516532778891166559194441622630463080918373248225 7"]
[45, "30708791775736786230195303073455616097146548010558999756 8"]
[45, "349874300244293722772960136112296487858552637120366272489 9"]
""
[49, " 0"]
[49, " 1"]
[49, "56294995342131 2"]
[49, "23929932923061752959008 3"]
[49, "31691265005705735037417580134 4"]
[49, "1776356839400250464677810668945312 5"]
[49, "13471354624412734344052326674275604889 6"]
[49, "25692357752105887808861147722423562132160 7"]
[49, "17840596158824498513228574618118689204784332 8"]
[49, "5726416897022348122627345886284680807801194688 9"]
[49, "1000000000000000000000000000000000000000000000000 0"]
[49, "106718957163359378642424087263962109035438308170209 1"]
[49, "7583698458335124811106321062785471937439293836047155 2"]
[49, "383022479214713136936262934888720140895393784651736417 3"]
[49, "14463511599831693822276891898391309217622161662471988838 4"]
[49, "425081000142699724602271871276570891495794057846069335937 5"]
[49, "10043362776618689222137263077132266265763768711142455220633 6"]
[49, "195883180777334225769122190478958763718906981383452065058689 7"]
[49, "3223686125449744871300982135439076755414056023956441558469836 8"]
[49, "45595968682136602245494937898290590594214438222163252997156257 9"]
""

2017年6月9日金曜日

170609(2)

Ruby


The Kac-Wakimoto Conjecture(2)

The 1-2-3 of Modular Forms に
載っていない方は、書籍ではなく論文から
探してきた。

def A24(n)
  m = n + 3
  s = 0
  (1..m).each{|b|
    (b + 1..m).each{|a|
      1.step(m, 2){|x|
        1.step(m, 2){|y|
          s += (a * b) ** 3 * (a * a - b * b) ** 2 if a * x + b * y == m
        }
      }
    }
  }
  s / 72
end

def A48(n)
  m = n + 6
  s = 0
  (1..m).each{|c|
    (c + 1..m).each{|b|
      (b + 1..m).each{|a|
        1.step(m, 2){|x|
          1.step(m, 2){|y|
            1.step(m, 2){|z|
              s += (a * b * c) ** 3 * ((a * a - b * b) * (a * a - c * c) * (b * b - c * c)) ** 2 if a * x + b * y + c * z == m
            }
          }
        }
      }
    }
  }
  s / 3110400
end

n = 15
p (0..n).map{|i| A24(i)}
p (0..n).map{|i| A48(i)}

出力結果
[1, 24, 276, 2048, 11178, 48576, 177400, 565248, 1612875, 4200352, 10131156, 22892544, 48897678, 99448320, 193740408, 363315200]
[1, 48, 1128, 17344, 196836, 1764192, 13051008, 82244736, 452197434, 2210431056, 9753024192, 39328459968, 146436844568, 507826976160, 1652238451200, 5074887938688]

170609

Ruby


The Kac-Wakimoto Conjecture(1)

The 1-2-3 of Modular Forms には、
定理(!)の片割れだけ載っている。
この定理に従い、値を求めてみた。

def A16(n)
  m = 2 * n + 4
  s = 0
  1.step(m, 2){|b|
    (b + 2).step(m, 2){|a|
      1.step(m, 2){|x|
        1.step(m, 2){|y|
          s += a * b * (a * a - b * b) ** 2 if a * x + b * y == m
        }
      }
    }
  }
  s / 192
end

def A36(n)
  m = 2 * n + 9
  s = 0
  1.step(m, 2){|c|
    (c + 2).step(m, 2){|b|
      (b + 2).step(m, 2){|a|
        1.step(m, 2){|x|
          1.step(m, 2){|y|
            1.step(m, 2){|z|
              s += a * b * c * ((a * a - b * b) * (a * a - c * c) * (b * b - c * c)) ** 2 if a * x + b * y + c * z == m
            }
          }
        }
      }
    }
  }
  s / 141557760
end

n = 10
p (0..n).map{|i| A16(i)}
p (0..n).map{|i| A36(i)}

出力結果
[1, 16, 120, 576, 2060, 6048, 15424, 35200, 73518, 143280, 263584]
[1, 36, 630, 7176, 60165, 398412, 2184078, 10255320, 42321942, 156590980, 527649912]

2017年6月4日日曜日

170604

Ruby


k - 1段とばしまでOKな階段ののぼりおり

k - 1段とばしまでOKな階段ののぼり方は、
フィボナッチ数列やトリボナッチ数列になることは
よく知られている。
では、k - 1段とばしまでOKな階段ののぼりおりはどうなるか
実験してみた。
ただし、のぼっておりるまでに各段は少なくとも一回はふむものとする。

def f(ary, n)
  return false if ary.size < n
  a = ary[-1]
  ary[-n..-2].all?{|i| i == a}
end

def A(k, n)
  f_ary = [[]]
  ary = [1]
  f_ary = [[]]
  ary = [1]
  (n - 1).times{
    b_ary = []
    f_ary.each{|i|
      i0, i1, i2 = i + [0], i + [1], i + [2]
      b_ary << i0 if !f(i0, k)
      b_ary << i1 if !f(i1, k)
      b_ary << i2
    }
    f_ary = b_ary
    ary << f_ary.size
  }
  ary
end

n = 15
(1..10).each{|i| p A(i, n)}

出力結果
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
[1, 3, 7, 17, 41, 99, 239, 577, 1393, 3363, 8119, 19601, 47321, 114243, 275807]
[1, 3, 9, 25, 71, 201, 569, 1611, 4561, 12913, 36559, 103505, 293041, 829651, 2348889]
[1, 3, 9, 27, 79, 233, 687, 2025, 5969, 17595, 51865, 152883, 450655, 1328401, 3915743]
[1, 3, 9, 27, 81, 241, 719, 2145, 6399, 19089, 56945, 169875, 506761, 1511739, 4509729]
[1, 3, 9, 27, 81, 243, 727, 2177, 6519, 19521, 58455, 175041, 524153, 1569555, 4699969]
[1, 3, 9, 27, 81, 243, 729, 2185, 6551, 19641, 58887, 176553, 529335, 1587033, 4758185]
[1, 3, 9, 27, 81, 243, 729, 2187, 6559, 19673, 59007, 176985, 530847, 1592217, 4775679]
[1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19681, 59039, 177105, 531279, 1593729, 4780863]
[1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59047, 177137, 531399, 1594161, 4782375]