<?xml version='1.0'?>
<html xmlns='http://www.w3.org/1999/xhtml'
      xmlns:math='http://www.w3.org/1998/Math/MathML'
>
<head>
<title>The Integer Power Function</title>
<meta name="description" id="description" content="The Integer Power Function"/>
<meta name="keywords" id="keywords" content=" pow integer exponent "/>
<style type='text/css'>
body { color : black }
body { background-color : white }
A:link { color : blue }
A:visited { color : purple }
A:active { color : purple }
</style>
<script type='text/javascript' language='JavaScript' src='_pow_int_xml.js'>
</script>
</head>
<body>
<table><tr>
<td>
<a href="http://www.coin-or.org/CppAD/" target="_top"><img border="0" src="_image.gif"/></a>
</td>
<td><a href="nan.cpp.xml" target="_top">Prev</a>
</td><td><a href="pow_int.cpp.xml" target="_top">Next</a>
</td><td>
<select onchange='choose_across0(this)'>
<option>Index-&gt;</option>
<option>contents</option>
<option>reference</option>
<option>index</option>
<option>search</option>
<option>external</option>
</select>
</td>
<td>
<select onchange='choose_up0(this)'>
<option>Up-&gt;</option>
<option>CppAD</option>
<option>library</option>
<option>pow_int</option>
</select>
</td>
<td>
<select onchange='choose_down2(this)'>
<option>CppAD-&gt;</option>
<option>Install</option>
<option>Introduction</option>
<option>AD</option>
<option>ADFun</option>
<option>preprocessor</option>
<option>multi_thread</option>
<option>library</option>
<option>ipopt_solve</option>
<option>Example</option>
<option>speed</option>
<option>Appendix</option>
</select>
</td>
<td>
<select onchange='choose_down1(this)'>
<option>library-&gt;</option>
<option>ErrorHandler</option>
<option>NearEqual</option>
<option>speed_test</option>
<option>SpeedTest</option>
<option>time_test</option>
<option>NumericType</option>
<option>CheckNumericType</option>
<option>SimpleVector</option>
<option>CheckSimpleVector</option>
<option>nan</option>
<option>pow_int</option>
<option>Poly</option>
<option>LuDetAndSolve</option>
<option>RombergOne</option>
<option>RombergMul</option>
<option>Runge45</option>
<option>Rosen34</option>
<option>OdeErrControl</option>
<option>OdeGear</option>
<option>OdeGearControl</option>
<option>CppAD_vector</option>
<option>thread_alloc</option>
<option>index_sort</option>
<option>BenderQuad</option>
<option>opt_val_hes</option>
<option>LuRatio</option>
</select>
</td>
<td>
<select onchange='choose_down0(this)'>
<option>pow_int-&gt;</option>
<option>pow_int.cpp</option>
</select>
</td>
<td>
<select onchange='choose_current0(this)'>
<option>Headings-&gt;</option>
<option>Syntax</option>
<option>See Also</option>
<option>Purpose</option>
<option>Include</option>
<option>x</option>
<option>y</option>
<option>z</option>
<option>Type</option>
<option>Operation Sequence</option>
<option>Example</option>
</select>
</td>
</tr></table><br/>







<center><b><big><big>The Integer Power Function</big></big></b></center>
<br/>
<b><big><a name="Syntax" id="Syntax">Syntax</a></big></b>

<code><font color="blue"><br/>
# include &lt;cppad/pow_int.h&gt;</font></code>
<code><span style='white-space: nowrap'><br/>
</span></code>
<code><i><font color="black"><span style='white-space: nowrap'>z</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;=&#xA0;pow(</span></font><i><font color="black"><span style='white-space: nowrap'>x</span></font></i><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>y</span></font></i><font color="blue"><span style='white-space: nowrap'>)</span></font></code>


<br/>
<br/>
<b><big><a name="See Also" id="See Also">See Also</a></big></b>

<br/>
<a href="pow.xml" target="_top"><span style='white-space: nowrap'>pow</span></a>


<br/>
<br/>
<b><big><a name="Purpose" id="Purpose">Purpose</a></big></b>
<br/>
Determines the value of the power function 

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mrow><mstyle mathvariant='normal'><mi mathvariant='normal'>pow</mi>
</mstyle></mrow>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>x</mi>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>y</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">=</mo>
<msup><mi mathvariant='italic'>x</mi>
<mi mathvariant='italic'>y</mi>
</msup>
</mrow></math>

for integer exponents 
<code><i><font color="black"><span style='white-space: nowrap'>n</span></font></i></code>
 
using multiplication and possibly division to compute the value.
The other CppAD <a href="pow.xml" target="_top"><span style='white-space: nowrap'>pow</span></a>
 function may use logarithms and exponentiation 
to compute derivatives of the same value
(which will not work if 
<code><i><font color="black"><span style='white-space: nowrap'>x</span></font></i></code>
 is less than or equal zero).

<br/>
<br/>
<b><big><a name="Include" id="Include">Include</a></big></b>
<br/>
The file <code><font color="blue">cppad/pow_int.h</font></code> is included by <code><font color="blue">cppad/cppad.hpp</font></code>
but it can also be included separately with out the rest of 
the <code><font color="blue">CppAD</font></code> routines.
Including this file defines
this version of the <code><font color="blue">pow</font></code> within the <code><font color="blue">CppAD</font></code> namespace.

<br/>
<br/>
<b><big><a name="x" id="x">x</a></big></b>
<br/>
The argument 
<code><i><font color="black"><span style='white-space: nowrap'>x</span></font></i></code>
 has prototype

<code><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;const&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>Type</span></font></i><font color="blue"><span style='white-space: nowrap'>&amp;&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>x</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
<br/>
<b><big><a name="y" id="y">y</a></big></b>
<br/>
The argument 
<code><i><font color="black"><span style='white-space: nowrap'>y</span></font></i></code>
 has prototype

<code><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;const&#xA0;int&amp;&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>y</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
<br/>
<b><big><a name="z" id="z">z</a></big></b>
<br/>
The result 
<code><i><font color="black"><span style='white-space: nowrap'>z</span></font></i></code>
 has prototype

<code><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>Type</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>z</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
<br/>
<b><big><a name="Type" id="Type">Type</a></big></b>
<br/>
The type 
<code><i><font color="black"><span style='white-space: nowrap'>Type</span></font></i></code>
 must support the following operations
where 
<code><i><font color="black"><span style='white-space: nowrap'>a</span></font></i></code>
 and 
<code><i><font color="black"><span style='white-space: nowrap'>b</span></font></i></code>
 are 
<code><i><font color="black"><span style='white-space: nowrap'>Type</span></font></i></code>
 objects
and 
<code><i><font color="black"><span style='white-space: nowrap'>i</span></font></i></code>
 is an <code><font color="blue">int</font></code>:
<table><tr><td align='left'  valign='top'>

<b>Operation</b>  <code><span style='white-space: nowrap'>&#xA0;&#xA0;</span></code>
	</td><td align='left'  valign='top'>
 <b>Description</b> 
	</td><td align='left'  valign='top'>
 <b>Result Type</b> 
</td></tr><tr><td align='left'  valign='top'>


<code><i><font color="black"><span style='white-space: nowrap'>Type</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>a</span></font></i><font color="blue"><span style='white-space: nowrap'>(</span></font><i><font color="black"><span style='white-space: nowrap'>i</span></font></i><font color="blue"><span style='white-space: nowrap'>)</span></font></code>
 
	</td><td align='left'  valign='top'>
 construction of a 
<code><i><font color="black"><span style='white-space: nowrap'>Type</span></font></i></code>
 object from an <code><font color="blue">int</font></code>
	</td><td align='left'  valign='top'>
 
<code><i><font color="black"><span style='white-space: nowrap'>Type</span></font></i></code>

</td></tr><tr><td align='left'  valign='top'>


<code><i><font color="black"><span style='white-space: nowrap'>a</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;*&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>b</span></font></i></code>
 
	</td><td align='left'  valign='top'>
 binary multiplication of 
<code><i><font color="black"><span style='white-space: nowrap'>Type</span></font></i></code>
 objects
	</td><td align='left'  valign='top'>
 
<code><i><font color="black"><span style='white-space: nowrap'>Type</span></font></i></code>

</td></tr><tr><td align='left'  valign='top'>


<code><i><font color="black"><span style='white-space: nowrap'>a</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;/&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>b</span></font></i></code>
 
	</td><td align='left'  valign='top'>
 binary division of 
<code><i><font color="black"><span style='white-space: nowrap'>Type</span></font></i></code>
 objects
	</td><td align='left'  valign='top'>
 
<code><i><font color="black"><span style='white-space: nowrap'>Type</span></font></i></code>

</td></tr>
</table>
<br/>
<b><big><a name="Operation Sequence" id="Operation Sequence">Operation Sequence</a></big></b>
<br/>
The 
<code><i><font color="black"><span style='white-space: nowrap'>Type</span></font></i></code>
 operation sequence used to calculate 
<code><i><font color="black"><span style='white-space: nowrap'>z</span></font></i></code>
 is 
<a href="glossary.xml#Operation.Independent" target="_top"><span style='white-space: nowrap'>independent</span></a>

of 
<code><i><font color="black"><span style='white-space: nowrap'>x</span></font></i></code>
.

<br/>
<br/>
<b><big><a name="Example" id="Example">Example</a></big></b>

<br/>
The file <a href="pow_int.cpp.xml" target="_top"><span style='white-space: nowrap'>pow_int.cpp</span></a>

is an example and test of this function.   
It returns true if it succeeds and false otherwise.



<hr/>Input File: cppad/pow_int.hpp

</body>
</html>
