2%> Return ``log(exp(logLarger) - exp(logSmaller))`` more accurately.
5%> The onus is on the user to ensure ``logSmaller < logLarger``.
7%> \param[in] logSmaller : The input scalar MATLAB ``real`` representing
8%> the natural logarithm of the smaller value.
9%> \param[in] logLarger : The input scalar MATLAB ``real`` representing
10%> the natural logarithm of the larger value.
13%> ``logDiff`` : The output scalar MATLAB ``real`` containing the
14%> result of ``log(exp(logLarger) - exp(logSmaller))`` accurately.
19%> logDiff = pm.math.logsubexp(smaller, larger)
24%> \include{lineno} example/math/
logsubexp/main.m
26%> \include{lineno} example/math/
logsubexp/main.out.m
31%> \JoshuaOsborne, May 21 2024, 9:45 PM, University of Texas at Arlington<br>
32%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
33%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
35 logDiff = logLarger + log(-expm1(logSmaller - logLarger));
function logsubexp(in logSmaller, in logLarger)
Return log(exp(logLarger) - exp(logSmaller)) more accurately.