Skip to content

Commit

Permalink
Merge pull request #815 from dylanhmorris/814-fix-log-diff-exp-descri…
Browse files Browse the repository at this point in the history
…ption

Clarify `log_diff_exp` behavior at `x == y`
  • Loading branch information
bob-carpenter authored Sep 17, 2024
2 parents b645f4d + ce43ed7 commit ba8c1c5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/functions-reference/real-valued_basic_functions.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -1601,8 +1601,12 @@ The logarithm of one minus the natural exponentiation of x
Return the natural logarithm of the difference of the natural
exponentiation of x and the natural exponentiation of y. \begin{equation*}
\mathrm{log\_diff\_exp}(x,y) = \begin{cases} \log(\exp(x)-\exp(y)) &
\text{if } x > y \\[6pt] \textrm{NaN} & \text{otherwise} \end{cases}
\text{if } +\infty > x \ge y \\[6pt]
\textrm{NaN} & \text{otherwise} \end{cases}
\end{equation*}

When x is equal to y, `log_diff_exp(x, y)` returns $-\infty$, consistent with `log(0)` returning $-\infty$. This includes the case in which x and y are both equal to $-\infty$, which corresponds to `log(0 - 0)` because `exp(negative_infinity())` returns 0.

{{< since 2.0 >}}

<!-- R; log_diff_exp; (T1 x, T2 y); -->
Expand Down

0 comments on commit ba8c1c5

Please sign in to comment.