CppAD: A C++ Algorithmic Differentiation Package  20171217
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
acosh.hpp
Go to the documentation of this file.
1 # ifndef CPPAD_CORE_ACOSH_HPP
2 # define CPPAD_CORE_ACOSH_HPP
3 
4 /* --------------------------------------------------------------------------
5 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell
6 
7 CppAD is distributed under multiple licenses. This distribution is under
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.
12 Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
13 -------------------------------------------------------------------------- */
14 
15 /*
16 -------------------------------------------------------------------------------
17 $begin acosh$$
18 $spell
19  acosh
20  const
21  Vec
22  std
23  cmath
24  CppAD
25 $$
26 $section The Inverse Hyperbolic Cosine Function: acosh$$
27 
28 $head Syntax$$
29 $icode%y% = acosh(%x%)%$$
30 
31 $head Description$$
32 The inverse hyperbolic cosine function is defined by
33 $icode%x% == cosh(%y%)%$$.
34 
35 $head x, y$$
36 See the $cref/possible types/unary_standard_math/Possible Types/$$
37 for a unary standard math function.
38 
39 $head CPPAD_USE_CPLUSPLUS_2011$$
40 
41 $subhead true$$
42 If this preprocessor symbol is true ($code 1$$),
43 and $icode x$$ is an AD type,
44 this is an $cref/atomic operation/glossary/Operation/Atomic/$$.
45 
46 $subhead false$$
47 If this preprocessor symbol is false ($code 0$$),
48 CppAD uses the representation
49 $latex \[
50 \R{acosh} (x) = \log \left( x + \sqrt{ x^2 - 1 } \right)
51 \] $$
52 to compute this function.
53 
54 $head Example$$
55 $children%
56  example/general/acosh.cpp
57 %$$
58 The file
59 $cref acosh.cpp$$
60 contains an example and test of this function.
61 It returns true if it succeeds and false otherwise.
62 
63 $end
64 -------------------------------------------------------------------------------
65 */
66 # include <cppad/configure.hpp>
67 # if ! CPPAD_USE_CPLUSPLUS_2011
68 
69 // BEGIN CppAD namespace
70 namespace CppAD {
71 
72 template <class Type>
73 Type acosh_template(const Type &x)
74 { return CppAD::log( x + CppAD::sqrt( x * x - Type(1) ) );
75 }
76 
77 inline float acosh(const float &x)
78 { return acosh_template(x); }
79 
80 inline double acosh(const double &x)
81 { return acosh_template(x); }
82 
83 template <class Base>
84 inline AD<Base> acosh(const AD<Base> &x)
85 { return acosh_template(x); }
86 
87 template <class Base>
88 inline AD<Base> acosh(const VecAD_reference<Base> &x)
89 { return acosh_template( x.ADBase() ); }
90 
91 
92 } // END CppAD namespace
93 
94 # endif // CPPAD_USE_CPLUSPLUS_2011
95 # endif // CPPAD_ACOSH_INCLUDED
AD< Base > log(const AD< Base > &x)
std::complex< double > acosh(const std::complex< double > &x)
AD< Base > sqrt(const AD< Base > &x)