summaryrefslogtreecommitdiff
path: root/boost/math/special_functions/detail/bessel_j0.hpp
diff options
context:
space:
mode:
authorChanho Park <chanho61.park@samsung.com>2014-12-11 18:55:56 +0900
committerChanho Park <chanho61.park@samsung.com>2014-12-11 18:55:56 +0900
commit08c1e93fa36a49f49325a07fe91ff92c964c2b6c (patch)
tree7a7053ceb8874b28ec4b868d4c49b500008a102e /boost/math/special_functions/detail/bessel_j0.hpp
parentbb4dd8289b351fae6b55e303f189127a394a1edd (diff)
downloadboost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.gz
boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.bz2
boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.zip
Imported Upstream version 1.57.0upstream/1.57.0
Diffstat (limited to 'boost/math/special_functions/detail/bessel_j0.hpp')
-rw-r--r--boost/math/special_functions/detail/bessel_j0.hpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/boost/math/special_functions/detail/bessel_j0.hpp b/boost/math/special_functions/detail/bessel_j0.hpp
index a07052d73e..ebcab17240 100644
--- a/boost/math/special_functions/detail/bessel_j0.hpp
+++ b/boost/math/special_functions/detail/bessel_j0.hpp
@@ -165,13 +165,23 @@ T bessel_j0(T x)
{
T y = 8 / x;
T y2 = y * y;
- T z = x - 0.25f * pi<T>();
BOOST_ASSERT(sizeof(PC) == sizeof(QC));
BOOST_ASSERT(sizeof(PS) == sizeof(QS));
rc = evaluate_rational(PC, QC, y2);
rs = evaluate_rational(PS, QS, y2);
- factor = sqrt(2 / (x * pi<T>()));
- value = factor * (rc * cos(z) - y * rs * sin(z));
+ factor = constants::one_div_root_pi<T>() / sqrt(x);
+ //
+ // What follows is really just:
+ //
+ // T z = x - pi/4;
+ // value = factor * (rc * cos(z) - y * rs * sin(z));
+ //
+ // But using the addition formulae for sin and cos, plus
+ // the special values for sin/cos of pi/4.
+ //
+ T sx = sin(x);
+ T cx = cos(x);
+ value = factor * (rc * (cx + sx) - y * rs * (sx - cx));
}
return value;