1 #ifndef STAN_MATH_FWD_FUN_ATAN_HPP
2 #define STAN_MATH_FWD_FUN_ATAN_HPP
3 
4 #include <stan/math/fwd/core.hpp>
5 #include <stan/math/fwd/meta.hpp>
6 #include <stan/math/prim/fun/atan.hpp>
7 #include <stan/math/prim/fun/square.hpp>
8 #include <cmath>
9 #include <complex>
10 
11 namespace stan {
12 namespace math {
13 
14 template <typename T>
atan(const fvar<T> & x)15 inline fvar<T> atan(const fvar<T>& x) {
16   using std::atan;
17   return fvar<T>(atan(x.val_), x.d_ / (1 + square(x.val_)));
18 }
19 
20 /**
21  * Return the arc tangent of the complex argument.
22  *
23  * @tparam T autodiff value type
24  * @param[in] z argument
25  * @return arc tanget of the argument
26  */
27 template <typename T>
atan(const std::complex<fvar<T>> & z)28 inline std::complex<fvar<T>> atan(const std::complex<fvar<T>>& z) {
29   return internal::complex_atan(z);
30 }
31 
32 }  // namespace math
33 }  // namespace stan
34 #endif
35