gsl_specfunc__expint3.c 3.4 KB

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