gsl_specfunc__atanint.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* specfunc/atanint.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_mode.h"
  24. #include "gsl_sf_expint.h"
  25. #include "gsl_specfunc__chebyshev.h"
  26. #include "gsl_specfunc__cheb_eval.c"
  27. static double atanint_data[21] = {
  28. 1.91040361296235937512,
  29. -0.4176351437656746940e-01,
  30. 0.275392550786367434e-02,
  31. -0.25051809526248881e-03,
  32. 0.2666981285121171e-04,
  33. -0.311890514107001e-05,
  34. 0.38833853132249e-06,
  35. -0.5057274584964e-07,
  36. 0.681225282949e-08,
  37. -0.94212561654e-09,
  38. 0.13307878816e-09,
  39. -0.1912678075e-10,
  40. 0.278912620e-11,
  41. -0.41174820e-12,
  42. 0.6142987e-13,
  43. -0.924929e-14,
  44. 0.140387e-14,
  45. -0.21460e-15,
  46. 0.3301e-16,
  47. -0.511e-17,
  48. 0.79e-18,
  49. };
  50. static cheb_series atanint_cs = {
  51. atanint_data,
  52. 20,
  53. -1, 1,
  54. 10
  55. };
  56. /*-*-*-*-*-*-*-*-*-*-*-* Functions with Error Codes *-*-*-*-*-*-*-*-*-*-*/
  57. int
  58. gsl_sf_atanint_e(const double x, gsl_sf_result * result)
  59. {
  60. const double ax = fabs(x);
  61. const double sgn = GSL_SIGN(x);
  62. /* CHECK_POINTER(result) */
  63. if(ax == 0.0) {
  64. result->val = 0.0;
  65. result->err = 0.0;
  66. return GSL_SUCCESS;
  67. }
  68. else if(ax < 0.5*GSL_SQRT_DBL_EPSILON) {
  69. result->val = x;
  70. result->err = 0.0;
  71. return GSL_SUCCESS;
  72. }
  73. else if(ax <= 1.0) {
  74. const double t = 2.0 * (x*x - 0.5);
  75. gsl_sf_result result_c;
  76. cheb_eval_e(&atanint_cs, t, &result_c);
  77. result->val = x * result_c.val;
  78. result->err = x * result_c.err;
  79. result->err += GSL_DBL_EPSILON * fabs(result->val);
  80. return GSL_SUCCESS;
  81. }
  82. else if(ax < 1.0/GSL_SQRT_DBL_EPSILON) {
  83. const double t = 2.0 * (1.0/(x*x) - 0.5);
  84. gsl_sf_result result_c;
  85. cheb_eval_e(&atanint_cs, t, &result_c);
  86. result->val = sgn * (0.5*M_PI*log(ax) + result_c.val/ax);
  87. result->err = result_c.err/ax + fabs(result->val*GSL_DBL_EPSILON);
  88. result->err += GSL_DBL_EPSILON * fabs(result->val);
  89. return GSL_SUCCESS;
  90. }
  91. else {
  92. result->val = sgn * 0.5*M_PI*log(ax);
  93. result->err = 2.0 * fabs(result->val * GSL_DBL_EPSILON);
  94. return GSL_SUCCESS;
  95. }
  96. }
  97. /*-*-*-*-*-*-*-*-*-* Functions w/ Natural Prototypes *-*-*-*-*-*-*-*-*-*-*/
  98. #include "gsl_specfunc__eval.h"
  99. double gsl_sf_atanint(const double x)
  100. {
  101. EVAL_RESULT(gsl_sf_atanint_e(x, &result));
  102. }