| [section:constants Numeric Constants] |
| |
| [h4 Synopsis] |
| |
| `` |
| #include <boost/math/constants/constants.hpp> |
| `` |
| |
| namespace boost{ namespace math{ namespace constants{ |
| |
| template <class T> T pi(); |
| template <class T> T root_pi(); |
| template <class T> T root_half_pi(); |
| template <class T> T root_two_pi(); |
| template <class T> T root_ln_four(); |
| template <class T> T e(); |
| template <class T> T half(); |
| template <class T> T euler(); |
| template <class T> T root_two(); |
| template <class T> T ln_two(); |
| template <class T> T ln_ln_two(); |
| template <class T> T third(); |
| template <class T> T twothirds(); |
| template <class T> T pi_minus_three(); |
| template <class T> T four_minus_pi(); |
| |
| }}} // namespaces |
| |
| [h4 Description] |
| |
| The header `boost/math/constants/constants.hpp` contains some numeric constants |
| that we have found useful in the development of this library. New constants are |
| added on an ad-hoc basis based on need. |
| |
| Usage is like this: |
| |
| template <class T> |
| T circumference(T r) |
| { |
| return 2 * boost::math::constants::pi<T>() * r; |
| } |
| |
| All the constants are accurate to at least the 34 decimal digits required for 128-bit |
| long doubles, and most are accurate to 100 digits or more when used with |
| a suitable arbitrary precision type. |
| |
| The following table summarises the constants we have at present: |
| |
| [table |
| [[Constant][Meaning][Value]] |
| [[pi][[pi]][3.1415926535897932384...]] |
| [[root_pi][[radic][pi]][1.772453850905516027...]] |
| [[root_half_pi][[radic]([pi]/2)][1.253314137315500251...]] |
| [[root_two_pi][[radic](2*[pi])][2.506628274631000502...]] |
| [[root_ln_four][[radic](ln(4))][1.17741002251547469...]] |
| [[e][['e]][2.71828182845904523536...]] |
| [[half][0.5][0.5]] |
| [[euler][Euler's constant][0.577215664901532860606]] |
| [[root_two][[radic]2][1.4142135623730950488...]] |
| [[ln_two][ln(2)][0.6931471805599453094...]] |
| [[ln_ln_two][ln(ln(2))][-0.3665129205816643...]] |
| [[third][1/3][0.333333333333333333...]] |
| [[twothirds][2/3][0.666666666666666666...]] |
| [[pi_minus_three][[pi]-3][0.14159265358979323846...]] |
| [[four_minus_pi][4-[pi]][0.85840734641020676153735...]] |
| ] |
| |
| [endsect][/section Numeric Constants] |
| |
| [/ |
| Copyright 2008 John Maddock and Paul A. Bristow. |
| Distributed under the Boost Software License, Version 1.0. |
| (See accompanying file LICENSE_1_0.txt or copy at |
| http://www.boost.org/LICENSE_1_0.txt). |
| ] |