[section pow] [section Rationale] Computing the power of a number with an exponent that is fixed and known in advance is a common need for programmers. In such cases, the usual method is to avoid the overhead implied by the pow, powf and powl C functions by hardcoding the expression: [h4] // Hand-written 8th power of a 'base' variable double result = base*base*base*base*base*base*base*base; However, this kind of expression is not really readable (knowing the value of the exponent involves counting the number of occurences of 'base'), error-prone (it's easy to forget an occurence), syntactically bulky, and non-optimal in terms of performance. The pow function of Boost.Math helps writing this kind expression along with solving all the problems listed above: [h4] // 8th power of a 'base' variable using math::pow double result = pow<8>(base); The expression is now shorter, easier to read, safer, and even faster. Indeed, pow will compute the expression such that only log2(N) products are made for a power of N. For instance in the example above, the resulting expression will be the same as if we had written this, with only one computation of each identical subexpression : [h4] // Internal effect of pow<8>(base) double result = ((base*base)*(base*base))*((base*base)*(base*base)); Only 3 different products were actually computed. [endsect] [section Header File] This function can be used by including [@../../boost/math/pow.hpp pow.hpp]. [endsect] [section Synopsis] [h4] namespace boost { namespace math { template double pow(T base); } } [endsect] [section Acknowledgements] Thanks to Joaquín López Muñoz and Scott McMurray for their help in improving the implementation. [endsect] [endsect]