<?xml version='1.0'?>
<html xmlns='http://www.w3.org/1999/xhtml'
      xmlns:math='http://www.w3.org/1998/Math/MathML'
>
<head>
<title>Evaluate a Polynomial or its Derivative</title>
<meta name="description" id="description" content="Evaluate a Polynomial or its Derivative"/>
<meta name="keywords" id="keywords" content=" Poly polynomial derivative template "/>
<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='_poly_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="pow_int.cpp.xml" target="_top">Prev</a>
</td><td><a href="poly.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>Poly</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>Poly-&gt;</option>
<option>poly.cpp</option>
<option>poly.hpp</option>
</select>
</td>
<td>
<select onchange='choose_current0(this)'>
<option>Headings-&gt;</option>
<option>Syntax</option>
<option>Description</option>
<option>Include</option>
<option>k</option>
<option>a</option>
<option>z</option>
<option>p</option>
<option>Type</option>
<option>---..Operations</option>
<option>Vector</option>
<option>Operation Sequence</option>
<option>Example</option>
<option>Source</option>
</select>
</td>
</tr></table><br/>








<center><b><big><big>Evaluate a Polynomial or its Derivative</big></big></b></center>
<br/>
<b><big><a name="Syntax" id="Syntax">Syntax</a></big></b>

<code><font color="blue"><br/>
# include &lt;cppad/poly.hpp&gt;</font></code>
<code><span style='white-space: nowrap'><br/>
</span></code>
<code><i><font color="black"><span style='white-space: nowrap'>p</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;=&#xA0;Poly(</span></font><i><font color="black"><span style='white-space: nowrap'>k</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'>,&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>z</span></font></i><font color="blue"><span style='white-space: nowrap'>)</span></font></code>



<br/>
<br/>
<b><big><a name="Description" id="Description">Description</a></big></b>
<br/>
Computes the <i>k</i>-th derivative of the polynomial 

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mi mathvariant='italic'>P</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>z</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">=</mo>
<msub><mi mathvariant='italic'>a</mi>
<mn>0</mn>
</msub>
<mo stretchy="false">+</mo>
<msub><mi mathvariant='italic'>a</mi>
<mn>1</mn>
</msub>
<msup><mi mathvariant='italic'>z</mi>
<mn>1</mn>
</msup>
<mo stretchy="false">+</mo>
<mo stretchy="false">&#x022EF;</mo>
<mo stretchy="false">+</mo>
<msub><mi mathvariant='italic'>a</mi>
<mi mathvariant='italic'>d</mi>
</msub>
<msup><mi mathvariant='italic'>z</mi>
<mi mathvariant='italic'>d</mi>
</msup>
</mrow></math>

If 
<code><i><font color="black"><span style='white-space: nowrap'>k</span></font></i></code>
 is equal to zero, the return value is 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>P</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>z</mi>
<mo stretchy="false">)</mo>
</mrow></math>

.

<br/>
<br/>
<b><big><a name="Include" id="Include">Include</a></big></b>
<br/>
The file <code><font color="blue">cppad/poly.hpp</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
<code><font color="blue">Poly</font></code> within the <code><font color="blue">CppAD</font></code> namespace.

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

<code><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;size_t&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>k</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
It specifies the order of the derivative to calculate.

<br/>
<br/>
<b><big><a name="a" id="a">a</a></big></b>
<br/>
The argument 
<code><i><font color="black"><span style='white-space: nowrap'>a</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'>Vector</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;&amp;</span></font><i><font color="black"><span style='white-space: nowrap'>a</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
(see <a href="poly.xml#Vector" target="_top"><span style='white-space: nowrap'>Vector</span></a>
 below).
It specifies the vector corresponding to the polynomial 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>P</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>z</mi>
<mo stretchy="false">)</mo>
</mrow></math>

.

<br/>
<br/>
<b><big><a name="z" id="z">z</a></big></b>
<br/>
The argument 
<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;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'>&#xA0;&amp;</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>
(see 
<code><i><font color="black"><span style='white-space: nowrap'>Type</span></font></i></code>
 below).
It specifies the point at which to evaluate the polynomial

<br/>
<br/>
<b><big><a name="p" id="p">p</a></big></b>
<br/>
The result 
<code><i><font color="black"><span style='white-space: nowrap'>p</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'>p</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
(see <a href="poly.xml#Type" target="_top"><span style='white-space: nowrap'>Type</span></a>
 below)
and it is equal to the <i>k</i>-th derivative of 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>P</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>z</mi>
<mo stretchy="false">)</mo>
</mrow></math>

; i.e., 

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mi mathvariant='italic'>p</mi>
<mo stretchy="false">=</mo>
<mfrac><mrow><mi mathvariant='italic'>k</mi>
<mo stretchy="false">!</mo>
</mrow>
<mrow><mn>0</mn>
<mo stretchy="false">!</mo>
</mrow>
</mfrac>
<msub><mi mathvariant='italic'>a</mi>
<mi mathvariant='italic'>k</mi>
</msub>
<mo stretchy="false">+</mo>
<mfrac><mrow><mo stretchy="false">(</mo>
<mi mathvariant='italic'>k</mi>
<mo stretchy="false">+</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
<mo stretchy="false">!</mo>
</mrow>
<mrow><mn>1</mn>
<mo stretchy="false">!</mo>
</mrow>
</mfrac>
<msub><mi mathvariant='italic'>a</mi>
<mrow><mi mathvariant='italic'>k</mi>
<mo stretchy="false">+</mo>
<mn>1</mn>
</mrow>
</msub>
<msup><mi mathvariant='italic'>z</mi>
<mn>1</mn>
</msup>
<mo stretchy="false">+</mo>
<mo stretchy="false">&#x02026;</mo>
<mo stretchy="false">+</mo>
<mfrac><mrow><mi mathvariant='italic'>d</mi>
<mo stretchy="false">!</mo>
</mrow>
<mrow><mo stretchy="false">(</mo>
<mi mathvariant='italic'>d</mi>
<mo stretchy="false">-</mo>
<mi mathvariant='italic'>k</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">!</mo>
</mrow>
</mfrac>
<msub><mi mathvariant='italic'>a</mi>
<mi mathvariant='italic'>d</mi>
</msub>
<msup><mi mathvariant='italic'>z</mi>
<mrow><mi mathvariant='italic'>d</mi>
<mo stretchy="false">-</mo>
<mi mathvariant='italic'>k</mi>
</mrow>
</msup>
</mrow></math>

If 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>k</mi>
<mo stretchy="false">&gt;</mo>
<mi mathvariant='italic'>d</mi>
</mrow></math>

, 
<code><i><font color="black"><span style='white-space: nowrap'>p</span></font></i><font color="blue"><span style='white-space: nowrap'>&#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'>(0)</span></font></code>
.

<br/>
<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>
 is determined by the argument 
<code><i><font color="black"><span style='white-space: nowrap'>z</span></font></i></code>
.
It is assumed that
multiplication and addition of 
<code><i><font color="black"><span style='white-space: nowrap'>Type</span></font></i></code>
 objects
are commutative.

<br/>
<br/>
<b><a name="Type.Operations" id="Type.Operations">Operations</a></b>
<br/>
The following operations must be supported where

<code><i><font color="black"><span style='white-space: nowrap'>x</span></font></i></code>
 and 
<code><i><font color="black"><span style='white-space: nowrap'>y</span></font></i></code>
 are objects of type 
<code><i><font color="black"><span style='white-space: nowrap'>Type</span></font></i></code>

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'>


<code><i><font color="black"><span style='white-space: nowrap'>x</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;&#xA0;=&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>i</span></font></i></code>
   </td><td align='left'  valign='top'>
 assignment     </td></tr><tr><td align='left'  valign='top'>


<code><i><font color="black"><span style='white-space: nowrap'>x</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;&#xA0;=&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>y</span></font></i></code>
   </td><td align='left'  valign='top'>
 assignment     </td></tr><tr><td align='left'  valign='top'>


<code><i><font color="black"><span style='white-space: nowrap'>x</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;*=&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>y</span></font></i></code>
   </td><td align='left'  valign='top'>
 multiplication computed assignment </td></tr><tr><td align='left'  valign='top'>


<code><i><font color="black"><span style='white-space: nowrap'>x</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;+=&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>y</span></font></i></code>
   </td><td align='left'  valign='top'>
 addition computed assignment

</td></tr>
</table>
<br/>
<b><big><a name="Vector" id="Vector">Vector</a></big></b>
<br/>
The type 
<code><i><font color="black"><span style='white-space: nowrap'>Vector</span></font></i></code>
 must be a <a href="simplevector.xml" target="_top"><span style='white-space: nowrap'>SimpleVector</span></a>
 class with
<a href="simplevector.xml#Elements of Specified Type" target="_top"><span style='white-space: nowrap'>elements&#xA0;of&#xA0;type</span></a>


<code><i><font color="black"><span style='white-space: nowrap'>Type</span></font></i></code>
.
The routine <a href="checksimplevector.xml" target="_top"><span style='white-space: nowrap'>CheckSimpleVector</span></a>
 will generate an error message
if this is not the case.

<br/>
<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'>p</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'>z</span></font></i></code>
 and the elements of 
<code><i><font color="black"><span style='white-space: nowrap'>a</span></font></i></code>

(it does depend on the size of the vector 
<code><i><font color="black"><span style='white-space: nowrap'>a</span></font></i></code>
).




<br/>
<br/>
<b><big><a name="Example" id="Example">Example</a></big></b>
<br/>
The file
<a href="poly.cpp.xml" target="_top"><span style='white-space: nowrap'>poly.cpp</span></a>

contains an example and test of this routine.
It returns true if it succeeds and false otherwise.

<br/>
<br/>
<b><big><a name="Source" id="Source">Source</a></big></b>
<br/>
The file <a href="poly.hpp.xml" target="_top"><span style='white-space: nowrap'>poly.hpp</span></a>
 contains the 
current source code that implements these specifications.


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

</body>
</html>
