### ----------------------------------------------------
### -- Math::Libgsl::Function
### -- Licenses: Artistic-2.0
### -- Authors: Fernando Santagata
### -- File: t/01-raw-function.rakutest
### ----------------------------------------------------
### -- Chunk 3 of 5
prel_2(-10e0), 0.18000090799859525, :rel-tol(10⁻¹⁵), '2 * (exp(x) - 1 - x) / x²';
  ok gsl_sf_exprel_2_e(-10e0, $res) == 0, '2 * (exp(x) - 1 - x) / x² with error check';
  is-approx $res.val, 0.18000090799859525, :rel-tol(10⁻¹⁵), '2 * (exp(x) - 1 - x) / x² with error check: value';
  is-approx gsl_sf_exprel_n(3, -10e0), 0.24599972760042138, :rel-tol(10⁻¹⁵), 'N relative exponential';
  ok gsl_sf_exprel_n_e(3, -10e0, $res) == 0, 'N relative exponential with error check';
  is-approx $res.val, 0.24599972760042138, :rel-tol(10⁻¹⁵), 'N relative exponential with error check: value';
  ok gsl_sf_exp_err_e(-10e0, 16e0 * 2.2204460492503131e-16, $res) == 0, 'exp with absolute error';
  ok $res.val == exp(-10), 'exp with absolute error: value';
  ok gsl_sf_exp_err_e10_e(1e0, 16e0 * 2.2204460492503131e-16, $rese10) == 0, 'exp with extended range error check';
  ok $rese10.val == 𝑒, 'exp with extended range error check: value';
  ok gsl_sf_exp_mult_err_e(-10e0, 2e0 * 2.2204460492503131e-16, 2e0, 2e0 * 2.2204460492503131e-16, $res) == 0, 'y * exp(x) with absolute error';
  ok $res.val == 2 * exp(-10), 'y * exp(x) with absolute error: value';
  ok gsl_sf_exp_mult_err_e10_e(-10e0, 2e0 * 2.2204460492503131e-16, 2e0, 2e0 * 2.2204460492503131e-16, $rese10) == 0, 'y * exp(x) with extended range error check';
  ok $rese10.val == 2 * exp(-10), 'y * exp(x) with extended range error check: value';
}, 'raw - exponential functions';

subtest {
  my gsl_sf_result $res .= new;
  is-approx gsl_sf_expint_E1(1e0), 0.21938393439552029, :rel-tol(10⁻¹⁵), 'E₁(x)';
  ok gsl_sf_expint_E1_e(1e0, $res) == 0, 'E₁(x) with error check';
  is-approx $res.val, 0.21938393439552029, :rel-tol(10⁻¹⁵), 'E₁(x) with error check: value';
  is-approx gsl_sf_expint_E2(1e0), 0.148495506775922, :rel-tol(10⁻¹⁵), 'E₂(x)';
  ok gsl_sf_expint_E2_e(1e0, $res) == 0, 'E₂(x) with error check';
  is-approx $res.val, 0.148495506775922, :rel-tol(10⁻¹⁵), 'E₂(x) with error check: value';
  is-approx gsl_sf_expint_En(1, 1e0), 0.21938393439552029, :rel-tol(10⁻¹⁵), 'Eₙ(x)';
  ok gsl_sf_expint_En_e(1, 1e0, $res) == 0, 'Eₙ(x) with error check';
  is-approx $res.val, 0.21938393439552029, :rel-tol(10⁻¹⁵), 'Eₙ(x) with error check: value';
  is-approx gsl_sf_expint_Ei(1e0), 1.895117816355937, :rel-tol(10⁻¹⁵), 'Eᵢ(x)';
  ok gsl_sf_expint_Ei_e(1e0, $res) == 0, 'Eᵢ(x) with error check';
  is-approx $res.val, 1.895117816355937, :rel-tol(10⁻¹⁵), 'Eᵢ(x) with error check: value';
  is-approx gsl_sf_Shi(.1e0), 0.100055572225057, :rel-tol(10⁻¹⁵), 'Shi(x)';
  ok gsl_sf_Shi_e(.1e0, $res) == 0, 'Shi(x) with error check';
  is-approx $res.val, 0.100055572225057, :rel-tol(10⁻¹⁵), 'Shi(x) with error check: value';
  is-approx gsl_sf_Chi(1e0), 0.837866940980208, :rel-tol(10⁻¹⁵), 'Chi(x)';
  ok gsl_sf_Chi_e(1e0, $res) == 0, 'Chi(x) with error check';
  is-approx $res.val, 0.837866940980208, :rel-tol(10⁻¹⁵), 'Chi(x) with error check: value';
  is-approx gsl_sf_expint_3(1e0), 0.807511182139672, :rel-tol(10⁻¹⁵), 'Ei₃(x)';
  ok gsl_sf_expint_3_e(1e0, $res) == 0, 'Ei₃(x) with error check';
  is-approx $res.val, 0.807511182139672, :rel-tol(10⁻¹⁵), 'Ei₃(x) with error check: value';
  is-approx gsl_sf_Si(1e0), 0.946083070367183, :rel-tol(10⁻¹⁵), 'Si(x)';
  ok gsl_sf_Si_e(1e0, $res) == 0, 'Si(x) with error check';
  is-approx $res.val, 0.946083070367183, :rel-tol(10⁻¹⁵), 'Si(x) with error check: value';
  is-approx gsl_sf_Ci(1e0), 0.337403922900968, :rel-tol(10⁻¹⁵), 'Ci(x)';
  ok gsl_sf_Ci_e(1e0, $res) == 0, 'Ci(x) with error check';
  is-approx $res.val, 0.337403922900968, :rel-tol(10⁻¹⁵), 'Ci(x) with error check: value';
  is-approx gsl_sf_atanint(1e0), 0.915965594177219, :rel-tol(10⁻¹⁵), 'atanint(x)';
  ok gsl_sf_atanint_e(1e0, $res) == 0, 'atanint(x) with error check';
  is-approx $res.val, 0.915965594177219, :rel-tol(10⁻¹⁵), 'atanint(x) with error check: value';
}, 'raw - exponential integrals';

subtest {
  my gsl_sf_result $res .= new;
  is-approx gsl_sf_fermi_dirac_m1(1e0), 0.731058578630005, :rel-tol(10⁻¹⁵), 'F₋₁(x)';
  ok gsl_sf_fermi_dirac_m1_e(1e0, $res) == 0, 'F₋₁(x) with error check';
  is-approx $res.val, 0.731058578630005, :rel-tol(10⁻¹⁵), 'F₋₁(x) with error check: value';
  is-approx gsl_sf_fermi_dirac_0(1e0), 1.313261687518223, :rel-tol(10⁻¹⁵), 'F₀(x)';
  ok gsl_sf_fermi_dirac_0_e(1e0, $res) == 0, 'F₀(x) with error check';
  is-approx $res.val, 1.313261687518223, :rel-tol(10⁻¹⁵), 'F₀(x) with error check: value';
  is-approx gsl_sf_fermi_dirac_1(1e0), 1.806286070444775, :rel-tol(10⁻¹⁵), 'F₁(x)';
  ok gsl_sf_fermi_dirac_1_e(1e0, $res) == 0, 'F₁(x) with error check';
  is-approx $res.val, 1.806286070444775, :rel-tol(10⁻¹⁵), 'F₁(x) with error check: value';
  is-approx gsl_sf_fermi_dirac_2(1e0), 2.164165612812701, :rel-tol(10⁻¹⁵), 'F₂(x)';
  ok gsl_sf_fermi_dirac_2_e(1e0, $res) == 0, 'F₂(x) with error check';
  is-approx $res.val, 2.164165612812701, :rel-tol(10⁻¹⁵), 'F₂(x) with error check: value';
  is-approx gsl_sf_fermi_dirac_int(3, 1e0), 2.39822608224894, :rel-tol(10⁻¹⁵), 'Fⱼ(x)';
  ok gsl_sf_fermi_dirac_int_e(3, 1e0, $res) == 0, 'Fⱼ(x) with error check';
  is-approx $res.val, 2.39822608224894, :rel-tol(10⁻¹⁵), 'Fⱼ(x) with error check: value';
  is-approx gsl_sf_fermi_dirac_mhalf(1e0), 1.027057125474351, :rel-tol(10⁻¹⁵), 'F-1/2(x)';
  ok gsl_sf_fermi_dirac_mhalf_e(1e0, $res) == 0, 'F-1/2(x) with error check';
  is-approx $res.val, 1.027057125474351, :rel-tol(10⁻¹⁵), 'F-1/2(x) with error check: value';
  is-approx gsl_sf_fermi_dirac_half(1e0), 1.575640776151300, :rel-tol(10⁻¹⁵), 'F1/2(x)';
  ok gsl_sf_fermi_dirac_half_e(1e0, $res) == 0, 'F1/2(x) with error check';
  is-approx $res.val, 1.575640776151300, :rel-tol(10⁻¹⁵), 'F1/2(x) with error check: value';
  is-approx gsl_sf_fermi_dirac_3half(1e0), 2.002258148778464, :rel-tol(10⁻¹⁵), 'F3/2(x)';
  ok gsl_sf_fermi_dirac_3half_e(1e0, $res) == 0, 'F3/2(x) with error check';
  is-approx $res.val, 2.002258148778464, :rel-tol(10⁻¹⁵), 'F3/2(x) with error check: value';
  is-approx gsl_sf_fermi_dirac_inc_0(1e0, 2e0), 0.313261687518223, :rel-tol(10⁻¹⁵), 'F₀(x,b)';
  ok gsl_sf_fermi_dirac_inc_0_e(1e0, 2e0, $res) == 0, 'F₀(x,b) with error check';
  is-approx $res.val, 0.313261687518223, :rel-tol(10⁻¹⁵), 'F₀(x,b) with error check: value';
}, 'raw - Fermi-Dirac integrals';

subtest {
  my gsl_sf_result $res .= new;
  my gsl_sf_result $resi .= new;
  ok gsl_sf_gamma(9e0) == 40320, 'Γ(x)';
  ok gsl_sf_gamma_e(9e0, $res) == 0, 'Γ(x) with error check';
  ok $res.val == 40320, 'Γ(x) with error check: value';
  is-approx gsl_sf_lngamma(.1e0), 2.252712651734205, :rel-tol(10⁻¹⁵), 'log(|Γ(x)|)';
  ok gsl_sf_lngamma_e(.1e0, $res) == 0, 'log(|Γ(x)|) with error check';
  is-approx $res.val, 2.252712651734205, :rel-tol(10⁻¹⁵), 'log(|Γ(x)|) with error check: value';
  my num64 $sgn;
  ok gsl_sf_lngamma_sgn_e(-.1e0, $res, $sgn) == 0, 'log(|Γ(x)|) with error check and sign';
  is-approx $res.val, 2.368961332728788, :rel-tol(10⁻¹⁵), 'log(|Γ(x)|) with error check and sign: value';
  ok $sgn == -1, 'log(|Γ(x)|) with error check: sign';
  is-approx gsl_sf_gammastar(9e0), 1.009298426421819, :rel-tol(10⁻¹⁵), 'Γ*(x)';
  ok gsl_sf_gammastar_e(9e0, $res) == 0, 'Γ*(x) with error check';
  is-approx $res.val, 1.009298426421819, :rel-tol(10⁻¹⁵), 'Γ*(x) with error check: value';
  ok gsl_sf_gammainv(3e0) == .5, '1/Γ(x)';
  ok gsl_sf_gammainv_e(3e0, $res) == 0, '1/Γ(x) with error check';
  ok $res.val == .5, '1/Γ(x) with error check: value';
  ok gsl_sf_lngamma_complex_e(5e0, 2e0, $res, $resi) == 0, 'log(Γ(z)) with error check';
  is-approx $res.val, 2.748701756133804, :rel-tol(10⁻¹⁵), 'log(Γ(z)) with error check: value';
  is-approx $resi.val, 3.073843410049702, :rel-tol(10⁻¹⁵), 'log(Γ(z)) with error check: value';
  ok gsl_sf_fact(8) == 40320, 'n!';
  ok gsl_sf_fact_e(8, $res) == 0, 'n! with error check';
  ok $res.val == 40320, 'n! with error check: value';
  ok gsl_sf_doublefact(7) == 105, 'n!!';
  ok gsl_sf_doublefact_e(7, $res) == 0, 'n!! with error check';
  ok $res.val == 105, 'n!! with error check: value';
  is-approx gsl_sf_lnfact(7), 8.525161361065414, :rel-tol(10⁻¹⁵), 'log(n!)';
  ok gsl_sf_lnfact_e(7, $res) == 0, 'log(n!) with error check';
  is-approx $res.val, 8.525161361065414, :rel-tol(10⁻¹⁵), 'log(n!) with error check: value';
  is-approx gsl_sf_lndoublefact(7), 4.653960350157524, :rel-tol(10⁻¹⁵), 'log(n!!)';
  ok gsl_sf_lndoublefact_e(7, $res) == 0, 'log(n!!) with error check';
  is-approx $res.val, 4.653960350157524, :rel-tol(10⁻¹⁵), 'log(n!!) with error check: value';
  ok gsl_sf_choose(7, 3) == 35, 'n!/(m!(n-m)!)';
  ok gsl_sf_choose_e(7, 3, $res) == 0, 'n!/(m!(n-m)!) with error check';
  ok $res.val == 35, 'n!/(m!(n-m)!) with error check: value';
  is-approx gsl_sf_lnchoose(7, 3), 3.555348061489414, :rel-tol(10⁻¹⁵), 'log(n!)-log(m!)-log((n-m)!)';
  ok gsl_sf_lnchoose_e(7, 3, $res) == 0, 'log(n!)-log(m!)-log((n-m)!) with error check';
  is-approx $res.val, 3.555348061489414, :rel-tol(10⁻¹⁵), 'log(n!)-log(m!)-log((n-m)!) with error check: value';
  is-approx gsl_sf_taylorcoeff(10, 5e0), 2.691144455467373, :rel-tol(10⁻¹⁵), 'xⁿ/n!';
  ok gsl_sf_taylorcoeff_e(10, 5e0, $res) == 0, 'xⁿ/n! with error check';
  is-approx $res.val, 2.691144455467373, :rel-tol(10⁻¹⁵), 'xⁿ/n! with error check: value';
  ok gsl_sf_poch(5e0, 0e0) == 1, '(a)ₓ';
  ok gsl_sf_poch_e(5e0, 0e0, $res) == 0, '(a)ₓ with error check';
  ok $res.val == 1, '(a)ₓ with error check: value';
  ok gsl_sf_lnpoch(5e0, 0e0) == 0, 'log((a)ₓ)';
  ok gsl_sf_lnpoch_e(5e0, 0e0, $res) == 0, 'log((a)ₓ) with error check';
  ok $res.val == 0, 'log((a)ₓ) with error check: value';
  ok gsl_sf_lnpoch_sgn_e(5e0, 0e0, $res, $sgn) == 0, 'log((a)ₓ) with error check and sign';
  ok $res.val == 0, 'log((a)ₓ) with error check and sign: value';
  ok $sgn == 1, 'log((a)ₓ) with error check and sign: sign';
  is-approx gsl_sf_pochrel(5e0, 0e0), 1.506117668431801, :rel-tol(10⁻¹⁵), '((a)ₓ-1)/x';
  ok gsl_sf_pochrel_e(5e0, 0e0, $res) == 0, '((a)ₓ-1)/x with error check';
  is-approx $res.val, 1.506117668431801, :rel-tol(10⁻¹⁵), '((a)ₓ-1)/x with error check: value';
  is-approx gsl_sf_gamma_inc(1e0, 1e0), 0.367879441171442, :rel-tol(10⁻¹⁵), 'Γ(a,x)';
  ok gsl_sf_gamma_inc_e(1e0, 1e0, $res) == 0, 'Γ(a,x) with error check';
  is-approx $res.val, 0.367879441171442, :rel-tol(10⁻¹⁵), 'Γ(a,x) with error check: value';
  is-approx gsl_sf_gamma_inc_Q(1e0, 1.01e0), 0.364218979571523, :rel-tol(10⁻¹⁵), 'Q(a,x)';
  ok gsl_sf_gamma_inc_Q_e(1e0, 1.01e0, $res) == 0, 'Q(a,x) with error check';
  is-approx $res.val, 0.364218979571523, :rel-tol(10⁻¹⁵), 'Q(a,x) with error check: value';
  is-approx gsl_sf_gamma_inc_P(100e0, 99e0), 0.473304330399461, :rel-tol(10⁻¹⁵), 'P(a,x)';
  ok gsl_sf_gamma_inc_P_e(100e0, 99e0, $res) == 0, 'P(a,x) with error check';
  is-approx $res.val, 0.473304330399461, :rel-tol(10⁻¹⁵), 'P(a,x) with error check: value';
  ok gsl_sf_beta(1e0, 1e0) == 1, 'B(a,b)';
  ok gsl_sf_beta_e(1e0, 1e0, $res) == 0, 'B(a,b) with error check';
  ok $res.val == 1, 'B(a,b) with error check: value';
  is-approx gsl_sf_lnbeta(1e0, 1.01e0), -0.009950330853168186, :rel-tol(10⁻¹⁵), 'log(B(a,b))';
  ok gsl_sf_lnbeta_e(1e0, 1.01e0, $res) == 0, 'log(B(a,b)) with error check';
  is-approx $res.val, -0.009950330853168186, :rel-tol(10⁻¹⁵), 'log(B(a,b)) with error check: value';
  ok gsl_sf_beta_inc(1e0, 1e0, 1e0) == 1, 'Iₓ(a,b)';
  ok gsl_sf_beta_inc_e(1e0, 1e0, 1e0, $res) == 0, 'Iₓ(a,b) with error check';
  ok $res.val == 1, 'Iₓ(a,b) with error check: value';
}, 'raw - gamma e beta functions';

subtest {
  my gsl_sf_result $res .= new;
  is-approx gsl_sf_gegenpoly_1(0e0, 1e0), 2, :rel-tol(10⁻¹⁵), 'Cₙ(λ)(x) n=1';
  ok gsl_sf_gegenpoly_1_e(0e0, 1e0, $res) == 0, 'Cₙ(λ)(x) n=1 with error check';
  is-approx $res.val, 2, :rel-tol(10⁻¹⁵), 'Cₙ(λ)(x) n=1 with error check: value';
  is-approx gsl_sf_gegenpoly_2(0e0, 1e0), 1, :rel-tol(10⁻¹⁵), 'Cₙ(λ)(x) n=2';
  ok gsl_sf_gegenpoly_2_e(0e0, 1e0, $res) == 0, 'Cₙ(λ)(x) n=2 with error check';
  is-approx $res.val, 1, :rel-tol(10⁻¹⁵), 'Cₙ(λ)(x) n=2 with error check: value';
  is-approx gsl_sf_gegenpoly_3(1e0, 1e0), 4, :rel-tol(10⁻¹⁵), 'Cₙ(λ)(x) n=3';
  ok gsl_sf_gegenpoly_3_e(1e0, 1e0, $res) == 0, 'Cₙ(λ)(x) n=3 with error check';
  is-approx $res.val, 4, :rel-tol(10⁻¹⁵), 'Cₙ(λ)(x) n=3 with error check: value';
  is-approx gsl_sf_gegenpoly_n(1, 1e0, 1e0), 2, :rel-tol(10⁻¹⁵), 'Cₙ(λ)(x)';
  ok gsl_sf_gegenpoly_n_e(1, 1e0, 1e0, $res) == 0, 'Cₙ(λ)(x) with error check';
  is-approx $res.val, 2, :rel-tol(10⁻¹⁵), 'Cₙ(λ)(x) with error check: value';
  my CArray[num64] $res_array .= new: 0e0 xx 12;
  ok gsl_sf_gegenpoly_array(11, 5e0, 1e0, $res_array) == 0, 'Cₙ(λ)(x) for n=0,1,2…nmax';
  ok $res_array[1] == 10, 'Cₙ(λ)(x) n=1';
  ok $res_array[10] == 9.23780e+4, 'Cₙ(λ)(x) n=10';
}, 'raw - Gegenbauer functions';

subtest {
  my gsl_sf_result $res .= new;
  my num64 $a;
  my CArray[num64] $res_array .= new: 0e0 xx 11;
  ok gsl_sf_hermite_phys(0, .75e0) == 1, 'Hₙ(x)';
  ok gsl_sf_hermite_phys_e(0, .75e0, $res) == 0, 'Hₙ(x) with error check';
  ok $res.val == 1, 'Hₙ(x) with error check: value';
  ok gsl_sf_hermite_phys_array(0, .75e0, $res_array) == 0, 'Hₙ(x) array';
  ok $res_array[0] == 1, 'Hₙ(x) array: results';
  $res_array[0] = 1e0;
  $res_array[$_] = $res_array[$_-1]/2e0 for 1…10;
  is-approx gsl_sf_hermite_phys_series(10, .75e0, $res_array), 29.591702461242672, :rel-tol(10⁻¹⁵), 'sum(aₙHₙ(x))';
  ok gsl_sf_hermite_phys_series_e(10, .75e0, $res_array, $res) == 0, 'sum(aₙHₙ(x)) with error check';
  is-approx $res.val, 29.591702461242672, :rel-tol(10⁻¹⁵), 'Hₙ(x) with error check: value';
  ok gsl_sf_hermite_prob(0, .75e0) == 1, 'Heₙ(x)';
  ok gsl_sf_hermite_prob_e(0, .75e0, $res) == 0, 'Heₙ(x) with error check';
  ok $res.val == 1, 'Heₙ(x) with error check: value';
  ok gsl_sf_hermite_prob_array(0, .75e0, $res_array) == 0, 'Heₙ(x) array';
  ok $res_array[0] == 1, 'Heₙ(x) array: results';
  is-approx gsl_sf_hermite_prob_series(10, .75e0, $res_array), 2.087602422572672, :rel-tol(10⁻¹⁵), 'sum(aₙHeₙ(x))';
  ok gsl_sf_hermite_prob_series_e(10, .75e0, $res_array, $res) == 0, 'sum(aₙHeₙ(x)) with error check';
  is-approx $res.val, 2.087602422572672, :rel-tol(10⁻¹⁵), 'sum(aₙHeₙ(x)) with error check: value';
  ok gsl_sf_hermite_phys_der(225, 128, .75e0) == 0, 'm-derivative of Hₙ(x)';
  ok gsl_sf_hermite_phys_der_e(225, 128, .75e0, $res) == 0, 'm-derivative of Hₙ(x) with error check';
  ok $res.val == 0, 'm-derivative of Hₙ(x) with error check: value';
  ok gsl_sf_hermite_phys_array_der(0, 10, .75e0, $res_array) == 0, 'm-derivative of Hₙ(x) array';
  ok $res_array[0] == 1, 'm-derivative of Hₙ(x) array [0]';
  is-approx $res_array[10], 38740.4384765625, :rel-tol(10⁻¹⁵), 'm-derivative of Hₙ(x) array [10]';
  ok gsl_sf_hermite_phys_der_array(10, 50, .75e0, $res_array) == 0, 'derivatives of Hₙ(x) array';
  is-approx $res_array[0], -8.26632218305863100726861832e38, :rel-tol(10⁻¹⁵), 'derivatives of Hₙ(x) array [0]';
  is-approx $res_array[1], 2.40954750392844799126151557e40, :rel-tol(10⁻¹⁵), 'derivatives of Hₙ(x) array [1]';
  ok gsl_sf_hermite_prob_der(225, 128, .75e0) == 0, 'm-derivative of probabilistic Heₙ(x)';
  ok gsl_sf_hermite_prob_der_e(225, 128, .75e0, $res) == 0, 'm-derivative of probabilistic Heₙ(x) with error check';
  ok $res.val == 0, 'm-derivative of probabilistic Heₙ(x) with error check: value';
  ok gsl_sf_hermite_prob_array_der(0, 10, .75e0, $res_array) == 0, 'm-derivative of probabilistic Heₙ(x) array';
  is-approx $res_array[10], 823.810509681701660156250, :rel-tol(10⁻¹⁵), 'm-derivative of Heₙ(x) array [10]';
  ok gsl_sf_hermite_prob_der_array(10, 50, .75e0, $res_array) == 0, 'derivatives of probabilistic Heₙ(x) array';
  is-approx $res_array[10], 7.9614368698398116765703194e38, :rel-tol(10⁻¹⁵), 'derivatives of Heₙ(x) array [10]';
  is-approx gsl_sf_hermite_func