1 /* specfunc/bessel_Inu.c
3 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 /* Author: G. Jungman */
23 #include <gsl/gsl_math.h>
24 #include <gsl/gsl_errno.h>
25 #include <gsl/gsl_sf_exp.h>
26 #include <gsl/gsl_sf_gamma.h>
27 #include <gsl/gsl_sf_bessel.h>
32 #include "bessel_temme.h"
35 /*-*-*-*-*-*-*-*-*-*-*-* Functions with Error Codes *-*-*-*-*-*-*-*-*-*-*-*/
38 gsl_sf_bessel_Inu_scaled_e(double nu, double x, gsl_sf_result * result)
40 /* CHECK_POINTER(result) */
42 if(x < 0.0 || nu < 0.0) {
45 else if(x*x < 10.0*(nu+1.0)) {
48 int stat = gsl_sf_bessel_IJ_taylor_e(nu, x, 1, 100, GSL_DBL_EPSILON, &b);
49 result->val = b.val * ex;
50 result->err = b.err * ex;
51 result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
54 else if(0.5/(nu*nu + x*x) < GSL_ROOT3_DBL_EPSILON) {
55 return gsl_sf_bessel_Inu_scaled_asymp_unif_e(nu, x, result);
58 int N = (int)(nu + 0.5);
59 double mu = nu - N; /* -1/2 <= mu <= 1/2 */
60 double K_mu, K_mup1, Kp_mu;
61 double K_nu, K_nup1, K_num1;
67 /* obtain K_mu, K_mup1 */
69 stat_Kmu = gsl_sf_bessel_K_scaled_temme(mu, x, &K_mu, &K_mup1, &Kp_mu);
72 stat_Kmu = gsl_sf_bessel_K_scaled_steed_temme_CF2(mu, x, &K_mu, &K_mup1, &Kp_mu);
75 /* recurse forward to obtain K_num1, K_nu */
82 K_nup1 = 2.0*(mu+n+1)/x * K_nu + K_num1;
85 /* calculate I_{nu+1}/I_nu */
86 stat_Irat = gsl_sf_bessel_I_CF1_ser(nu, x, &I_nu_ratio);
89 result->val = 1.0/(x * (K_nup1 + I_nu_ratio * K_nu));
90 result->err = GSL_DBL_EPSILON * (0.5*N + 2.0) * fabs(result->val);
92 return GSL_ERROR_SELECT_2(stat_Kmu, stat_Irat);
98 gsl_sf_bessel_Inu_e(double nu, double x, gsl_sf_result * result)
101 int stat_I = gsl_sf_bessel_Inu_scaled_e(nu, x, &b);
102 int stat_e = gsl_sf_exp_mult_err_e(x, fabs(x*GSL_DBL_EPSILON),
105 return GSL_ERROR_SELECT_2(stat_e, stat_I);
109 /*-*-*-*-*-*-*-*-*-* Functions w/ Natural Prototypes *-*-*-*-*-*-*-*-*-*-*/
113 double gsl_sf_bessel_Inu_scaled(double nu, double x)
115 EVAL_RESULT(gsl_sf_bessel_Inu_scaled_e(nu, x, &result));
119 double gsl_sf_bessel_Inu(double nu, double x)
121 EVAL_RESULT(gsl_sf_bessel_Inu_e(nu, x, &result));