1#ifndef STAN_MATH_FWD_FUN_TANH_HPP
2#define STAN_MATH_FWD_FUN_TANH_HPP
30 if (
fabs(x_val) < 0.5) {
31 return fvar<T>(tanh_x, x.
d_ * (1 - tanh_x * tanh_x));
34 const T exp_neg_2abs_x =
exp(x_val > 0 ? -2 * x.
val_ : 2 * x.
val_);
35 const T one_plus_exp = 1 + exp_neg_2abs_x;
37 x.
d_ * (4 * exp_neg_2abs_x / (one_plus_exp * one_plus_exp)));
48inline std::complex<fvar<T>>
tanh(
const std::complex<
fvar<T>>& z) {
std::complex< V > complex_tanh(const std::complex< V > &z)
Return the hyperbolic tangent of the complex argument.
double value_of_rec(const fvar< T > &v)
Return the value of the specified variable.
fvar< T > tanh(const fvar< T > &x)
Return the hyperbolic tangent of the argument.
fvar< T > fabs(const fvar< T > &x)
fvar< T > exp(const fvar< T > &x)
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Scalar val_
The value of this variable.
Scalar d_
The tangent (derivative) of this variable.
This template class represents scalars used in forward-mode automatic differentiation,...