...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
#include <boost/math/special_functions/powm1.hpp>
namespace boost{ namespace math{ template <class T1, class T2> calculatedresulttype powm1(T1 x, T2 y); template <class T1, class T2, class Policy> calculatedresulttype powm1(T1 x, T2 y, const Policy&); }} // namespaces
Returns x^{y }  1.
The return type of this function is computed using the result type calculation rules when T1 and T2 are dufferent types.
The final Policy argument is optional and can be used to control the behaviour of the function: how it handles errors, what level of precision to use etc. Refer to the policy documentation for more details.
There are two domains where this is useful: when y is very small, or when x is close to 1.
Implemented in terms of expm1
.
The following graph illustrates the behaviour of powm1:
Should have approximately 23 epsilon accuracy.
Table 6.82. Error rates for powm1
Microsoft Visual C++ version 12.0 
GNU C++ version 5.1.0 
GNU C++ version 5.1.0 
Sun compiler version 0x5130 


powm1 
Max = 1.99ε (Mean = 0.461ε) 
Max = 1.26ε (Mean = 0.428ε) 
Max = 2.04ε (Mean = 0.521ε) 
Max = 2.14ε (Mean = 0.498ε) 
A selection of random high precision test values calculated using NTL::RR at 1000bit precision.