$Id: sqrt_reverse.omh 3757 2015-11-30 12:03:07Z bradbell $
/* --------------------------------------------------------------------------
CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell

CppAD is distributed under multiple licenses. This distribution is under
the terms of the
                    GNU General Public License Version 3.

A copy of this license is included in the COPYING file of this distribution.
Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
-------------------------------------------------------------------------- */

$begin sqrt_reverse$$
$spell
	sqrt
	Taylor
$$

$section Square Root Function Reverse Mode Theory$$
$mindex sqrt$$


We use the reverse theory
$cref%standard math function
	%ReverseTheory
	%Standard Math Functions
%$$
definition for the functions $latex H$$ and $latex G$$.

The forward mode formulas for the
$cref/square root/sqrt_forward/$$
function are
$latex \[
	z^{(j)}  =  \sqrt { x^{(0)} }
\] $$

for the case $latex j = 0$$, and for $latex j > 0$$,

$latex \[
z^{(j)}  =  \frac{1}{j} \frac{1}{ z^{(0)} }
\left(
	\frac{j}{2} x^{(j) }
	- \sum_{\ell=1}^{j-1} \ell z^{(\ell)} z^{(j-\ell)}
\right)
\] $$

If $latex j = 0$$, we have the relation

$latex \[
\begin{array}{rcl}
\D{H}{ x^{(j)} } & = &
\D{G}{ x^{(j)} }  + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(0)} }
\\
& = &
\D{G}{ x^{(j)} }  + \D{G}{ z^{(j)} } \frac{1}{2 z^{(0)} }
\end{array}
\] $$

If $latex j > 0$$, then for $latex k = 1, \ldots , j-1$$

$latex \[
\begin{array}{rcl}
\D{H}{ z^{(0)} } & = &
\D{G}{ z^{(0)} }  + \D{G} { z^{(j)} } \D{ z^{(j)} }{ z^{(0)} }
\\
& = &
\D{G}{ z^{(0)} }  -
\D{G}{ z^{(j)} }  \frac{ z^{(j)} }{ z^{(0)} }
\\
\D{H}{ x^{(j)} } & = &
\D{G}{ x^{(j)} }  + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(j)} }
\\
& = &
\D{G}{ x^{(j)} }  + \D{G}{ z^{(j)} } \frac{1}{ 2 z^{(0)} }
\\
\D{H}{ z^{(k)} } & = &
\D{G}{ z^{(k)} }  + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ z^{(k)} }
\\
& = &
\D{G}{ z^{(k)} }  - \D{G}{ z^{(j)} } \frac{ z^{(j-k)} }{ z^{(0)} }
\end{array}
\] $$

$end
