CppAD: A C++ Algorithmic Differentiation Package  20171217
atanh.hpp
Go to the documentation of this file.
1 # ifndef CPPAD_CORE_ATANH_HPP
2 # define CPPAD_CORE_ATANH_HPP
3
4 /* --------------------------------------------------------------------------
5 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell
6
8 the terms of the
9  Eclipse Public License Version 1.0.
10
11 A copy of this license is included in the COPYING file of this distribution.
13 -------------------------------------------------------------------------- */
14
15 /*
16 -------------------------------------------------------------------------------
17 $begin atanh$$18 spell 19 atanh 20 const 21 Vec 22 std 23 cmath 24 CppAD 25 tanh 26$$ 27$section The Inverse Hyperbolic Tangent Function: atanh$$28 29 head Syntax$$
30 $icode%y% = atanh(%x%)%$$31 32 head Description$$ 33 The inverse hyperbolic tangent function is defined by 34$icode%x% == tanh(%y%)%$$. 35 36 head x, y$$
37 See the $cref/possible types/unary_standard_math/Possible Types/$$38 for a unary standard math function. 39 40 head CPPAD_USE_CPLUSPLUS_2011$$ 41 42$subhead true$$43 If this preprocessor symbol is true (code 1$$),
44 and $icode x$$is an AD type, 45 this is an cref/atomic operation/glossary/Operation/Atomic/$$. 46 47$subhead false$$48 If this preprocessor symbol is false (code 0$$),
49 CppAD uses the representation
50 $latex $51 \R{atanh} (x) = \frac{1}{2} \log \left( \frac{1 + x}{1 - x} \right) 52$ $$53 to compute this function. 54 55 head Example$$ 56$children%
57  example/general/atanh.cpp
58 %$$59 The file 60 cref atanh.cpp$$
61 contains an example and test of this function.
62 It returns true if it succeeds and false otherwise.
63
64 \$end
65 -------------------------------------------------------------------------------
66 */
67 # include <cppad/configure.hpp>
68 # if ! CPPAD_USE_CPLUSPLUS_2011
69
70 // BEGIN CppAD namespace
71 namespace CppAD {
72
73 template <class Type>
74 Type atanh_template(const Type &x)
75 { return CppAD::log( (Type(1) + x) / (Type(1) - x) ) / Type(2);
76 }
77
78 inline float atanh(const float &x)
79 { return atanh_template(x); }
80
81 inline double atanh(const double &x)
82 { return atanh_template(x); }
83
84 template <class Base>