Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

powm1

#include <boost/math/special_functions/powm1.hpp>

namespace boost{ namespace math{

template <class T1, class T2>
calculated-result-type powm1(T1 x, T2 y);

template <class T1, class T2, class Policy>
calculated-result-type powm1(T1 x, T2 y, const Policy&);

}} // namespaces

Returns xy - 1.

The return type of this function is computed using the result type calculation rules when T1 and T2 are different 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.

Note that for invalid input this function may raise a domain_error or overflow_error as appropriate.

Implemented in terms of expm1.

The following graph illustrates the behaviour of powm1:

Accuracy

Should have approximately 2-3 epsilon accuracy.

Table 8.85. Error rates for powm1

GNU C++ version 7.1.0
linux
double

GNU C++ version 7.1.0
linux
long double

Sun compiler version 0x5150
Sun Solaris
long double

Microsoft Visual C++ version 14.1
Win32
double

powm1

Max = 1.06ε (Mean = 0.425ε)

Max = 2.04ε (Mean = 0.493ε)

Max = 1.88ε (Mean = 0.49ε)

Max = 1.84ε (Mean = 0.486ε)


Testing

A selection of random high precision test values calculated using NTL::RR at 1000-bit precision.


PrevUpHomeNext