Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ log_diff_exp() [6/10]

template<typename T1 , typename T2 , require_all_arithmetic_t< T1, T2 > * = nullptr>
return_type_t< T1, T2 > stan::math::log_diff_exp ( const T1  x,
const T2  y 
)
inline

The natural logarithm of the difference of the natural exponentiation of x and the natural exponentiation of y.

This function is only defined for x >= y

\[ \mbox{log\_diff\_exp}(x, y) = \begin{cases} \textrm{NaN} & \mbox{if } x < y\\ \ln(\exp(x)-\exp(y)) & \mbox{if } x \geq y \\[6pt] \textrm{NaN} & \mbox{if } x = \textrm{NaN or } y = \textrm{NaN} \end{cases} \]

\[ \frac{\partial\, \mbox{log\_diff\_exp}(x, y)}{\partial x} = \begin{cases} \textrm{NaN} & \mbox{if } x \leq y\\ \frac{\exp(x)}{\exp(x)-\exp(y)} & \mbox{if } x > y \\[6pt] \textrm{NaN} & \mbox{if } x = \textrm{NaN or } y = \textrm{NaN} \end{cases} \]

\[ \frac{\partial\, \mbox{log\_diff\_exp}(x, y)}{\partial y} = \begin{cases} \textrm{NaN} & \mbox{if } x \leq y\\ -\frac{\exp(y)}{\exp(x)-\exp(y)} & \mbox{if } x > y \\[6pt] \textrm{NaN} & \mbox{if } x = \textrm{NaN or } y = \textrm{NaN} \end{cases} \]

Template Parameters
T1type of the first argument
T2type of the second argument
Parameters
xfirst argument
ysecond argument

Definition at line 51 of file log_diff_exp.hpp.