| 1 |
/* specfunc/expint3.c |
| 2 |
* |
| 3 |
* Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman |
| 4 |
* |
| 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. |
| 9 |
* |
| 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. |
| 14 |
* |
| 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. |
| 18 |
*/ |
| 19 |
|
| 20 |
/* Author: G. Jungman */ |
| 21 |
|
| 22 |
#include "gsl__config.h" |
| 23 |
#include "gsl_math.h" |
| 24 |
#include "gsl_errno.h" |
| 25 |
#include "gsl_sf_expint.h" |
| 26 |
|
| 27 |
#include "gsl_specfunc__error.h" |
| 28 |
|
| 29 |
#include "gsl_specfunc__chebyshev.h" |
| 30 |
#include "gsl_specfunc__cheb_eval.c" |
| 31 |
|
| 32 |
static double expint3_data[24] = { |
| 33 |
1.269198414221126014, |
| 34 |
-0.248846446384140982, |
| 35 |
0.80526220717231041e-01, |
| 36 |
-0.25772733251968330e-01, |
| 37 |
0.7599878873073774e-02, |
| 38 |
-0.2030695581940405e-02, |
| 39 |
0.490834586699330e-03, |
| 40 |
-0.107682239142021e-03, |
| 41 |
0.21551726264290e-04, |
| 42 |
-0.3956705137384e-05, |
| 43 |
0.6699240933896e-06, |
| 44 |
-0.105132180807e-06, |
| 45 |
0.15362580199e-07, |
| 46 |
-0.20990960364e-08, |
| 47 |
0.2692109538e-09, |
| 48 |
-0.325195242e-10, |
| 49 |
0.37114816e-11, |
| 50 |
-0.4013652e-12, |
| 51 |
0.412334e-13, |
| 52 |
-0.40338e-14, |
| 53 |
0.3766e-15, |
| 54 |
-0.336e-16, |
| 55 |
0.29e-17, |
| 56 |
-0.2e-18 |
| 57 |
}; |
| 58 |
static cheb_series expint3_cs = { |
| 59 |
expint3_data, |
| 60 |
23, |
| 61 |
-1.0, 1.0, |
| 62 |
15 |
| 63 |
}; |
| 64 |
|
| 65 |
static double expint3a_data[23] = { |
| 66 |
1.9270464955068273729, |
| 67 |
-0.349293565204813805e-01, |
| 68 |
0.14503383718983009e-02, |
| 69 |
-0.8925336718327903e-04, |
| 70 |
0.70542392191184e-05, |
| 71 |
-0.6671727454761e-06, |
| 72 |
0.724267589982e-07, |
| 73 |
-0.87825825606e-08, |
| 74 |
0.11672234428e-08, |
| 75 |
-0.1676631281e-09, |
| 76 |
0.257550158e-10, |
| 77 |
-0.41957888e-11, |
| 78 |
0.7201041e-12, |
| 79 |
-0.1294906e-12, |
| 80 |
0.24287e-13, |
| 81 |
-0.47331e-14, |
| 82 |
0.95531e-15, |
| 83 |
-0.1991e-15, |
| 84 |
0.428e-16, |
| 85 |
-0.94e-17, |
| 86 |
0.21e-17, |
| 87 |
-0.5e-18, |
| 88 |
0.1e-18 |
| 89 |
}; |
| 90 |
static cheb_series expint3a_cs = { |
| 91 |
expint3a_data, |
| 92 |
22, |
| 93 |
-1.0, 1.0, |
| 94 |
10 |
| 95 |
}; |
| 96 |
|
| 97 |
|
| 98 |
/*-*-*-*-*-*-*-*-*-*-*-* Functions with Error Codes *-*-*-*-*-*-*-*-*-*-*-*/ |
| 99 |
|
| 100 |
int gsl_sf_expint_3_e(const double x, gsl_sf_result * result) |
| 101 |
{ |
| 102 |
const double val_infinity = 0.892979511569249211; |
| 103 |
|
| 104 |
/* CHECK_POINTER(result) */ |
| 105 |
|
| 106 |
if(x < 0.0) { |
| 107 |
DOMAIN_ERROR(result); |
| 108 |
} |
| 109 |
else if(x < 1.6*GSL_ROOT3_DBL_EPSILON) { |
| 110 |
result->val = x; |
| 111 |
result->err = 0.0; |
| 112 |
return GSL_SUCCESS; |
| 113 |
} |
| 114 |
else if(x <= 2.0) { |
| 115 |
const double t = x*x*x/4.0 - 1.0; |
| 116 |
gsl_sf_result result_c; |
| 117 |
cheb_eval_e(&expint3_cs, t, &result_c); |
| 118 |
result->val = x * result_c.val; |
| 119 |
result->err = x * result_c.err; |
| 120 |
return GSL_SUCCESS; |
| 121 |
} |
| 122 |
else if(x < pow(-GSL_LOG_DBL_EPSILON, 1.0/3.0)) { |
| 123 |
const double t = 16.0/(x*x*x) - 1.0; |
| 124 |
const double s = exp(-x*x*x)/(3.0*x*x); |
| 125 |
gsl_sf_result result_c; |
| 126 |
cheb_eval_e(&expint3a_cs, t, &result_c); |
| 127 |
result->val = val_infinity - result_c.val * s; |
| 128 |
result->err = val_infinity * GSL_DBL_EPSILON + s * result_c.err; |
| 129 |
return GSL_SUCCESS; |
| 130 |
} |
| 131 |
else { |
| 132 |
result->val = val_infinity; |
| 133 |
result->err = val_infinity * GSL_DBL_EPSILON; |
| 134 |
return GSL_SUCCESS; |
| 135 |
} |
| 136 |
} |
| 137 |
|
| 138 |
|
| 139 |
/*-*-*-*-*-*-*-*-*-* Functions w/ Natural Prototypes *-*-*-*-*-*-*-*-*-*-*/ |
| 140 |
|
| 141 |
#include "gsl_specfunc__eval.h" |
| 142 |
|
| 143 |
double gsl_sf_expint_3(double x) |
| 144 |
{ |
| 145 |
EVAL_RESULT(gsl_sf_expint_3_e(x, &result)); |
| 146 |
} |