]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/math/test/tanh_sinh_mpfr.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / math / test / tanh_sinh_mpfr.cpp
CommitLineData
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
11using std::log;
12using std::sin;
13using std::abs;
14using boost::math::quadrature::tanh_sinh;
15using boost::multiprecision::mpfr_float;
16using boost::math::constants::pi;
17using boost::math::constants::zeta_three;
18
19int 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}