Prev Next

AD Standard Math Unary Functions

Syntax
y = fun(x)

Purpose
Evaluates the one argument standard math function fun where its argument is an AD of Base object.

x
The argument x has one of the following prototypes
     const AD<
Base>               &x
     const VecAD<
Base>::reference &x

y
The result y has prototype
     AD<
Basey

Operation Sequence
Most of these functions are AD of Base atomic operations . In all cases, The AD of Base operation sequence used to calculate y is independent of x.

fun
A definition of fun is included for each of the following functions: acos, asin, atan, cos, cosh, exp, log, log10, sin, sinh, sqrt, tan.

Examples
The following files contain examples and tests of these functions. Each test returns true if it succeeds and false otherwise.
Acos.cpp The AD acos Function: Example and Test
Asin.cpp The AD asin Function: Example and Test
Atan.cpp The AD atan Function: Example and Test
Cos.cpp The AD cos Function: Example and Test
Cosh.cpp The AD cosh Function: Example and Test
Exp.cpp The AD exp Function: Example and Test
Log.cpp The AD log Function: Example and Test
Log10.cpp The AD log10 Function: Example and Test
Sin.cpp The AD sin Function: Example and Test
Sinh.cpp The AD sinh Function: Example and Test
Sqrt.cpp The AD sqrt Function: Example and Test
Tan.cpp The AD tan Function: Example and Test

Derivatives
Each of these functions satisfy a standard math function differential equation. Calculating derivatives using this differential equation is discussed for both forward and reverse mode. The exact form of the differential equation for each of these functions is listed below:

acos
 \[
\begin{array}{lcr}
     \D{[ {\rm acos} (x) ]}{x} & = & - (1 - x * x)^{-1/2}
\end{array}
\] 


asin
 \[
\begin{array}{lcr}
     \D{[ {\rm asin} (x) ]}{x} & = & (1 - x * x)^{-1/2}
\end{array}
\] 


atan
 \[
\begin{array}{lcr}
        \D{[ {\rm atan} (x) ]}{x} & = & \frac{1}{1 + x^2}
\end{array}
\] 


cos
 \[
\begin{array}{lcr}
        \D{[ \cos (x) ]}{x} & = & - \sin (x)  \\
        \D{[ \sin (x) ]}{x} & = & \cos (x)
\end{array}
\] 


cosh
 \[
\begin{array}{lcr}
        \D{[ \cosh (x) ]}{x} & = & \sinh (x)  \\
        \D{[ \sin (x) ]}{x}  & = & \cosh (x)
\end{array}
\] 


exp
 \[
\begin{array}{lcr}
        \D{[ \exp (x) ]}{x} & = & \exp (x)
\end{array}
\] 


log
 \[
\begin{array}{lcr}
        \D{[ \log (x) ]}{x} & = & \frac{1}{x}
\end{array}
\] 


log10
This function is special in that it's derivatives are calculated using the relation  \[
\begin{array}{lcr}
        {\rm log10} (x) & = & \log(x) / \log(10)
\end{array}
\] 


sin
 \[
\begin{array}{lcr}
        \D{[ \sin (x) ]}{x} & = & \cos (x) \\
        \D{[ \cos (x) ]}{x} & = & - \sin (x) 
\end{array}
\] 


sinh
 \[
\begin{array}{lcr}
        \D{[ \sinh (x) ]}{x} & = & \cosh (x)   \\
        \D{[ \cosh (x) ]}{x} & = & \sinh (x)
\end{array}
\] 


sqrt
 \[
\begin{array}{lcr}
        \D{[ {\rm sqrt} (x) ]}{x} & = & \frac{1}{2 {\rm sqrt} (x) }
\end{array}
\] 


tan
This function is special in that it's derivatives are calculated using the relation  \[
\begin{array}{lcr}
        \tan (x) & = & \sin(x) / \cos(x)
\end{array}
\] 

Input File: cppad/local/std_math_ad.hpp