Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / math / doc / html / math_toolkit / constants_intro.html
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Introduction</title>
5 <link rel="stylesheet" href="../math.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="../index.html" title="Math Toolkit 2.11.0">
8 <link rel="up" href="../constants.html" title="Chapter&#160;4.&#160;Mathematical Constants">
9 <link rel="prev" href="../constants.html" title="Chapter&#160;4.&#160;Mathematical Constants">
10 <link rel="next" href="tutorial.html" title="Tutorial">
11 </head>
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
15 <td align="center"><a href="../../../../../index.html">Home</a></td>
16 <td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../../../../more/index.htm">More</a></td>
20 </tr></table>
21 <hr>
22 <div class="spirit-nav">
23 <a accesskey="p" href="../constants.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../constants.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="tutorial.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
24 </div>
25 <div class="section">
26 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
27 <a name="math_toolkit.constants_intro"></a><a class="link" href="constants_intro.html" title="Introduction">Introduction</a>
28 </h2></div></div></div>
29 <p>
30       Boost.Math provides a collection of mathematical constants.
31     </p>
32 <h5>
33 <a name="math_toolkit.constants_intro.h0"></a>
34       <span class="phrase"><a name="math_toolkit.constants_intro.why_use_boost_math_mathematical_"></a></span><a class="link" href="constants_intro.html#math_toolkit.constants_intro.why_use_boost_math_mathematical_">Why
35       use Boost.Math mathematical constants?</a>
36     </h5>
37 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
38 <li class="listitem">
39 <p class="simpara">
40           Readable. For the very many jobs just using built-in like <code class="computeroutput"><span class="keyword">double</span></code>, you can just write expressions like
41         </p>
42 <pre class="programlisting"><span class="keyword">double</span> <span class="identifier">area</span> <span class="special">=</span> <span class="identifier">pi</span> <span class="special">*</span> <span class="identifier">r</span> <span class="special">*</span> <span class="identifier">r</span><span class="special">;</span></pre>
43 <p class="simpara">
44           (If that's all you want, jump direct to <a class="link" href="tutorial/non_templ.html" title="Use in non-template code">use
45           in non-template code</a>!)
46         </p>
47 </li>
48 <li class="listitem">
49           Effortless - avoiding a search of reference sources.
50         </li>
51 <li class="listitem">
52           Usable with both builtin floating point types, and user-defined, possibly
53           extended precision, types such as NTL, MPFR/GMP, mp_float: in the latter
54           case the constants are computed to the necessary precision and then cached.
55         </li>
56 <li class="listitem">
57           Accurate - ensuring that the values are as accurate as possible for the
58           chosen floating-point type
59           <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
60 <li class="listitem">
61                 No loss of accuracy from repeated rounding of intermediate computations.
62               </li>
63 <li class="listitem">
64                 Result is computed with higher precision and only rounded once.
65               </li>
66 <li class="listitem">
67                 Less risk of inaccurate result from functions pow, trig and log at
68                 <a href="http://en.wikipedia.org/wiki/Corner_case" target="_top">corner cases</a>.
69               </li>
70 <li class="listitem">
71                 Less risk of <a href="http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html" target="_top">cancellation
72                 error</a>.
73               </li>
74 </ul></div>
75         </li>
76 <li class="listitem">
77           Portable - as possible between different systems using different floating-point
78           precisions: see <a class="link" href="tutorial/templ.html" title="Use in template code">use in template
79           code</a>.
80         </li>
81 <li class="listitem">
82           Tested - by comparison with other published sources, or separately computed
83           at long double precision.
84         </li>
85 <li class="listitem">
86 <p class="simpara">
87           Faster - can avoid (re-)calculation at runtime.
88           <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
89 <li class="listitem">
90                 If the value returned is a builtin type then it's returned by value
91                 as a <code class="computeroutput"><span class="keyword">constexpr</span></code> (C++11
92                 feature, if available).
93               </li>
94 <li class="listitem">
95                 If the value is computed and cached (or constructed from a string
96                 representation and cached), then it's returned by constant reference.
97               </li>
98 </ul></div>
99         </p>
100 <p class="simpara">
101           This can be significant if:
102         </p>
103 <p class="simpara">
104           <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
105 <li class="listitem">
106                 Functions pow, trig or log are used.
107               </li>
108 <li class="listitem">
109                 Inside an inner loop.
110               </li>
111 <li class="listitem">
112                 Using a high-precision UDT like <a href="../../../../../libs/multiprecision/doc/html/index.html" target="_top">Boost.Multiprecision</a>.
113               </li>
114 <li class="listitem">
115                 Compiler optimizations possible with built-in types, especially
116                 <code class="computeroutput"><span class="keyword">double</span></code>, are not available.
117               </li>
118 </ul></div>
119         </p>
120 </li>
121 </ul></div>
122 </div>
123 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
124 <td align="left"></td>
125 <td align="right"><div class="copyright-footer">Copyright &#169; 2006-2019 Nikhar
126       Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
127       Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan
128       R&#229;de, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg,
129       Daryle Walker and Xiaogang Zhang<p>
130         Distributed under the Boost Software License, Version 1.0. (See accompanying
131         file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
132       </p>
133 </div></td>
134 </tr></table>
135 <hr>
136 <div class="spirit-nav">
137 <a accesskey="p" href="../constants.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../constants.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="tutorial.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
138 </div>
139 </body>
140 </html>