Example #1
0
File: psi.go Project: swook/gogsl
func Psi_n_xg0(n int, x float64, result *Result) error {
	if n == 0 {
		return Psi_e(x, result)
	}

	/* Abramowitz + Stegun 6.4.10 */
	ln_nf, hzeta := new(Result), new(Result)
	stat_hz := Hzeta_e(float64(n+1), x, hzeta)
	stat_nf := Lnfact_e(n, ln_nf)
	stat_e := Exp_mult_err_e(ln_nf.val, ln_nf.err, hzeta.val, hzeta.err, result)
	if gsl.IsEven(n) {
		result.val = -result.val
	}
	return err.Select(stat_e, stat_nf, stat_hz)
}
Example #2
0
File: psi.go Project: swook/gogsl
func Psi_n_e(n int, x float64, result *Result) error {
	if n == 0 {
		return Psi_e(x, result)
	} else if n == 1 {
		return Psi_1_e(x, result)
	} else if n < 0 || x <= 0.0 {
		return DomainError(result)
	}

	ln_nf, hzeta := new(Result), new(Result)
	stat_hz := Hzeta_e(float64(n+1), x, hzeta)
	stat_nf := Lnfact_e(n, ln_nf)
	stat_e := Exp_mult_err_e(ln_nf.val, ln_nf.err, hzeta.val, hzeta.err, result)
	if gsl.IsEven(n) {
		result.val = -result.val
	}
	return err.Select(stat_e, stat_nf, stat_hz)
}