ArticleslgStudy

science

LogSumExp

LogSumExp is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand LogSumExp rather than just read about it. In short: The LogSumExp (LSE) (also called RealSoftMax or multivariable softplus) function is a smooth maximum – a smooth approximation to the maximum function, mainly used by machine learning algorithms. It is defined as the logarithm of the sum of the exponentials of the arguments: LSE(x1,…,xn)=log⁡(exp⁡(x1)+⋯+exp⁡(xn)).

LogSumExp — main illustration
LogSumExp — illustration

Key takeaways

  • LogSumExp belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect LogSumExp to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of LogSumExp from memory before moving on to harder problems.

Reference excerpt

The LogSumExp (LSE) (also called RealSoftMax or multivariable softplus) function is a smooth maximum – a smooth approximation to the maximum function, mainly used by machine learning algorithms. It is defined as the logarithm of the sum of the exponentials of the arguments: LSE(x1,…,xn)=log⁡(exp⁡(x1)+⋯+exp⁡(xn)).

Properties The LogSumExp function domain is ℝn, the real coordinate space, and its codomain is ℝ, the real line. It is an approximation to the maximum maxixi with the following bounds max⁡{x1,…,xn}≤LSE(x1,…,xn)≤max⁡{x1,…,xn}+log⁡(n). The first inequality is strict unless n=1. The second inequality is strict unless all arguments are equal. (Proof: Let m=maxixi. Then exp⁡(m)≤∑i=1nexp⁡(xi)≤nexp⁡(m). Applying the logarithm to the inequality gives the result.) In addition, we can scale the function to make the bounds tighter. Consider the function 1tLSE(tx1,…,txn). Then max⁡{x1,…,xn}<1tLSE(tx1,…,txn)≤max⁡{x1,…,xn}+log⁡(n)t. (Proof: Replace each xi with txi for some t>0 in the inequalities above, to give max⁡{tx1,…,txn}<LSE(tx1,…,txn)≤max⁡{tx1,…,txn}+log⁡(n). and, since t>0 tmax⁡{x1,…,xn}<LSE(tx1,…,txn)≤tmax⁡{x1,…,xn}+log⁡(n). finally, dividing by t gives the result.) Also, if we multiply by a negative number instead, we of course find a comparison to the min function: min⁡{x1,…,xn}−log⁡(n)t≤1−tLSE(−tx)<min⁡{x1,…,xn}. The LogSumExp function is convex, and is strictly increasing everywhere in its domain. It is not strictly convex, since it is affine (linear plus a constant) on the diagonal and parallel lines:

LSE(x1+c,…,xn+c)=LSE(x1,…,xn)+c. Other than this direction, it is strictly convex (the Hessian has rank ⁠n−1⁠), so for example restricting to a hyperplane that is transverse to the diagonal results in a strictly convex function. See LSE0+, below. Writing 𝐱=(x1,…,xn), the partial derivatives are: ∂∂xiLSE(𝐱)=exp⁡xi∑jexp⁡xj, which means the gradient of LogSumExp is the softmax function. The convex conjugate of LogSumExp is the negative entropy. In tropical analysis, LogSumExp is the sum in the log semiring.

log-sum-exp trick for log-domain calculations The LSE function is often encountered when the usual arithmetic computations are performed on a logarithmic scale, as in log probability. Similar to multiplication operations in linear-scale becoming simple additions in log-scale, an addition operation in linear-scale becomes the LSE in log-scale: LSE(log⁡(x1),...,log⁡(xn))=log⁡(x1+⋯+xn) A common purpose of using log-domain computations is to increase accuracy and avoid underflow and overflow problems when very small or very large numbers are represented directly (i.e. in a linear domain) using limited-precision floating point numbers. Unfortunately, the use of LSE directly in this case can again cause overflow/underflow problems. Therefore, the following equivalent must be used instead (especially when the accuracy of the above 'max' approximation is not sufficient). LSE(x1,…,xn)=x∗+log⁡(exp⁡(x1−x∗)+⋯+exp⁡(xn−x∗)) where x∗=max⁡{x1,…,xn} Many math libraries such as IT++ provide a default routine of LSE and use this formula internally.

A strictly convex log-sum-exp type function LSE is convex but not strictly convex. We can define a strictly convex log-sum-exp type function by adding an extra argument set to zero: LSE0+(x1,...,xn)=LSE(0,x1,...,xn) This function is a proper Bregman generator (strictly convex and differentiable). It is encountered in machine learning, for example, as the cumulant of the multinomial/binomial family.

See also Logarithmic mean Log semiring Smooth maximum Softmax function

References

Illustrations

LogSumExp: Graph of LSE(x,−x) compared to max⁡(x,−x)
Graph of LSE(x,−x) compared to max⁡(x,−x)

Worked examples

Example 1 — a first encounter with LogSumExp

Start with the simplest possible case. Write down what LogSumExp claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to LogSumExp before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about LogSumExp ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of LogSumExp

In research
LogSumExp appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses LogSumExp in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
LogSumExp is common in secondary-school and first-year university syllabi. It links to neighbouring topics Exponentials, Logarithms, so understanding it makes those chapters shorter.
In everyday life
Look for LogSumExp outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “LogSumExp” →

How to study LogSumExp in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what LogSumExp means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain LogSumExp out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is LogSumExp in simple terms?

The LogSumExp (LSE) (also called RealSoftMax or multivariable softplus) function is a smooth maximum – a smooth approximation to the maximum function, mainly used by machine learning algorithms. It is defined as the logarithm of the sum of the exponentials of the arguments: LSE(x1,…,xn)=log⁡(exp⁡(x…

Why does LogSumExp matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study LogSumExp?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on LogSumExp.

Tags

  • Exponentials
  • Logarithms

Keep exploring