#!/usr/bin/env ruby
require("gsl")
include GSL::Sf

l = 2
x = 0.01
File.open("gamma.dat", "w") do |file|
  while x <= 14.0
    lng = lngamma(x)
    pa05 = gamma_inc_P(0.5, x)
    pa1 = gamma_inc_P(1, x)
    pa3 = gamma_inc_P(3, x)
    pa10 = gamma_inc_P(10, x)
    if x <= 1.0
      binc0550 = beta_inc(0.5, 5.0, x)
      binc1030 = beta_inc(1.0, 3.0, x)
      binc8010 = beta_inc(8.0, 10.0, x)
      binc5005 = beta_inc(5.0, 0.5, x)
    end
    file.printf("%e %e %e %e %e %e %e %e %e %e\n", x, pa05, pa1, pa3, pa10, lng, 
                binc0550, binc1030, binc8010, binc5005)
    x += 0.01
  end
end

#puts("gamma.dat created. Try gamma.gp.")
system("gnuplot -persist gamma.gp")
File.delete("gamma.dat")
