]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/test/tanh_sinh_mpfr.cpp
1 // Copyright Nick Thompson, 2020
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt
5 // or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #include "math_unit_test.hpp"
7 #include <boost/math/quadrature/tanh_sinh.hpp>
8 #include <boost/math/constants/constants.hpp>
9 #include <boost/multiprecision/mpfr.hpp>
14 using boost::math::quadrature::tanh_sinh
;
15 using boost::multiprecision::mpfr_float
;
16 using boost::math::constants::pi
;
17 using boost::math::constants::zeta_three
;
20 using Real
= mpfr_float
;
22 mpfr_float::default_precision(p
);
23 auto f
= [](Real x
)->Real
{ return x
*log(sin(x
)); };
24 auto integrator
= tanh_sinh
<mpfr_float
>();
25 Real Q
= integrator
.integrate(f
, Real(0), pi
<Real
>()/2);
26 // Sanity check: NIntegrate[x*Log[Sin[x]],{x,0,Pi/2}] = -0.329236
27 Real expected
= (7*zeta_three
<Real
>() - pi
<Real
>()*pi
<Real
>()*log(static_cast<Real
>(4)))/16;
28 CHECK_ULP_CLOSE(expected
, Q
, 3);
29 return boost::math::test::report_errors();