_{m = 1}^M \, \mu_m
= \log \sum_{m=1}^M \exp(\mu_m).
\]</span> The log sum of exponentials function can be implemented so as to avoid underflow and maintain high arithmetic precision as <span class="math display">\[
\textrm{log-sum-exp}_{m = 1}^M \mu_m
= \textrm{max}(\mu)
+ \log \sum_{m = 1}^M \exp(\mu_m - \textrm{max}(\mu)).
\]</span> Pulling the maximum out preserves all of its precision. By subtracting the maximum, the terms <span class="math inline">\(\mu_m - \textrm{max}(\mu) \leq 0\)</span>, and thus 