Skip to content

Commit ba8c1c5

Browse files
Merge pull request #815 from dylanhmorris/814-fix-log-diff-exp-description
Clarify `log_diff_exp` behavior at `x == y`
2 parents b645f4d + ce43ed7 commit ba8c1c5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/functions-reference/real-valued_basic_functions.qmd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1601,8 +1601,12 @@ The logarithm of one minus the natural exponentiation of x
16011601
Return the natural logarithm of the difference of the natural
16021602
exponentiation of x and the natural exponentiation of y. \begin{equation*}
16031603
\mathrm{log\_diff\_exp}(x,y) = \begin{cases} \log(\exp(x)-\exp(y)) &
1604-
\text{if } x > y \\[6pt] \textrm{NaN} & \text{otherwise} \end{cases}
1604+
\text{if } +\infty > x \ge y \\[6pt]
1605+
\textrm{NaN} & \text{otherwise} \end{cases}
16051606
\end{equation*}
1607+
1608+
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.
1609+
16061610
{{< since 2.0 >}}
16071611

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

0 commit comments

Comments
 (0)