1 /* specfunc/bessel_Y0.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_trig.h>
26 #include <gsl/gsl_sf_bessel.h>
31 #include "bessel_amp_phase.h"
32 #include "cheb_eval.c"
34 /*-*-*-*-*-*-*-*-*-*-*-* Private Section *-*-*-*-*-*-*-*-*-*-*-*/
36 /* based on SLATEC besy0, 1980 version, w. fullerton */
38 /* chebyshev expansions
40 series for by0 on the interval 0. to 1.60000d+01
41 with weighted error 1.20e-17
42 log weighted error 16.92
43 significant figures required 16.15
44 decimal places required 17.48
47 static double by0_data[13] = {
48 -0.011277839392865573,
49 -0.128345237560420350,
50 -0.104378847997942490,
52 -0.002090391647700486,
54 -0.000003369747162423,
56 -0.000000001324976772,
58 -0.000000000000188105,
62 static cheb_series by0_cs = {
70 /*-*-*-*-*-*-*-*-*-*-*-* Functions with Error Codes *-*-*-*-*-*-*-*-*-*-*-*/
72 int gsl_sf_bessel_Y0_e(const double x, gsl_sf_result * result)
74 const double two_over_pi = 2.0/M_PI;
75 const double xmax = 1.0/GSL_DBL_EPSILON;
77 /* CHECK_POINTER(result) */
85 int stat_J0 = gsl_sf_bessel_J0_e(x, &J0);
86 cheb_eval_e(&by0_cs, 0.125*x*x-1.0, &c);
87 result->val = two_over_pi*(-M_LN2 + log(x))*J0.val + 0.375 + c.val;
88 result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val) + c.err;
92 /* Leading behaviour of phase is x, which is exact,
93 * so the error is bounded.
95 const double z = 32.0/(x*x) - 1.0;
99 const int stat_c1 = cheb_eval_e(&_gsl_sf_bessel_amp_phase_bm0_cs, z, &c1);
100 const int stat_c2 = cheb_eval_e(&_gsl_sf_bessel_amp_phase_bth0_cs, z, &c2);
101 const int stat_sp = gsl_sf_bessel_sin_pi4_e(x, c2.val/x, &sp);
102 const double sqrtx = sqrt(x);
103 const double ampl = (0.75 + c1.val) / sqrtx;
104 result->val = ampl * sp.val;
105 result->err = fabs(sp.val) * c1.err/sqrtx + fabs(ampl) * sp.err;
106 result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
107 return GSL_ERROR_SELECT_3(stat_sp, stat_c1, stat_c2);
110 UNDERFLOW_ERROR(result);
115 /*-*-*-*-*-*-*-*-*-* Functions w/ Natural Prototypes *-*-*-*-*-*-*-*-*-*-*/
119 double gsl_sf_bessel_Y0(const double x)
121 EVAL_RESULT(gsl_sf_bessel_Y0_e(x, &result));