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_clausen.h>
28 #include "chebyshev.h"
29 #include "cheb_eval.c"
31 static double aclaus_data[15] = {
32 2.142694363766688447e+00,
33 0.723324281221257925e-01,
34 0.101642475021151164e-02,
35 0.3245250328531645e-04,
36 0.133315187571472e-05,
48 static cheb_series aclaus_cs = {
52 8 /* FIXME: this is a guess, correct value needed here BJG */
56 /*-*-*-*-*-*-*-*-*-*-*-* Functions with Error Codes *-*-*-*-*-*-*-*-*-*-*-*/
58 int gsl_sf_clausen_e(double x, gsl_sf_result *result)
60 const double x_cut = M_PI * GSL_SQRT_DBL_EPSILON;
70 /* Argument reduction to [0, 2pi) */
71 status_red = gsl_sf_angle_restrict_pos_e(&x);
73 /* Further reduction to [0,pi) */
75 /* simulated extra precision: 2PI = p0 + p1 */
76 const double p0 = 6.28125;
77 const double p1 = 0.19353071795864769253e-02;
87 result->val = x * (1.0 - log(x));
88 result->err = x * GSL_DBL_EPSILON;
91 const double t = 2.0*(x*x / (M_PI*M_PI) - 0.5);
92 gsl_sf_result result_c;
93 cheb_eval_e(&aclaus_cs, t, &result_c);
94 result->val = x * (result_c.val - log(x));
95 result->err = x * (result_c.err + GSL_DBL_EPSILON);
104 /*-*-*-*-*-*-*-*-*-* Functions w/ Natural Prototypes *-*-*-*-*-*-*-*-*-*-*/
108 double gsl_sf_clausen(const double x)
110 EVAL_RESULT(gsl_sf_clausen_e(x, &result));