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