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

l = 2
x = 0.01
File.open("bessel.dat", "w") do |file|
  while x <= 12.0
    j0 = bessel_J0(x)
    j1 = bessel_J1(x)
    j2 = bessel_Jn(2, x)
    j3 = bessel_Jn(3,x)
    y0 = bessel_Y0(x)
    y1 = bessel_Y1(x)
    y2 = bessel_Yn(2, x)
    i0 = bessel_I0(x)
    i1 = bessel_I1(x)
    i2 = bessel_In(2, x)
    k0 = bessel_K0(x)
    k1 = bessel_K1(x)
    k2 = bessel_Kn(2, x)
    file.printf("%e %e %e %e %e %e %e %e %e %e %e %e %e %e\n", 
                x, j0, j1, j2, j3, y0, y1, y2, i0, i1, i2, k0, k1, k2)
    x += 0.1
  end
end

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

