]>
Commit | Line | Data |
---|---|---|
20effc67 TL |
1 | // (C) Copyright Nick Thompson 2020. |
2 | // Use, modification and distribution are subject to the | |
3 | // Boost Software License, Version 1.0. (See accompanying file | |
4 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
1e59de90 | 5 | #include <cmath> |
20effc67 | 6 | #include <iostream> |
1e59de90 | 7 | #include <iomanip> |
20effc67 TL |
8 | #include <boost/math/tools/agm.hpp> |
9 | #include <boost/math/constants/constants.hpp> | |
1e59de90 TL |
10 | |
11 | #ifndef BOOST_MATH_STANDALONE | |
20effc67 | 12 | #include <boost/multiprecision/cpp_bin_float.hpp> |
1e59de90 | 13 | #endif |
20effc67 TL |
14 | |
15 | // This example computes the lemniscate constant to high precision using the agm: | |
16 | using boost::math::tools::agm; | |
17 | using boost::math::constants::pi; | |
18 | ||
19 | int main() { | |
1e59de90 TL |
20 | using std::sqrt; |
21 | ||
22 | #ifndef BOOST_MATH_STANDALONE | |
20effc67 | 23 | using Real = boost::multiprecision::cpp_bin_float_100; |
1e59de90 TL |
24 | #else |
25 | using Real = long double; | |
26 | #endif | |
27 | ||
20effc67 TL |
28 | Real G = agm(sqrt(Real(2)), Real(1)); |
29 | std::cout << std::setprecision(std::numeric_limits<Real>::max_digits10); | |
30 | std::cout << " Gauss's lemniscate constant = " << pi<Real>()/G << "\n"; | |
31 | std::cout << "Expected lemniscate constant = " << "2.62205755429211981046483958989111941368275495143162316281682170380079058707041425023029553296142909344613\n"; | |
32 | } |