1 /* specfunc/bessel_Y1.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 besy1, 1977 version, w. fullerton */
38 /* chebyshev expansions
40 series for by1 on the interval 0. to 1.60000d+01
41 with weighted error 1.87e-18
42 log weighted error 17.73
43 significant figures required 17.83
44 decimal places required 18.30
47 static double by1_data[14] = {
48 0.03208047100611908629,
50 0.00649996189992317500,
51 -0.08936164528860504117,
52 0.01325088122175709545,
53 -0.00089790591196483523,
54 0.00003647361487958306,
55 -0.00000100137438166600,
56 0.00000001994539657390,
57 -0.00000000030230656018,
58 0.00000000000360987815,
59 -0.00000000000003487488,
60 0.00000000000000027838,
61 -0.00000000000000000186
63 static cheb_series by1_cs = {
71 /*-*-*-*-*-*-*-*-*-*-*-* Functions with Error Codes *-*-*-*-*-*-*-*-*-*-*-*/
73 int gsl_sf_bessel_Y1_e(const double x, gsl_sf_result * result)
75 const double two_over_pi = 2.0/M_PI;
76 const double xmin = 1.571*GSL_DBL_MIN; /*exp ( amax1(alog(r1mach(1)), -alog(r1mach(2)))+.01) */
77 const double x_small = 2.0 * GSL_SQRT_DBL_EPSILON;
78 const double xmax = 1.0/GSL_DBL_EPSILON;
80 /* CHECK_POINTER(result) */
86 OVERFLOW_ERROR(result);
88 else if(x < x_small) {
89 const double lnterm = log(0.5*x);
92 int status = gsl_sf_bessel_J1_e(x, &J1);
93 cheb_eval_e(&by1_cs, -1.0, &c);
94 result->val = two_over_pi * lnterm * J1.val + (0.5 + c.val)/x;
95 result->err = fabs(lnterm) * (fabs(GSL_DBL_EPSILON * J1.val) + J1.err) + c.err/x;
99 const double lnterm = log(0.5*x);
103 cheb_eval_e(&by1_cs, 0.125*x*x-1.0, &c);
104 status = gsl_sf_bessel_J1_e(x, &J1);
105 result->val = two_over_pi * lnterm * J1.val + (0.5 + c.val)/x;
106 result->err = fabs(lnterm) * (fabs(GSL_DBL_EPSILON * J1.val) + J1.err) + c.err/x;
110 const double z = 32.0/(x*x) - 1.0;
114 const int stat_ca = cheb_eval_e(&_gsl_sf_bessel_amp_phase_bm1_cs, z, &ca);
115 const int stat_ct = cheb_eval_e(&_gsl_sf_bessel_amp_phase_bth1_cs, z, &ct);
116 const int stat_cp = gsl_sf_bessel_cos_pi4_e(x, ct.val/x, &cp);
117 const double sqrtx = sqrt(x);
118 const double ampl = (0.75 + ca.val) / sqrtx;
119 result->val = -ampl * cp.val;
120 result->err = fabs(cp.val) * ca.err/sqrtx + fabs(ampl) * cp.err;
121 result->err += GSL_DBL_EPSILON * fabs(result->val);
122 return GSL_ERROR_SELECT_3(stat_ca, stat_ct, stat_cp);
125 UNDERFLOW_ERROR(result);
130 /*-*-*-*-*-*-*-*-*-* Functions w/ Natural Prototypes *-*-*-*-*-*-*-*-*-*-*/
134 double gsl_sf_bessel_Y1(const double x)
136 EVAL_RESULT(gsl_sf_bessel_Y1_e(x, &result));