#!/usr/bin/env ruby
require("gsl")

f = GSL::Function.new { |x|
  pow(x, 1.5)
}

printf ("f(x) = x^(3/2)\n");

x = 2.0
h = 1e-8
result, abserr = f.deriv_central(x, h)
printf("x = 2.0\n");
printf("f'(x) = %.10f +- %.10f\n", result, abserr);
printf("exact = %.10f\n\n", 1.5 * Math::sqrt(2));

aval, aerr = f.deriv_central([1, 2, 3, 4], h)
p aval

aval, aerr = f.deriv_central(1..4, h)
p aval

vval, verr = Deriv.central(f, Vector.new([1, 2, 3, 4]), h)
p vval

m = Matrix.new([1, 2], [3, 4])
mval, merr = f.deriv_central(m, h)
p mval
