
Boost : 
From: Paul A. Bristow (boost_at_[hidden])
Date: 20011106 15:27:55
Here are some suggested constants, in three groups:
1 Basic math constants. The absolute minimum?
2 More, and some derived math constants.
3 More obscure (but essential for some people) math constants.
I have indicated some rationale for including each one,
drawing on the 'authority' of 3 texts:
1 Knuth, Art of Computer Programming,
2 John Hart, Computer Approximations, and
3 Stephen Moshier, Math Functions, mathlib
4 Morris, ACM 715 & Brown CDFlib collection of math functions used in
statistics.
as a guide to what has been used in typical math work.
Although there was some discussion and many disagreements,
in the end I have generally stuck to the naming scheme I proposed earlier.
I still prefer ln to log, but C99 seems to use log for ln and log10,
so I am persauded to reluctantly follow this.
I have yet to find a nicer way of describing reciprocal than one_div_...
Any ideas? Is reciprocal_sqrt_2 better than one_div_sqrt_2 ?
All the sqrt, log, trig and pow functions are liable to be inaccurate,
(seriously inaccurate at times)
and all lead to runtime code which is most unlikely to be optimised.
I indicate this by saying for example 'avoid log(pi)'.
Please object (Boosters are really, really expert at this!)
and suggest others (your pet constant!) that are missing.
Is the .hpp naming scheme sensible, if boring?
1 Basic math_constants.hpp
pi
log_pi  avoid log(pi)
sqrt_2  avoid sqrt(2.)
sqrt_3
sqrt_10
cbrt_2  avoid pow (but follow cbrt C99 naming convention, even if ugly!)
cbrt_3  avoid pow
fourth_root_2  avoid pow
log_2  avoid log(2.)
log_3
log_4  avoid log(4.)
log_10  avoid log(10.)
log_e  avoid log(e)
log_pi  avoid log(pi)
log_two_pi  avoid log(2.*pi)
one_div_log_2
one_div_log_10
one_div_pi  accuracy.
sqrt(1_div_pi)  avoid sqrt
sqrt_10  avoid sqrt(10.)
sqrt_pi  avoid sqrt == gamma_half
log_sqrt_two_pi  avoid log and sqrt
log10_2  avoid possible log and *
log10_e 
2 Additional in math_constants2.hpp
Some of these may be calculated accurately by the compiler,
but are good for clear programs,
and avoid any runtime code for debug and/or lessoptimised code.
half_pi  convenient and commonly used (even if compiler should get it
exact).
quarter_pi  convenient and commonly used (even if compiler should get it
exact).
two_pi  convenient and commonly used(even if compiler should get it exact).
half_sqrt_2  convenient and commonly used(even if compiler should get it
exact).
one_div_sqrt_2 
one_div_sqrt_two_pi
two_pow_two_thirds  avoid pow
two_div_pi  commonly used(even if compiler should get it exactly from
one_div_pi).
three_quarters_pi  for accuracy (or three_pi_div_4?)
one_div_pi 
pi_squared  accuracy
log_2_div_2  avoid log(2)
e_squared  accuracy
one_div_e
pi_div_180
two_pow_2_div_3  avoid pow
log_log_2  avoid log, twice!
phi  golden ratio
euler
a handful of real constants (1. NOT 1  useful)
one
two
three
four
ten
half
third  accuracy?
two_thirds  accuracy?
quarter
3 Obscure in math_constants3.hpp
cbrt_10
sqrt_5
sqrt_32
sin_0
cos_0
tan_0
sin_1
cos_1
tan_1
sin_half
cos_half
tan_half
log_euler
one_div_euler
one_div_log_euler
gamma_third
gamma_two_thirds
gamma_sixth
gamma_min_at  1.46...
gamma_min  0.88560...
e_pow_euler  avoid pow
e_pow_quarter_pi
e_pow_pi
pi_pow_e
zeta_three ?
Paul
Dr Paul A Bristow, hetp Chromatography
Prizet Farmhouse
Kendal, Cumbria
LA8 8AB UK
+44 1539 561830
Mobile +44 7714 33 02 04
mailto:pbristow_at_[hidden]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk