2017年7月17日月曜日

170717

Ruby


q * Delta' / Delta

E_2 = q * Delta' / Delta が成り立つことを確認しておく。

# 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(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 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 E_2(n)
  a0 = A([[1, 24]], n)
  a = [0] + a0
  puts "Delta'"
  p b = (1..n + 1).map{|i| i * a[i]}
  puts "q / Delta"
  p I(a0, n)
  puts "E_2"
  mul(I(a0, n), b, n)
end

n = 10
p ary = E_2(n)

出力結果
Delta'
[1, -48, 756, -5888, 24150, -36288, -117208, 675840, -1022787, -1159200, 5880732]
q / Delta
[1, 24, 324, 3200, 25650, 176256, 1073720, 5930496, 30178575, 143184000, 639249300]
E_2
[1, -24, -72, -96, -168, -144, -288, -192, -360, -312, -432]

0 件のコメント:

コメントを投稿