gsl_specfunc__bessel_amp_phase.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /* specfunc/bessel_amp_phase.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_bessel.h"
  24. #include "gsl_specfunc__bessel_amp_phase.h"
  25. /* chebyshev expansions for amplitude and phase
  26. functions used in bessel evaluations
  27. These are the same for J0,Y0 and for J1,Y1, so
  28. they sit outside those functions.
  29. */
  30. static double bm0_data[21] = {
  31. 0.09284961637381644,
  32. -0.00142987707403484,
  33. 0.00002830579271257,
  34. -0.00000143300611424,
  35. 0.00000012028628046,
  36. -0.00000001397113013,
  37. 0.00000000204076188,
  38. -0.00000000035399669,
  39. 0.00000000007024759,
  40. -0.00000000001554107,
  41. 0.00000000000376226,
  42. -0.00000000000098282,
  43. 0.00000000000027408,
  44. -0.00000000000008091,
  45. 0.00000000000002511,
  46. -0.00000000000000814,
  47. 0.00000000000000275,
  48. -0.00000000000000096,
  49. 0.00000000000000034,
  50. -0.00000000000000012,
  51. 0.00000000000000004
  52. };
  53. const cheb_series _gsl_sf_bessel_amp_phase_bm0_cs = {
  54. bm0_data,
  55. 20,
  56. -1, 1,
  57. 10
  58. };
  59. static double bth0_data[24] = {
  60. -0.24639163774300119,
  61. 0.001737098307508963,
  62. -0.000062183633402968,
  63. 0.000004368050165742,
  64. -0.000000456093019869,
  65. 0.000000062197400101,
  66. -0.000000010300442889,
  67. 0.000000001979526776,
  68. -0.000000000428198396,
  69. 0.000000000102035840,
  70. -0.000000000026363898,
  71. 0.000000000007297935,
  72. -0.000000000002144188,
  73. 0.000000000000663693,
  74. -0.000000000000215126,
  75. 0.000000000000072659,
  76. -0.000000000000025465,
  77. 0.000000000000009229,
  78. -0.000000000000003448,
  79. 0.000000000000001325,
  80. -0.000000000000000522,
  81. 0.000000000000000210,
  82. -0.000000000000000087,
  83. 0.000000000000000036
  84. };
  85. const cheb_series _gsl_sf_bessel_amp_phase_bth0_cs = {
  86. bth0_data,
  87. 23,
  88. -1, 1,
  89. 12
  90. };
  91. static double bm1_data[21] = {
  92. 0.1047362510931285,
  93. 0.00442443893702345,
  94. -0.00005661639504035,
  95. 0.00000231349417339,
  96. -0.00000017377182007,
  97. 0.00000001893209930,
  98. -0.00000000265416023,
  99. 0.00000000044740209,
  100. -0.00000000008691795,
  101. 0.00000000001891492,
  102. -0.00000000000451884,
  103. 0.00000000000116765,
  104. -0.00000000000032265,
  105. 0.00000000000009450,
  106. -0.00000000000002913,
  107. 0.00000000000000939,
  108. -0.00000000000000315,
  109. 0.00000000000000109,
  110. -0.00000000000000039,
  111. 0.00000000000000014,
  112. -0.00000000000000005,
  113. };
  114. const cheb_series _gsl_sf_bessel_amp_phase_bm1_cs = {
  115. bm1_data,
  116. 20,
  117. -1, 1,
  118. 10
  119. };
  120. static double bth1_data[24] = {
  121. 0.74060141026313850,
  122. -0.004571755659637690,
  123. 0.000119818510964326,
  124. -0.000006964561891648,
  125. 0.000000655495621447,
  126. -0.000000084066228945,
  127. 0.000000013376886564,
  128. -0.000000002499565654,
  129. 0.000000000529495100,
  130. -0.000000000124135944,
  131. 0.000000000031656485,
  132. -0.000000000008668640,
  133. 0.000000000002523758,
  134. -0.000000000000775085,
  135. 0.000000000000249527,
  136. -0.000000000000083773,
  137. 0.000000000000029205,
  138. -0.000000000000010534,
  139. 0.000000000000003919,
  140. -0.000000000000001500,
  141. 0.000000000000000589,
  142. -0.000000000000000237,
  143. 0.000000000000000097,
  144. -0.000000000000000040,
  145. };
  146. const cheb_series _gsl_sf_bessel_amp_phase_bth1_cs = {
  147. bth1_data,
  148. 23,
  149. -1, 1,
  150. 12
  151. };
  152. int
  153. gsl_sf_bessel_asymp_Mnu_e(const double nu, const double x, double * result)
  154. {
  155. const double r = 2.0*nu/x;
  156. const double r2 = r*r;
  157. const double x2 = x*x;
  158. const double term1 = (r2-1.0/x2)/8.0;
  159. const double term2 = (r2-1.0/x2)*(r2-9.0/x2)*3.0/128.0;
  160. const double Mnu2_c = 2.0/(M_PI) * (1.0 + term1 + term2);
  161. *result = sqrt(Mnu2_c)/sqrt(x); /* will never underflow this way */
  162. return GSL_SUCCESS;
  163. }
  164. int
  165. gsl_sf_bessel_asymp_thetanu_corr_e(const double nu, const double x, double * result)
  166. {
  167. const double r = 2.0*nu/x;
  168. const double r2 = r*r;
  169. const double x2 = x*x;
  170. const double term1 = x*(r2 - 1.0/x2)/8.0;
  171. const double term2 = x*(r2 - 1.0/x2)*(r2 - 25.0/x2)/384.0;
  172. *result = (-0.25*M_PI + term1 + term2);
  173. return GSL_SUCCESS;
  174. }