1 /* specfunc/bessel_Ynu.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_bessel.h>
30 #include "bessel_olver.h"
31 #include "bessel_temme.h"
33 /* Perform forward recurrence for Y_nu(x) and Y'_nu(x)
35 * Y_{nu+1} = nu/x Y_nu - Y'_nu
36 * Y'_{nu+1} = -(nu+1)/x Y_{nu+1} + Y_nu
41 bessel_Y_recur(const double nu_min, const double x, const int kmax,
42 const double Y_start, const double Yp_start,
43 double * Y_end, double * Yp_end)
47 double Y_nu = Y_start;
48 double Yp_nu = Yp_start;
51 for(k=1; k<=kmax; k++) {
52 double nuox = nu*x_inv;
53 double Y_nu_save = Y_nu;
54 Y_nu = -Yp_nu + nuox * Y_nu;
55 Yp_nu = Y_nu_save - (nuox+x_inv) * Y_nu;
65 /*-*-*-*-*-*-*-*-*-*-*-* Functions with Error Codes *-*-*-*-*-*-*-*-*-*-*-*/
68 gsl_sf_bessel_Ynu_e(double nu, double x, gsl_sf_result * result)
70 /* CHECK_POINTER(result) */
72 if(x <= 0.0 || nu < 0.0) {
76 return gsl_sf_bessel_Ynu_asymp_Olver_e(nu, x, result);
79 /* -1/2 <= mu <= 1/2 */
80 int N = (int)(nu + 0.5);
83 gsl_sf_result Y_mu, Y_mup1;
91 /* Determine Ymu, Ymup1 directly. This is really
92 * an optimization since this case could as well
93 * be handled by a call to gsl_sf_bessel_JY_mu_restricted(),
96 stat_mu = gsl_sf_bessel_Y_temme(mu, x, &Y_mu, &Y_mup1);
99 /* Determine Ymu, Ymup1 and Jmu, Jmup1.
101 gsl_sf_result J_mu, J_mup1;
102 stat_mu = gsl_sf_bessel_JY_mu_restricted(mu, x, &J_mu, &J_mup1, &Y_mu, &Y_mup1);
105 /* Forward recursion to get Ynu, Ynup1.
109 for(n=1; n<=N; n++) {
110 Ynp1 = 2.0*(mu+n)/x * Yn - Ynm1;
115 result->val = Ynm1; /* Y_nu */
116 result->err = (N + 1.0) * fabs(Ynm1) * (fabs(Y_mu.err/Y_mu.val) + fabs(Y_mup1.err/Y_mup1.val));
117 result->err += 2.0 * GSL_DBL_EPSILON * fabs(Ynm1);
124 /*-*-*-*-*-*-*-*-*-* Functions w/ Natural Prototypes *-*-*-*-*-*-*-*-*-*-*/
128 double gsl_sf_bessel_Ynu(const double nu, const double x)
130 EVAL_RESULT(gsl_sf_bessel_Ynu_e(nu, x, &result));