1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
/* specfunc/shint.c
*
* Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/* Author: G. Jungman */
#include <config.h>
#include <gsl/gsl_math.h>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_sf_expint.h>
#include "error.h"
#include "chebyshev.h"
#include "cheb_eval.c"
/*-*-*-*-*-*-*-*-*-*-*-* Private Section *-*-*-*-*-*-*-*-*-*-*-*/
/* based on SLATEC shi.f, W. Fullerton
series for shi on the interval 0.00000e+00 to 1.40625e-01
with weighted error 4.67e-20
log weighted error 19.33
significant figures required 17.07
decimal places required 19.75
*/
static double shi_data[7] = {
0.0078372685688900950695,
0.0039227664934234563973,
0.0000041346787887617267,
0.0000000024707480372883,
0.0000000000009379295591,
0.0000000000000002451817,
0.0000000000000000000467
};
static cheb_series shi_cs = {
shi_data,
6,
-1, 1,
6
};
/*-*-*-*-*-*-*-*-*-*-*-* Functions with Error Codes *-*-*-*-*-*-*-*-*-*-*-*/
int gsl_sf_Shi_e(const double x, gsl_sf_result * result)
{
const double xsml = GSL_SQRT_DBL_EPSILON; /* sqrt (r1mach(3)) */
const double ax = fabs(x);
if(ax < xsml) {
result->val = x;
result->err = 0.0;
return GSL_SUCCESS;
}
else if(ax <= 0.375) {
gsl_sf_result result_c;
cheb_eval_e(&shi_cs, 128.0*x*x/9.0-1.0, &result_c);
result->val = x * (1.0 + result_c.val);
result->err = x * result_c.err;
result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
return GSL_SUCCESS;
}
else {
gsl_sf_result result_Ei;
gsl_sf_result result_E1;
int status_Ei = gsl_sf_expint_Ei_e(x, &result_Ei);
int status_E1 = gsl_sf_expint_E1_e(x, &result_E1);
result->val = 0.5*(result_Ei.val + result_E1.val);
result->err = 0.5*(result_Ei.err + result_E1.err);
result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
if(status_Ei == GSL_EUNDRFLW && status_E1 == GSL_EUNDRFLW) {
GSL_ERROR ("underflow", GSL_EUNDRFLW);
}
else if(status_Ei == GSL_EOVRFLW || status_E1 == GSL_EOVRFLW) {
GSL_ERROR ("overflow", GSL_EOVRFLW);
}
else {
return GSL_SUCCESS;
}
}
}
int gsl_sf_Chi_e(const double x, gsl_sf_result * result)
{
gsl_sf_result result_Ei;
gsl_sf_result result_E1;
int status_Ei = gsl_sf_expint_Ei_e(x, &result_Ei);
int status_E1 = gsl_sf_expint_E1_e(x, &result_E1);
if(status_Ei == GSL_EDOM || status_E1 == GSL_EDOM) {
DOMAIN_ERROR(result);
}
else if(status_Ei == GSL_EUNDRFLW && status_E1 == GSL_EUNDRFLW) {
UNDERFLOW_ERROR(result);
}
else if(status_Ei == GSL_EOVRFLW || status_E1 == GSL_EOVRFLW) {
OVERFLOW_ERROR(result);
}
else {
result->val = 0.5 * (result_Ei.val - result_E1.val);
result->err = 0.5 * (result_Ei.err + result_E1.err);
result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
return GSL_SUCCESS;
}
}
/*-*-*-*-*-*-*-*-*-* Functions w/ Natural Prototypes *-*-*-*-*-*-*-*-*-*-*/
#include "eval.h"
double gsl_sf_Shi(const double x)
{
EVAL_RESULT(gsl_sf_Shi_e(x, &result));
}
double gsl_sf_Chi(const double x)
{
EVAL_RESULT(gsl_sf_Chi_e(x, &result));
}
|