1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>powm1</title> 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.12.0"> 8<link rel="up" href="../powers.html" title="Basic Functions"> 9<link rel="prev" href="sqrt1pm1.html" title="sqrt1pm1"> 10<link rel="next" href="hypot.html" title="hypot"> 11</head> 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> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="sqrt1pm1.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="hypot.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h3 class="title"> 27<a name="math_toolkit.powers.powm1"></a><a class="link" href="powm1.html" title="powm1">powm1</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">powm1</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 30</pre> 31<p> 32 namespace boost{ namespace math{ 33 </p> 34<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">></span> 35<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">powm1</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">y</span><span class="special">);</span> 36 37<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T2</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">></span> 38<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">powm1</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T2</span> <span class="identifier">y</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Chapter 21. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&);</span> 39 40<span class="special">}}</span> <span class="comment">// namespaces</span> 41</pre> 42<p> 43 Returns x<sup>y </sup> - 1. 44 </p> 45<p> 46 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 47 type calculation rules</em></span></a> when T1 and T2 are different types. 48 </p> 49<p> 50 The final <a class="link" href="../../policy.html" title="Chapter 21. 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 21. Policies: Controlling Precision, Error Handling etc">policy 53 documentation for more details</a>. 54 </p> 55<p> 56 There are two domains where this is useful: when <span class="emphasis"><em>y</em></span> is 57 very small, or when <span class="emphasis"><em>x</em></span> is close to 1. 58 </p> 59<p> 60 Implemented in terms of <code class="computeroutput"><span class="identifier">expm1</span></code>. 61 </p> 62<p> 63 The following graph illustrates the behaviour of powm1: 64 </p> 65<div class="blockquote"><blockquote class="blockquote"><p> 66 <span class="inlinemediaobject"><img src="../../../graphs/powm1.svg" align="middle"></span> 67 68 </p></blockquote></div> 69<h5> 70<a name="math_toolkit.powers.powm1.h0"></a> 71 <span class="phrase"><a name="math_toolkit.powers.powm1.accuracy"></a></span><a class="link" href="powm1.html#math_toolkit.powers.powm1.accuracy">Accuracy</a> 72 </h5> 73<p> 74 Should have approximately 2-3 epsilon accuracy. 75 </p> 76<div class="table"> 77<a name="math_toolkit.powers.powm1.table_powm1"></a><p class="title"><b>Table 8.85. Error rates for powm1</b></p> 78<div class="table-contents"><table class="table" summary="Error rates for powm1"> 79<colgroup> 80<col> 81<col> 82<col> 83<col> 84<col> 85</colgroup> 86<thead><tr> 87<th> 88 </th> 89<th> 90 <p> 91 GNU C++ version 7.1.0<br> linux<br> double 92 </p> 93 </th> 94<th> 95 <p> 96 GNU C++ version 7.1.0<br> linux<br> long double 97 </p> 98 </th> 99<th> 100 <p> 101 Sun compiler version 0x5150<br> Sun Solaris<br> long double 102 </p> 103 </th> 104<th> 105 <p> 106 Microsoft Visual C++ version 14.1<br> Win32<br> double 107 </p> 108 </th> 109</tr></thead> 110<tbody><tr> 111<td> 112 <p> 113 powm1 114 </p> 115 </td> 116<td> 117 <p> 118 <span class="blue">Max = 1.06ε (Mean = 0.425ε)</span> 119 </p> 120 </td> 121<td> 122 <p> 123 <span class="blue">Max = 2.04ε (Mean = 0.493ε)</span> 124 </p> 125 </td> 126<td> 127 <p> 128 <span class="blue">Max = 1.88ε (Mean = 0.49ε)</span> 129 </p> 130 </td> 131<td> 132 <p> 133 <span class="blue">Max = 1.84ε (Mean = 0.486ε)</span> 134 </p> 135 </td> 136</tr></tbody> 137</table></div> 138</div> 139<br class="table-break"><h5> 140<a name="math_toolkit.powers.powm1.h1"></a> 141 <span class="phrase"><a name="math_toolkit.powers.powm1.testing"></a></span><a class="link" href="powm1.html#math_toolkit.powers.powm1.testing">Testing</a> 142 </h5> 143<p> 144 A selection of random high precision test values calculated using NTL::RR 145 at 1000-bit precision. 146 </p> 147</div> 148<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 149<td align="left"></td> 150<td align="right"><div class="copyright-footer">Copyright © 2006-2019 Nikhar 151 Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, 152 Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan 153 Råde, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg, 154 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>) 157 </p> 158</div></td> 159</tr></table> 160<hr> 161<div class="spirit-nav"> 162<a accesskey="p" href="sqrt1pm1.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="hypot.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 163</div> 164</body> 165</html> 166