]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | <html> |
2 | <head> | |
3 | <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> | |
4 | <title>FAQs</title> | |
5 | <link rel="stylesheet" href="../math.css" type="text/css"> | |
6 | <meta name="generator" content="DocBook XSL Stylesheets V1.77.1"> | |
7 | <link rel="home" href="../index.html" title="Math Toolkit 2.5.1"> | |
8 | <link rel="up" href="../constants.html" title="Chapter 4. Mathematical Constants"> | |
9 | <link rel="prev" href="new_const.html" title="Defining New Constants"> | |
10 | <link rel="next" href="../dist.html" title="Chapter 5. Statistical Distributions and Functions"> | |
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="new_const.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="../dist.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_faq"></a><a class="link" href="constants_faq.html" title="FAQs">FAQs</a> | |
28 | </h2></div></div></div> | |
29 | <h5> | |
30 | <a name="math_toolkit.constants_faq.h0"></a> | |
31 | <span class="phrase"><a name="math_toolkit.constants_faq.why_are_these_constants_chosen"></a></span><a class="link" href="constants_faq.html#math_toolkit.constants_faq.why_are_these_constants_chosen">Why are | |
32 | <span class="emphasis"><em>these</em></span> Constants Chosen?</a> | |
33 | </h5> | |
34 | <p> | |
35 | It is, of course, impossible to please everyone with a list like this. | |
36 | </p> | |
37 | <p> | |
38 | Some of the criteria we have used are: | |
39 | </p> | |
40 | <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> | |
41 | <li class="listitem"> | |
42 | Used in Boost.Math. | |
43 | </li> | |
44 | <li class="listitem"> | |
45 | Commonly used. | |
46 | </li> | |
47 | <li class="listitem"> | |
48 | Expensive to compute. | |
49 | </li> | |
50 | <li class="listitem"> | |
51 | Requested by users. | |
52 | </li> | |
53 | <li class="listitem"> | |
54 | <a href="http://en.wikipedia.org/wiki/Mathematical_constant" target="_top">Used in | |
55 | science and mathematics.</a> | |
56 | </li> | |
57 | <li class="listitem"> | |
58 | No integer values (because so cheap to construct).<br> (You can easily | |
59 | define your own if found convenient, for example: <code class="computeroutput"><span class="identifier">FPT</span> | |
60 | <span class="identifier">one</span> <span class="special">=</span><span class="keyword">static_cast</span><span class="special"><</span><span class="identifier">FPT</span><span class="special">>(</span><span class="number">42</span><span class="special">);</span></code>). | |
61 | </li> | |
62 | </ul></div> | |
63 | <h5> | |
64 | <a name="math_toolkit.constants_faq.h1"></a> | |
65 | <span class="phrase"><a name="math_toolkit.constants_faq.how_are_constants_named"></a></span><a class="link" href="constants_faq.html#math_toolkit.constants_faq.how_are_constants_named">How | |
66 | are constants named?</a> | |
67 | </h5> | |
68 | <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> | |
69 | <li class="listitem"> | |
70 | Not macros, so no upper case. | |
71 | </li> | |
72 | <li class="listitem"> | |
73 | All lower case (following C++ standard names). | |
74 | </li> | |
75 | <li class="listitem"> | |
76 | No CamelCase. | |
77 | </li> | |
78 | <li class="listitem"> | |
79 | Underscore as _ delimiter between words. | |
80 | </li> | |
81 | <li class="listitem"> | |
82 | Numbers spelt as words rather than decimal digits (except following pow). | |
83 | </li> | |
84 | <li class="listitem"> | |
85 | Abbreviation conventions: | |
86 | <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "> | |
87 | <li class="listitem"> | |
88 | root for square root. | |
89 | </li> | |
90 | <li class="listitem"> | |
91 | cbrt for cube root. | |
92 | </li> | |
93 | <li class="listitem"> | |
94 | pow for pow function using decimal digits like pow23 for n<sup>2/3</sup>. | |
95 | </li> | |
96 | <li class="listitem"> | |
97 | div for divided by or operator /. | |
98 | </li> | |
99 | <li class="listitem"> | |
100 | minus for operator -, plus for operator +. | |
101 | </li> | |
102 | <li class="listitem"> | |
103 | sqr for squared. | |
104 | </li> | |
105 | <li class="listitem"> | |
106 | cubed for cubed n<sup>3</sup>. | |
107 | </li> | |
108 | <li class="listitem"> | |
109 | words for greek, like π, ζ and Γ. | |
110 | </li> | |
111 | <li class="listitem"> | |
112 | words like half, third, three_quarters, sixth for fractions. (Digit(s) | |
113 | can get muddled). | |
114 | </li> | |
115 | <li class="listitem"> | |
116 | log10 for log<sub>10</sub> | |
117 | </li> | |
118 | <li class="listitem"> | |
119 | ln for log<sub>e</sub> | |
120 | </li> | |
121 | </ul></div> | |
122 | </li> | |
123 | </ul></div> | |
124 | <h5> | |
125 | <a name="math_toolkit.constants_faq.h2"></a> | |
126 | <span class="phrase"><a name="math_toolkit.constants_faq.how_are_the_constants_derived"></a></span><a class="link" href="constants_faq.html#math_toolkit.constants_faq.how_are_the_constants_derived">How are | |
127 | the constants derived?</a> | |
128 | </h5> | |
129 | <p> | |
130 | The constants have all been calculated using high-precision software working | |
131 | with up to 300-bit precision giving about 100 decimal digits. (The precision | |
132 | can be arbitrarily chosen and is limited only by compute time). | |
133 | </p> | |
134 | <h5> | |
135 | <a name="math_toolkit.constants_faq.h3"></a> | |
136 | <span class="phrase"><a name="math_toolkit.constants_faq.how_accurate_are_the_constants"></a></span><a class="link" href="constants_faq.html#math_toolkit.constants_faq.how_accurate_are_the_constants">How Accurate | |
137 | are the constants?</a> | |
138 | </h5> | |
139 | <p> | |
140 | The minimum accuracy chosen (100 decimal digits) exceeds the accuracy of reasonably-foreseeable | |
141 | floating-point hardware (256-bit) and should meet most high-precision computations. | |
142 | </p> | |
143 | <h5> | |
144 | <a name="math_toolkit.constants_faq.h4"></a> | |
145 | <span class="phrase"><a name="math_toolkit.constants_faq.how_are_the_constants_tested"></a></span><a class="link" href="constants_faq.html#math_toolkit.constants_faq.how_are_the_constants_tested">How are the | |
146 | constants tested?</a> | |
147 | </h5> | |
148 | <div class="orderedlist"><ol class="orderedlist" type="1"> | |
149 | <li class="listitem"> | |
150 | Comparison using Boost.Test BOOST_CHECK_CLOSE_FRACTION using long double | |
151 | literals, with at least 35 decimal digits, enough to be accurate for all | |
152 | long double implementations. The tolerance is usually twice <code class="computeroutput"><span class="keyword">long</span> <span class="keyword">double</span> <span class="identifier">epsilon</span></code>. | |
153 | </li> | |
154 | <li class="listitem"> | |
155 | Comparison with calculation at long double precision. This often requires | |
156 | a slightly higher tolerance than two epsilon because of computational noise | |
157 | from round-off etc, especially when trig and other functions are called. | |
158 | </li> | |
159 | <li class="listitem"> | |
160 | Comparison with independent published values, for example, using <a href="http://oeis.org/" target="_top">The On-Line Encyclopedia of Integer Sequences (OEIS)</a> | |
161 | again using at least 35 decimal digits strings. | |
162 | </li> | |
163 | <li class="listitem"> | |
164 | Comparison with independely calculated values using arbitrary precision | |
165 | tools like <a href="http://www.wolfram.com/mathematica/" target="_top">Mathematica</a>, | |
166 | again using at least 35 decimal digits literal strings. | |
167 | </li> | |
168 | </ol></div> | |
169 | <div class="warning"><table border="0" summary="Warning"> | |
170 | <tr> | |
171 | <td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../../doc/src/images/warning.png"></td> | |
172 | <th align="left">Warning</th> | |
173 | </tr> | |
174 | <tr><td align="left" valign="top"><p> | |
175 | We have not yet been able to <span class="bold"><strong>check</strong></span> that | |
176 | <span class="bold"><strong>all</strong></span> constants are accurate at the full arbitrary | |
177 | precision, at present 100 decimal digits. But certain key values like <code class="computeroutput"><span class="identifier">e</span></code> and <code class="computeroutput"><span class="identifier">pi</span></code> | |
178 | appear to be accurate and internal consistencies suggest that others are | |
179 | this accurate too. | |
180 | </p></td></tr> | |
181 | </table></div> | |
182 | <h5> | |
183 | <a name="math_toolkit.constants_faq.h5"></a> | |
184 | <span class="phrase"><a name="math_toolkit.constants_faq.why_is_portability_important"></a></span><a class="link" href="constants_faq.html#math_toolkit.constants_faq.why_is_portability_important">Why is Portability | |
185 | important?</a> | |
186 | </h5> | |
187 | <p> | |
188 | Code written using math constants is easily portable even when using different | |
189 | floating-point types with differing precision. | |
190 | </p> | |
191 | <p> | |
192 | It is a mistake to expect that results of computations will be <span class="bold"><strong>identical</strong></span>, | |
193 | but you can achieve the <span class="bold"><strong>best accuracy possible for the | |
194 | floating-point type in use</strong></span>. | |
195 | </p> | |
196 | <p> | |
197 | This has no extra cost to the user, but reduces irritating, and often confusing | |
198 | and very hard-to-trace effects, caused by the intrinsically limited precision | |
199 | of floating-point calculations. | |
200 | </p> | |
201 | <p> | |
202 | A harmless symptom of this limit is a spurious least-significant digit; at | |
203 | worst, slightly inaccurate constants sometimes cause iterating algorithms to | |
204 | diverge wildly because internal comparisons just fail. | |
205 | </p> | |
206 | <h5> | |
207 | <a name="math_toolkit.constants_faq.h6"></a> | |
208 | <span class="phrase"><a name="math_toolkit.constants_faq.what_is_the_internal_format_of_t"></a></span><a class="link" href="constants_faq.html#math_toolkit.constants_faq.what_is_the_internal_format_of_t">What | |
209 | is the Internal Format of the constants, and why?</a> | |
210 | </h5> | |
211 | <p> | |
212 | See <a class="link" href="tutorial.html" title="Tutorial">tutorial</a> above for normal | |
213 | use, but this FAQ explains the internal details used for the constants. | |
214 | </p> | |
215 | <p> | |
216 | Constants are stored as 100 decimal digit values. However, some compilers do | |
217 | not accept decimal digits strings as long as this. So the constant is split | |
218 | into two parts, with the first containing at least 128-bit long double precision | |
219 | (35 decimal digits), and for consistency should be in scientific format with | |
220 | a signed exponent. | |
221 | </p> | |
222 | <p> | |
223 | The second part is the value of the constant expressed as a string literal, | |
224 | accurate to at least 100 decimal digits (in practice that means at least 102 | |
225 | digits). Again for consistency use scientific format with a signed exponent. | |
226 | </p> | |
227 | <p> | |
228 | For types with precision greater than a long double, then if T is constructible | |
229 | <code class="computeroutput"><span class="identifier">T</span> </code>is constructible from a | |
230 | <code class="computeroutput"><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span></code> then it's directly constructed from the string, | |
231 | otherwise we fall back on lexical_cast to convert to type <code class="computeroutput"><span class="identifier">T</span></code>. | |
232 | (Using a string is necessary because you can't use a numeric constant since | |
233 | even a <code class="computeroutput"><span class="keyword">long</span> <span class="keyword">double</span></code> | |
234 | might not have enough digits). | |
235 | </p> | |
236 | <p> | |
237 | So, for example, a constant like pi is internally defined as | |
238 | </p> | |
239 | <pre class="programlisting"><span class="identifier">BOOST_DEFINE_MATH_CONSTANT</span><span class="special">(</span><span class="identifier">pi</span><span class="special">,</span> <span class="number">3.141592653589793238462643383279502884e+00</span><span class="special">,</span> <span class="string">"3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651e+00"</span><span class="special">);</span> | |
240 | </pre> | |
241 | <p> | |
242 | In this case the significand is 109 decimal digits, ensuring 100 decimal digits | |
243 | are exact, and exponent is zero. | |
244 | </p> | |
245 | <p> | |
246 | See <a class="link" href="new_const.html" title="Defining New Constants">defining new constants</a> to | |
247 | calculate new constants. | |
248 | </p> | |
249 | <p> | |
250 | A macro definition like this can be pasted into user code where convenient, | |
251 | or into <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">constants</span><span class="special">.</span><span class="identifier">hpp</span></code> if it | |
252 | is to be added to the Boost.Math library. | |
253 | </p> | |
254 | <h5> | |
255 | <a name="math_toolkit.constants_faq.h7"></a> | |
256 | <span class="phrase"><a name="math_toolkit.constants_faq.what_floating_point_types_could_"></a></span><a class="link" href="constants_faq.html#math_toolkit.constants_faq.what_floating_point_types_could_">What | |
257 | Floating-point Types could I use?</a> | |
258 | </h5> | |
259 | <p> | |
260 | Apart from the built-in floating-point types <code class="computeroutput"><span class="keyword">float</span></code>, | |
261 | <code class="computeroutput"><span class="keyword">double</span></code>, <code class="computeroutput"><span class="keyword">long</span> | |
262 | <span class="keyword">double</span></code>, there are several arbitrary | |
263 | precision floating-point classes available, but most are not licensed for commercial | |
264 | use. | |
265 | </p> | |
266 | <h6> | |
267 | <a name="math_toolkit.constants_faq.h8"></a> | |
268 | <span class="phrase"><a name="math_toolkit.constants_faq.boost_multiprecision_by_christop"></a></span><a class="link" href="constants_faq.html#math_toolkit.constants_faq.boost_multiprecision_by_christop">Boost.Multiprecision | |
269 | by Christopher Kormanyos</a> | |
270 | </h6> | |
271 | <p> | |
272 | This work is based on an earlier work called e-float: Algorithm 910: A Portable | |
273 | C++ Multiple-Precision System for Special-Function Calculations, in ACM TOMS, | |
274 | {VOL 37, ISSUE 4, (February 2011)} (C) ACM, 2011. <a href="http://doi.acm.org/10.1145/1916461.1916469" target="_top">http://doi.acm.org/10.1145/1916461.1916469</a> | |
275 | <a href="https://svn.boost.org/svn/boost/sandbox/e_float/" target="_top">e_float</a> | |
276 | but is now re-factored and available under the Boost license in the Boost-sandbox | |
277 | at <a href="https://svn.boost.org/svn/boost/sandbox/multiprecision/" target="_top">multiprecision</a> | |
278 | where it is being refined and prepared for review. | |
279 | </p> | |
280 | <h6> | |
281 | <a name="math_toolkit.constants_faq.h9"></a> | |
282 | <span class="phrase"><a name="math_toolkit.constants_faq.boost_cpp_float_by_john_maddock_"></a></span><a class="link" href="constants_faq.html#math_toolkit.constants_faq.boost_cpp_float_by_john_maddock_">Boost.cpp_float | |
283 | by John Maddock using Expression Templates</a> | |
284 | </h6> | |
285 | <p> | |
286 | <a href="https://svn.boost.org/svn/boost/sandbox/big_number/" target="_top">Big Number</a> | |
287 | which is a reworking of <a href="https://svn.boost.org/svn/boost/sandbox/e_float/" target="_top">e_float</a> | |
288 | by Christopher Kormanyos to use expression templates for faster execution. | |
289 | </p> | |
290 | <h6> | |
291 | <a name="math_toolkit.constants_faq.h10"></a> | |
292 | <span class="phrase"><a name="math_toolkit.constants_faq.ntl_class_quad_float"></a></span><a class="link" href="constants_faq.html#math_toolkit.constants_faq.ntl_class_quad_float">NTL | |
293 | class quad_float</a> | |
294 | </h6> | |
295 | <p> | |
296 | <a href="http://shoup.net/ntl/" target="_top">NTL</a> by Victor Shoup has fixed and | |
297 | arbitrary high precision fixed and floating-point types. However none of these | |
298 | are licenced for commercial use. | |
299 | </p> | |
300 | <pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">NTL</span><span class="special">/</span><span class="identifier">quad_float</span><span class="special">.</span><span class="identifier">h</span><span class="special">></span> <span class="comment">// quad precision 106-bit, about 32 decimal digits.</span> | |
301 | <span class="keyword">using</span> <span class="identifier">NTL</span><span class="special">::</span><span class="identifier">to_quad_float</span><span class="special">;</span> <span class="comment">// Less precise than arbitrary precision NTL::RR.</span> | |
302 | </pre> | |
303 | <p> | |
304 | NTL class <code class="computeroutput"><span class="identifier">quad_float</span></code>, which | |
305 | gives a form of quadruple precision, 106-bit significand (but without an extended | |
306 | exponent range.) With an IEC559/IEEE 754 compatible processor, for example | |
307 | Intel X86 family, with 64-bit double, and 53-bit significand, using the significands | |
308 | of <span class="bold"><strong>two</strong></span> 64-bit doubles, if <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special"><</span><span class="keyword">double</span><span class="special">>::</span><span class="identifier">digits10</span></code> is 16, then we get about twice the | |
309 | precision, so <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special"><</span><span class="identifier">quad_float</span><span class="special">>::</span><span class="identifier">digits10</span><span class="special">()</span></code> | |
310 | should be 32. (the default <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special"><</span><span class="identifier">RR</span><span class="special">>::</span><span class="identifier">digits10</span><span class="special">()</span></code> | |
311 | should be about 40). (which seems to agree with experiments). We output constants | |
312 | (including some noisy bits, an approximation to <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special"><</span><span class="identifier">RR</span><span class="special">>::</span><span class="identifier">max_digits10</span><span class="special">()</span></code>) | |
313 | by adding 2 or 3 extra decimal digits, so using <code class="computeroutput"><span class="identifier">quad_float</span><span class="special">::</span><span class="identifier">SetOutputPrecision</span><span class="special">(</span><span class="number">32</span> <span class="special">+</span> | |
314 | <span class="number">3</span><span class="special">);</span></code> | |
315 | </p> | |
316 | <p> | |
317 | Apple Mac/Darwin uses a similar <span class="emphasis"><em>doubledouble</em></span> 106-bit for | |
318 | its built-in <code class="computeroutput"><span class="keyword">long</span> <span class="keyword">double</span></code> | |
319 | type. | |
320 | </p> | |
321 | <div class="note"><table border="0" summary="Note"> | |
322 | <tr> | |
323 | <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/src/images/note.png"></td> | |
324 | <th align="left">Note</th> | |
325 | </tr> | |
326 | <tr><td align="left" valign="top"><p> | |
327 | The precision of all <code class="computeroutput"><span class="identifier">doubledouble</span></code> | |
328 | floating-point types is rather odd and values given are only approximate. | |
329 | </p></td></tr> | |
330 | </table></div> | |
331 | <p> | |
332 | <span class="bold"><strong>New projects should use <a href="../../../../../libs/multiprecision/doc/html/index.html" target="_top">Boost.Multiprecision</a>.</strong></span> | |
333 | </p> | |
334 | <h6> | |
335 | <a name="math_toolkit.constants_faq.h11"></a> | |
336 | <span class="phrase"><a name="math_toolkit.constants_faq.ntl_class_rr"></a></span><a class="link" href="constants_faq.html#math_toolkit.constants_faq.ntl_class_rr">NTL | |
337 | class RR</a> | |
338 | </h6> | |
339 | <p> | |
340 | Arbitrary precision floating point with NTL class RR, default is 150 bit (about | |
341 | 50 decimal digits) used here with 300 bit to output 100 decimal digits, enough | |
342 | for many practical non-'number-theoretic' C++ applications. | |
343 | </p> | |
344 | <p> | |
345 | <a href="http://www.shoup.net/ntl/" target="_top">NTL A Library for doing Number Theory</a> | |
346 | is <span class="bold"><strong>not licenced for commercial use</strong></span>. | |
347 | </p> | |
348 | <p> | |
349 | This class is used in Boost.Math and is an option when using big_number projects | |
350 | to calculate new math constants. | |
351 | </p> | |
352 | <p> | |
353 | <span class="bold"><strong>New projects should use <a href="../../../../../libs/multiprecision/doc/html/index.html" target="_top">Boost.Multiprecision</a>.</strong></span> | |
354 | </p> | |
355 | <h6> | |
356 | <a name="math_toolkit.constants_faq.h12"></a> | |
357 | <span class="phrase"><a name="math_toolkit.constants_faq.gmp_and_mpfr"></a></span><a class="link" href="constants_faq.html#math_toolkit.constants_faq.gmp_and_mpfr">GMP | |
358 | and MPFR</a> | |
359 | </h6> | |
360 | <p> | |
361 | <a href="http://gmplib.org" target="_top">GMP</a> and <a href="http://www.mpfr.org/" target="_top">MPFR</a> | |
362 | have also been used to compute constants, but are licensed under the <a href="http://www.gnu.org/copyleft/lesser.html" target="_top">Lesser GPL license</a> and | |
363 | are <span class="bold"><strong>not licensed for commercial use</strong></span>. | |
364 | </p> | |
365 | <h5> | |
366 | <a name="math_toolkit.constants_faq.h13"></a> | |
367 | <span class="phrase"><a name="math_toolkit.constants_faq.what_happened_to_a_previous_coll"></a></span><a class="link" href="constants_faq.html#math_toolkit.constants_faq.what_happened_to_a_previous_coll">What | |
368 | happened to a previous collection of constants proposed for Boost?</a> | |
369 | </h5> | |
370 | <p> | |
371 | A review concluded that the way in which the constants were presented did not | |
372 | meet many peoples needs. None of the methods proposed met many users' essential | |
373 | requirement to allow writing simply <code class="computeroutput"><span class="identifier">pi</span></code> | |
374 | rather than <code class="computeroutput"><span class="identifier">pi</span><span class="special">()</span></code>. | |
375 | Many science and engineering equations look difficult to read when because | |
376 | function call brackets can be confused with the many other brackets often needed. | |
377 | All the methods then proposed of avoiding the brackets failed to meet all needs, | |
378 | often on grounds of complexity and lack of applicability to various realistic | |
379 | scenarios. | |
380 | </p> | |
381 | <p> | |
382 | So the simple namespace method, proposed on its own, but rejected at the first | |
383 | review, has been added to allow users to have convenient access to float, double | |
384 | and long double values, but combined with template struct and functions to | |
385 | allow simultaneous use with other non-built-in floating-point types. | |
386 | </p> | |
387 | <h5> | |
388 | <a name="math_toolkit.constants_faq.h14"></a> | |
389 | <span class="phrase"><a name="math_toolkit.constants_faq.why_do_the_constants_internally_"></a></span><a class="link" href="constants_faq.html#math_toolkit.constants_faq.why_do_the_constants_internally_">Why do | |
390 | the constants (internally) have a struct rather than a simple function?</a> | |
391 | </h5> | |
392 | <p> | |
393 | A function mechanism was provided by in previous versions of Boost.Math. | |
394 | </p> | |
395 | <p> | |
396 | The new mechanism is to permit partial specialization. See Custom Specializing | |
397 | a constant above. It should also allow use with other packages like <a href="http://www.ttmath.org/" target="_top">ttmath Bignum C++ library.</a> | |
398 | </p> | |
399 | <h5> | |
400 | <a name="math_toolkit.constants_faq.h15"></a> | |
401 | <span class="phrase"><a name="math_toolkit.constants_faq.where_can_i_find_other_high_prec"></a></span><a class="link" href="constants_faq.html#math_toolkit.constants_faq.where_can_i_find_other_high_prec">Where | |
402 | can I find other high precision constants?</a> | |
403 | </h5> | |
404 | <div class="orderedlist"><ol class="orderedlist" type="1"> | |
405 | <li class="listitem"> | |
406 | Constants with very high precision and good accuracy (>40 decimal digits) | |
407 | from Simon Plouffe's web based collection <a href="http://pi.lacim.uqam.ca/eng/" target="_top">http://pi.lacim.uqam.ca/eng/</a>. | |
408 | </li> | |
409 | <li class="listitem"> | |
410 | <a href="https://oeis.org/" target="_top">The On-Line Encyclopedia of Integer Sequences | |
411 | (OEIS)</a> | |
412 | </li> | |
413 | <li class="listitem"> | |
414 | Checks using printed text optically scanned values and converted from: | |
415 | D. E. Knuth, Art of Computer Programming, Appendix A, Table 1, Vol 1, ISBN | |
416 | 0 201 89683 4 (1997) | |
417 | </li> | |
418 | <li class="listitem"> | |
419 | M. Abrahamovitz & I. E. Stegun, National Bureau of Standards, Handbook | |
420 | of Mathematical Functions, a reference source for formulae now superceded | |
421 | by | |
422 | </li> | |
423 | <li class="listitem"> | |
424 | Frank W. Olver, Daniel W. Lozier, Ronald F. Boisvert, Charles W. Clark, | |
425 | NIST Handbook of Mathemetical Functions, Cambridge University Press, ISBN | |
426 | 978-0-521-14063-8, 2010. | |
427 | </li> | |
428 | <li class="listitem"> | |
429 | John F Hart, Computer Approximations, Kreiger (1978) ISBN 0 88275 642 7. | |
430 | </li> | |
431 | <li class="listitem"> | |
432 | Some values from Cephes Mathematical Library, Stephen L. Moshier and CALC100 | |
433 | 100 decimal digit Complex Variable Calculator Program, a DOS utility. | |
434 | </li> | |
435 | <li class="listitem"> | |
436 | Xavier Gourdon, Pascal Sebah, 50 decimal digits constants at <a href="http://numbers.computation.free.fr/Constants/constants.html" target="_top">Number, | |
437 | constants and computation</a>. | |
438 | </li> | |
439 | </ol></div> | |
440 | <h5> | |
441 | <a name="math_toolkit.constants_faq.h16"></a> | |
442 | <span class="phrase"><a name="math_toolkit.constants_faq.where_are_physical_constants"></a></span><a class="link" href="constants_faq.html#math_toolkit.constants_faq.where_are_physical_constants">Where are | |
443 | Physical Constants?</a> | |
444 | </h5> | |
445 | <p> | |
446 | Not here in this Boost.Math collection, because physical constants: | |
447 | </p> | |
448 | <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> | |
449 | <li class="listitem"> | |
450 | Are measurements, not truely constants. | |
451 | </li> | |
452 | <li class="listitem"> | |
453 | Are not truly constant and keeping changing as mensuration technology improves. | |
454 | </li> | |
455 | <li class="listitem"> | |
456 | Have a instrinsic uncertainty. | |
457 | </li> | |
458 | <li class="listitem"> | |
459 | Mathematical constants are stored and represented at varying precision, | |
460 | but should never be inaccurate. | |
461 | </li> | |
462 | </ul></div> | |
463 | <p> | |
464 | Some physical constants may be available in Boost.Units. | |
465 | </p> | |
466 | </div> | |
467 | <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> | |
468 | <td align="left"></td> | |
469 | <td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal, | |
470 | Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert | |
471 | Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani, | |
472 | Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p> | |
473 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
474 | 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>) | |
475 | </p> | |
476 | </div></td> | |
477 | </tr></table> | |
478 | <hr> | |
479 | <div class="spirit-nav"> | |
480 | <a accesskey="p" href="new_const.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="../dist.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> | |
481 | </div> | |
482 | </body> | |
483 | </html> |