ceed by evaluating the terms as
written. Instead, with a little algebra, the terms are rearranged
into a stable form,</p>
<p><span class="math display">\[
\mathrm{log\_sum\_exp}(u, v)
\ = \
\max(u, v) + \log\left( \exp(u - \max(u, v)) + \exp(v - \max(u, v)) \right).
\]</span></p>
<p>Because the terms inside the exponentiations are <span class="math inline">\(u - \max(u, v)\)</span> and
<span class="math inline">\(v - \max(u, v)\)</span>, one will be zero, and the other will be negative.
Because the operatio