2019年10月25日金曜日

191025

Ruby


The normalized Apéry-like number Jtilde_k(n)

Jtilde_1(0), Jtilde_1(1), Jtilde_1(2), ...
Jtilde_2(0), Jtilde_2(1), Jtilde_2(2), ...
...
のように出力してみた。

def f(n)
  return 1 if n < 2
  (1..n).inject(:*)
end

def Jtilde(k, n)
  return 0 if k == 0
  return (2r ** n * f(n)) ** 2 / f(2 * n + 1) if k == 1
  if n == 0
    return 1 if k == 2
    return 0
  end
  if n == 1
    return 3r / 4 if k == 2
    return 1      if k == 3 || k == 4
    return 0
  end
  ((8r * n * n - 8 * n + 3) * Jtilde(k, n - 1) - 4 * (n - 1) ** 2 * Jtilde(k, n - 2) + 4 * Jtilde(k - 2, n - 1)) / (4 * n * n)
end

(1..14).each{|i| p [i, (0..6).map{|j| Jtilde(i, j)}]}

出力結果
[1, [(1/1), (2/3), (8/15), (16/35), (128/315), (256/693), (1024/3003)]]
[2, [1, (3/4), (41/64), (147/256), (8649/16384), (32307/65536), (487889/1048576)]]
[3, [0, 1, (65/48), (13247/8640), (704707/430080), (660278641/387072000), (357852111131/204374016000)]]
[4, [0, 1, (11/8), (907/576), (1739/1024), (6567221/3686400), (54281321/29491200)]]
[5, [0, 0, (1/4), (109/216), (101717/138240), (4557449/4838400), (15689290781/13934592000)]]
[6, [0, 0, (1/4), (73/144), (3419/4608), (29273/30720), (151587391/132710400)]]
[7, [0, 0, (0/1), (1/36), (515/6912), (76667/576000), (115560397/580608000)]]
[8, [0, 0, (0/1), (1/36), (43/576), (15389/115200), (1659311/8294400)]]
[9, [0, 0, (0/1), (0/1), (1/576), (251/43200), (254977/20736000)]]
[10, [0, 0, (0/1), (0/1), (1/576), (67/11520), (34061/2764800)]]
[11, [0, 0, (0/1), (0/1), (0/1), (1/14400), (1733/6220800)]]
[12, [0, 0, (0/1), (0/1), (0/1), (1/14400), (289/1036800)]]
[13, [0, 0, (0/1), (0/1), (0/1), (0/1), (1/518400)]]
[14, [0, 0, (0/1), (0/1), (0/1), (0/1), (1/518400)]]

0 件のコメント:

コメントを投稿

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