3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
5 <link rel="stylesheet" href="../../math.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="../../index.html" title="Math Toolkit 2.5.2">
8 <link rel="up" href="../powers.html" title="Basic Functions">
9 <link rel="prev" href="expm1.html" title="expm1">
10 <link rel="next" href="sqrt1pm1.html" title="sqrt1pm1">
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
15 <td align="center"><a href="../../../../../../index.html">Home</a></td>
16 <td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../../../../../more/index.htm">More</a></td>
22 <div class="spirit-nav">
23 <a accesskey="p" href="expm1.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../powers.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="sqrt1pm1.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
26 <div class="titlepage"><div><div><h3 class="title">
27 <a name="math_toolkit.powers.cbrt"></a><a class="link" href="cbrt.html" title="cbrt">cbrt</a>
28 </h3></div></div></div>
29 <pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">special_functions</span><span class="special">/</span><span class="identifier">cbrt</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
31 <pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span>
33 <span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
34 <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">cbrt</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">x</span><span class="special">);</span>
36 <span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span>
37 <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">cbrt</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span>
39 <span class="special">}}</span> <span class="comment">// namespaces</span>
42 Returns the cubed root of x: x<sup>1/3</sup>.
45 The return type of this function is computed using the <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>result
46 type calculation rules</em></span></a>: the return is <code class="computeroutput"><span class="keyword">double</span></code>
47 when <span class="emphasis"><em>x</em></span> is an integer type and T otherwise.
50 The final <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">Policy</a> argument is optional and can
51 be used to control the behaviour of the function: how it handles errors,
52 what level of precision to use etc. Refer to the <a class="link" href="../../policy.html" title="Chapter 15. Policies: Controlling Precision, Error Handling etc">policy
53 documentation for more details</a>.
56 Implemented using Halley iteration.
59 The following graph illustrates the behaviour of cbrt:
62 <span class="inlinemediaobject"><img src="../../../graphs/cbrt.svg" align="middle"></span>
65 <a name="math_toolkit.powers.cbrt.h0"></a>
66 <span class="phrase"><a name="math_toolkit.powers.cbrt.accuracy"></a></span><a class="link" href="cbrt.html#math_toolkit.powers.cbrt.accuracy">Accuracy</a>
69 For built in floating-point types <code class="computeroutput"><span class="identifier">cbrt</span></code>
70 should have approximately 2 epsilon accuracy.
73 <a name="math_toolkit.powers.cbrt.table_cbrt"></a><p class="title"><b>Table 6.80. Error rates for cbrt</b></p>
74 <div class="table-contents"><table class="table" summary="Error rates for cbrt">
87 Microsoft Visual C++ version 12.0<br> Win32<br> double
92 GNU C++ version 5.1.0<br> linux<br> double
97 GNU C++ version 5.1.0<br> linux<br> long double
102 Sun compiler version 0x5130<br> Sun Solaris<br> long double
114 <span class="blue">Max = 1.7ε (Mean = 0.565ε)</span><br> <br>
115 (<span class="emphasis"><em><math.h>:</em></span> Max = 1.7ε (Mean = 0.565ε))
120 <span class="blue">Max = 0ε (Mean = 0ε)</span><br> <br> (<span class="emphasis"><em>Cephes:</em></span>
121 Max = 0ε (Mean = 0ε))
126 <span class="blue">Max = 1.34ε (Mean = 0.471ε)</span><br> <br>
127 (<span class="emphasis"><em><tr1/cmath>:</em></span> Max = 1.34ε (Mean = 0.471ε))<br>
128 (<span class="emphasis"><em><math.h>:</em></span> Max = 1.34ε (Mean = 0.471ε))
133 <span class="blue">Max = 1.11ε (Mean = 0.424ε)</span><br> <br>
134 (<span class="emphasis"><em><math.h>:</em></span> Max = 1.11ε (Mean = 0.424ε))
140 <br class="table-break"><h5>
141 <a name="math_toolkit.powers.cbrt.h1"></a>
142 <span class="phrase"><a name="math_toolkit.powers.cbrt.testing"></a></span><a class="link" href="cbrt.html#math_toolkit.powers.cbrt.testing">Testing</a>
145 A mixture of spot test sanity checks, and random high precision test values
146 calculated using NTL::RR at 1000-bit precision.
149 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
150 <td align="left"></td>
151 <td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
152 Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
153 Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
154 Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
155 Distributed under the Boost Software License, Version 1.0. (See accompanying
156 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
161 <div class="spirit-nav">
162 <a accesskey="p" href="expm1.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../powers.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="sqrt1pm1.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>