LogSumExp

LogSumExp is defined as the logarithm of the sum of the exponentials of the arguments:

When is this used? Ex:

To stabilize the computation, we factor out the largest exponent:

Where:

Derivation: Just take out the largest exponent, you can compute it by hand https://chatgpt.com/share/67a00c3c-16d8-8002-beab-33d689d02915