![]() |
Home | Libraries | People | FAQ | More |
#include <boost/math/special_functions/pow1p.hpp> namespace boost { namespace math { template <typename T1, typename T2, typename Policy> BOOST_MATH_GPU_ENABLED tools::promote_args_t<T1, T2> pow1p(const T1 x, const T2 y, const Policy& pol) template <typename T1, typename T2> BOOST_MATH_GPU_ENABLED tools::promote_args_t<T1, T2> pow1p(const T1 x, const T2 y) }} // namespaces
The function pow1p computes
(1 + x)y where x and y are real numbers. This function is particularly useful
for scenarios where adding 1 to x before raising it to the power of y is
required. It provides a more numerically stable and efficient way to perform
this computation, especially for small values of x. When x is very small,
directly computing (1 + x)y using standard arithmetic operations can lead
to a loss of precision due to floating-point arithmetic limitations. The
pow1p function helps mitigate this issue by internally handling such cases
more accurately.
The type T must provide an
fma function, found either
as std::fma or by argument dependent lookup.
In random testing against a 100 digit reference, the error is at most 3 ULP
for float and double, including tiny x
with huge y, where pow(1 +
x, y) loses
all precision. In the plots below, pow1p is shown in blue and pow(1
+ x, y)
in orange; red points are errors that exceed 100 ULP.
![]() |
Warning |
|---|---|
pow1p relies on error-free transforms and IEEE overflow behavior. Compiling
with value-unsafe floating-point optimizations ( |