def simpson(xs,xe,n) deltax = (xe-xs)*0.5/n sum = f(xs) + f(xe) + 4*f(xs+deltax) for i in 1..(n-1) sum = sum + 2*f(xs+2*i*deltax) + 4*f(xs+(2*i+1)*deltax) end deltax*sum / 3.0 end
ruby vote.rb 選択肢番号