Home | Libraries | People | FAQ | More |

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

namespace boost{ namespace math{ template <class T>calculated-result-typesqrt1pm1(T x); template <class T, class Policy>calculated-result-typesqrt1pm1(T x, const Policy&); }} // namespaces

Returns `sqrt(1+x) - 1`

.

The return type of this function is computed using the *result
type calculation rules*: the return is `double`

when *x* is an integer type and T otherwise.

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.

This function is useful when you need the difference between sqrt(x) and 1, when x is itself close to 1.

Implemented in terms of `log1p`

and `expm1`

.

For built in floating-point types `sqrt1pm1`

should have approximately 3 epsilon accuracy.

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