...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/cbrt.hpp>
namespace boost{ namespace math{ template <class T> calculatedresulttype cbrt(T x); template <class T, class Policy> calculatedresulttype cbrt(T x, const Policy&); }} // namespaces
Returns the cubed root of x: x^{1/3}.
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.
Implemented using Halley iteration.
The following graph illustrates the behaviour of cbrt:
For built in floatingpoint types cbrt
should have approximately 2 epsilon accuracy.
Table 6.83. Error rates for cbrt
GNU C++ version 7.1.0 
GNU C++ version 7.1.0 
Sun compiler version 0x5150 
Microsoft Visual C++ version 14.1 


cbrt Function 
Max = 0ε (Mean = 0ε) 
Max = 1.34ε (Mean = 0.471ε) 
Max = 1.34ε (Mean = 0.471ε) 
Max = 1.7ε (Mean = 0.565ε) 
A mixture of spot test sanity checks, and random high precision test values calculated using NTL::RR at 1000bit precision.