]>
Commit | Line | Data |
---|---|---|
20effc67 TL |
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> | |
10 | ||
11 | using std::log; | |
12 | using std::sin; | |
13 | using std::abs; | |
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; | |
18 | ||
19 | int main() { | |
20 | using Real = mpfr_float; | |
21 | int p = 100; | |
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(); | |
1e59de90 | 30 | } |