e Stan’s built-in
<code>log_sum_exp</code> function is that it can prevent underflow and overflow
in the exponentiation, by calculating the result as</p>
<p><span class="math display">\[
\log\left( \exp(a) + \exp(b)\right)
= c
  + \log \left( \exp(a - c) + \exp(b - c) \right),
\]</span></p>
<p>where <span class="math inline">\(c = \max(a, b)\)</span>. In this evaluation, one of the terms, <span class="math inline">\(a - c\)</span>
or <span class="math inline">\(b - c\)</span>, is zero and the other is neg