Skip to content
advanced

Deriving Soft Bellman Equations From the Entropy-Regularized Objective

You add an entropy bonus to your objective, and the whole value structure shifts under your feet. The max in the Bellman backup becomes a log-sum-exp. The…

Published 2026-10-02Updated 2026-10-0410 min read
Colorful bird perched on a log in a natural setting with lush greenery.
Colorful bird perched on a log in a natural setting with lush greenery. Photo by Siegfried Poepperl on Pexels.

You add an entropy bonus to your objective, and the whole value structure shifts under your feet. The max in the Bellman backup becomes a log-sum-exp. The greedy policy becomes a softmax. The temperature stops acting like a learning-rate knob and starts acting like a price. None of that is a bug in your implementation. It is what happens when entropy moves inside the return instead of sitting beside it.

This article derives that shift. I assume you already have the standard Bellman expectation and optimality relationships and the likelihood-ratio policy-gradient estimator in hand. Here I derive only the delta: where the entropy term enters the objective, how it propagates into the value definitions, why the optimality backup becomes a log-sum-exp, and what the temperature actually means.

Why the Entropy Term Cannot Stay Outside the Value Function

The weak model most people carry is this: entropy is an exploration bonus. You keep your value functions exactly as they were, and you add a bonus gradient term to the policy update. The bonus nudges the policy toward diversity early in training, then fades as the policy converges.

That model works for exactly one job — keeping a policy from collapsing onto a premature deterministic solution while the critic is still wrong. It fails the moment you ask what the optimal policy looks like under the augmented objective. If entropy is part of the return, then the value of a state must already account for the entropy the policy will collect in the future. You cannot compute a value that ignores a term that appears in every future step's return.

So the reframe: entropy regularization changes the return definition, and therefore changes the Bellman operator itself. The value functions are not unchanged. They are redefined.

Here is the notation I will use throughout. State s∈Ss \in \mathcal{S}, action a∈Aa \in \mathcal{A}, transition kernel P(s′∣s,a)P(s' \mid s, a), reward r(s,a)r(s, a), discount γ∈[0,1)\gamma \in [0, 1), policy π(a∣s)\pi(a \mid s), and temperature α>0\alpha > 0. The temperature is a scalar weight on the entropy term. It is not a property of the environment.

Writing the Entropy-Regularized Objective

The augmented per-step return adds a temperature-weighted entropy term to the reward:

r~(s,a)=r(s,a)+α H(π(⋅∣s))\tilde{r}(s, a) = r(s, a) + \alpha \, \mathcal{H}\big(\pi(\cdot \mid s)\big)

where H(π(⋅∣s))=−∑aπ(a∣s)log⁡π(a∣s)\mathcal{H}(\pi(\cdot \mid s)) = -\sum_a \pi(a \mid s) \log \pi(a \mid s) is the Shannon entropy of the policy at state ss. The full objective maximizes the expected discounted sum of r~\tilde{r} over trajectories.

The general form replaces Shannon entropy with the KL divergence to a reference policy pp:

H(π(⋅∣s) ∥ p(⋅∣s))=−∑aπ(a∣s)log⁡π(a∣s)p(a∣s)\mathcal{H}\big(\pi(\cdot \mid s) \,\|\, p(\cdot \mid s)\big) = -\sum_a \pi(a \mid s) \log \frac{\pi(a \mid s)}{p(a \mid s)}

Shannon entropy is the special case where pp is uniform. The general form matters for derivations because it keeps the reference policy explicit, and because it is the form that survives when you want a policy to stay near a prior rather than spread uniformly.

State the assumptions before the algebra, because they are load-bearing:

  • Finite action space. The closed-form log-sum-exp and Boltzmann policy below require a finite A\mathcal{A}. Continuous actions lose the closed form.
  • Finite return. Either episodic or discounted, so the sum of rewards and entropies is finite.
  • Differentiable, strictly positive policy. A policy that assigns zero probability to an action makes log⁡π\log \pi unbounded, and the derivation breaks.

Common mistake: Treating the temperature as a property of the environment. It is a scalar you choose, and it sets the exchange rate between reward and stochasticity. Change it and you change the optimal policy, not just the learning dynamics.

Deriving the Soft Value Functions

Start from the entropy-augmented return and take the expectation under the policy. The soft state value is:

Vπ(s)=Eπ[∑t=0∞γt(r(st,at)+α H(π(⋅∣st))) ∣ s0=s]V^\pi(s) = \mathbb{E}_{\pi}\left[\sum_{t=0}^{\infty} \gamma^t \big(r(s_t, a_t) + \alpha \, \mathcal{H}(\pi(\cdot \mid s_t))\big) \,\Big|\, s_0 = s\right]

The soft action value is the same expectation conditioned on the first action:

Qπ(s,a)=r(s,a)+γ Es′∼P[Vπ(s′)]Q^\pi(s, a) = r(s, a) + \gamma \, \mathbb{E}_{s' \sim P}\big[V^\pi(s')\big]

Notice what is absent from QπQ^\pi: the entropy term at the current step. The action aa is already chosen, so the current-step entropy does not depend on it. This is the single most common place readers expect a term that is not there. The entropy term attaches at the successor state, not the current action.

The relationship between soft VV and soft QQ follows from the definition of the expectation:

Vπ(s)=Ea∼π[Qπ(s,a)]−α Ea∼π[log⁡π(a∣s)]V^\pi(s) = \mathbb{E}_{a \sim \pi}\big[Q^\pi(s, a)\big] - \alpha \, \mathbb{E}_{a \sim \pi}\big[\log \pi(a \mid s)\big]

That is an expectation of QQ minus temperature times log-policy — not a plain expectation of QQ. Compare it to the standard relationship Vπ(s)=Ea∼π[Qπ(s,a)]V^\pi(s) = \mathbb{E}_{a \sim \pi}[Q^\pi(s, a)] and you can see exactly which term was inserted and where.

A backup diagram makes the placement concrete. Draw the reward node and the successor value node as usual. Attach the entropy node at the successor state, hanging off the policy that selects the next action — not off the current action.

Knowledge check

Check your understanding

Answer this question before you continue.

Why does the stated definition of $Q^\pi(s,a)$ omit an entropy term for the current state?
Misconception Check

Focus: Distinguish the current-step entropy contribution to the soft state value from the definition of the soft action value conditioned on the current action.

Deriving the Soft Bellman Equations

Substitute the soft QQ definition into the soft VV definition and expand one step. You get the soft Bellman expectation equation:

Vπ(s)=Ea∼π[r(s,a)+α H(π(⋅∣s))+γ Es′∼P[Vπ(s′)]]V^\pi(s) = \mathbb{E}_{a \sim \pi}\Big[r(s, a) + \alpha \, \mathcal{H}(\pi(\cdot \mid s)) + \gamma \, \mathbb{E}_{s' \sim P}\big[V^\pi(s')\big]\Big]

Now maximize the right-hand side over the policy. This is the key algebraic move. You are maximizing an expectation of QQ minus temperature times log-policy over the probability simplex:

max⁡π  Ea∼π[Q(s,a)]−α Ea∼π[log⁡π(a∣s)]\max_{\pi} \; \mathbb{E}_{a \sim \pi}\big[Q(s, a)\big] - \alpha \, \mathbb{E}_{a \sim \pi}\big[\log \pi(a \mid s)\big]

The solution is a Boltzmann distribution:

π∗(a∣s)=exp⁡(Q(s,a)/α)∑a′exp⁡(Q(s,a′)/α)\pi^*(a \mid s) = \frac{\exp\big(Q(s, a) / \alpha\big)}{\sum_{a'} \exp\big(Q(s, a') / \alpha\big)}

and the resulting value is temperature times log-sum-exp:

V∗(s)=αlog⁡∑aexp⁡(Q(s,a)/α)V^*(s) = \alpha \log \sum_a \exp\big(Q(s, a) / \alpha\big)

This is the soft Bellman optimality equation. The max operator is gone, replaced by a smooth, differentiable approximation that reduces to the hard max as α→0\alpha \to 0.

The soft Bellman backup is a contraction under the same discounting conditions as the standard operator, which is what makes soft policy iteration well-defined. The proof follows the same structure as the standard contraction argument, with the entropy term bounded because the policy is bounded.

A Two-Action Worked Example

Two action values, 2 and 0, feed a softmax at temperature 1, producing probabilities 0.881 and 0.119; the resulting soft value is 2.127, compared with the hard maximum of 2.
The lower-valued action still receives probability under the soft backup, lifting the value above the hard maximum.

Take a state with two actions and Q(s,a1)=2Q(s, a_1) = 2, Q(s,a2)=0Q(s, a_2) = 0. Set α=1\alpha = 1.

The soft value is:

V∗(s)=1⋅log⁡(e2+e0)=log⁡(7.389+1)=log⁡(8.389)≈2.127V^*(s) = 1 \cdot \log\big(e^{2} + e^{0}\big) = \log(7.389 + 1) = \log(8.389) \approx 2.127

The Boltzmann policy is:

π∗(a1∣s)=e2e2+e0≈0.881,π∗(a2∣s)≈0.119\pi^*(a_1 \mid s) = \frac{e^{2}}{e^{2} + e^{0}} \approx 0.881, \qquad \pi^*(a_2 \mid s) \approx 0.119

The hard-max value is max⁡(2,0)=2\max(2, 0) = 2. The soft value is higher — 2.1272.127 — because the entropy term rewards keeping the second action alive. Now shrink the temperature to α=0.1\alpha = 0.1:

V∗(s)=0.1log⁡(e20+e0)≈0.1⋅20=2.0V^*(s) = 0.1 \log\big(e^{20} + e^{0}\big) \approx 0.1 \cdot 20 = 2.0

The gap closes. The policy concentrates: π∗(a1∣s)≈0.9999\pi^*(a_1 \mid s) \approx 0.9999. As α→0\alpha \to 0, the soft equations recover the standard Bellman equations, and the Boltzmann policy recovers the greedy argmax.

Knowledge check

Check your understanding

Answer this question before you continue.

For the worked example with $Q(s,a_1)=2$, $Q(s,a_2)=0$, and $\alpha=1$, approximately what probability does the optimal soft policy assign to $a_1$?
Scenario Interpretation

Focus: Use the Boltzmann policy equation to interpret the probability assigned to the higher-valued action in the worked two-action example.

Reading the Temperature as a Mathematical Object

The temperature scales the entropy term relative to reward. It sets the exchange rate between expected reward and policy stochasticity. Two limits define its behavior:

  • α→0\alpha \to 0: the Boltzmann policy concentrates on the argmax, and the soft equations recover the standard Bellman equations.
  • α→∞\alpha \to \infty: the policy flattens toward uniform, and reward stops mattering.

The temperature is also the dual variable of a constrained problem. Maximize reward subject to an entropy floor, and the Lagrangian produces the same objective with a temperature determined by the constraint. That is why automatic temperature tuning is a dual ascent step — you are solving for the multiplier that satisfies the constraint, not guessing a hyperparameter.

Note: The temperature is not a learning rate. It changes the optimum, not the step size toward the optimum. A learning rate controls how fast you move; the temperature controls where you are moving to.

The failure modes are symmetric. A fixed temperature that is too high makes the optimal policy deliberately suboptimal in reward terms — it will leave reward on the table to stay stochastic. A temperature that is too low reintroduces the deterministic collapse the entropy term was meant to prevent.

Knowledge check

Check your understanding

Answer this question before you continue.

According to the temperature limits in the article, what happens as $\alpha \to \infty$?
Comparison Reasoning

Focus: Predict how the optimal policy and reward sensitivity change as the entropy temperature becomes very large.

When Stochasticity Is Rewarded, Not Just Used

Exploration stochasticity is a means to gather data. It vanishes at convergence. Optimality stochasticity is part of the objective. It persists at convergence.

The soft optimal policy is stochastic even when the environment is deterministic and the reward is deterministic, because the entropy term is inside the return. This is the practical payoff of the derivation: the stochasticity is not a training artifact you anneal away. It is the answer.

When this is genuinely useful:

  • Multi-modal action distributions where several actions are near-equally good, and committing to one mode is arbitrary.
  • Robustness to perturbation, where a policy that spreads probability across near-optimal actions degrades more gracefully.
  • Settings where a deterministic policy would overcommit to one mode before the critic has resolved the others.

When it is the wrong tool:

  • Tasks with a single correct action where any deviation is costly. The entropy term will trade reward for diversity you do not want.
  • Fixed temperature without regard to reward scale. A temperature tuned for one reward scale is wrong for another.
Standard BellmanSoft Bellman
Backup operatormax⁡aQ(s,a)\max_a Q(s, a)αlog⁡∑aexp⁡(Q(s,a)/α)\alpha \log \sum_a \exp(Q(s, a)/\alpha)
Optimal policyDeterministic argmaxBoltzmann distribution
Value definitionV=Eπ[Q]V = \mathbb{E}_\pi[Q]V=Eπ[Q]−αEπ[log⁡π]V = \mathbb{E}_\pi[Q] - \alpha \mathbb{E}_\pi[\log \pi]
Temperature roleNoneExchange rate between reward and entropy

Knowledge check

Check your understanding

Answer this question before you continue.

A deterministic environment has deterministic rewards, but its entropy-regularized optimal policy remains stochastic at convergence. Which explanation matches the article?
Misconception Check

Focus: Explain why entropy regularization can make a stochastic policy optimal even in a deterministic environment.

From the Derivation to the Algorithm

The soft Bellman backup is the target the critic regresses toward. That is why entropy-regularized critics use a log-policy term in the target rather than a plain reward plus discounted value. The Boltzmann policy from the optimality derivation is the form the actor is pushed toward, which is why entropy-regularized actors are stochastic by construction.

I will stop at the equations here. The learning loop that turns these into an algorithm, and the continuous-control experiment that exercises them, are separate steps.

To verify the derivation against output rather than trusting it, implement the two-action example in a few lines:

import numpy as np

Q = np.array([2.0, 0.0])
alpha = 1.0

V_soft = alpha * np.log(np.sum(np.exp(Q / alpha)))
pi_soft = np.exp(Q / alpha) / np.sum(np.exp(Q / alpha))
V_hard = np.max(Q)

print(f"soft V: {V_soft:.4f}, hard V: {V_hard:.4f}")
print(f"policy: {pi_soft}")

Run it. Change alpha to 0.1 and watch the soft value converge to the hard value and the policy concentrate. The numbers should match the hand calculation above. If they do not, the derivation or the code has a bug — and finding which one is the point.

The test for whether stochasticity belongs in your objective is simple: does it survive at convergence? If it vanishes, it was exploration. If it persists, it was part of the return. Run the soft backup numerically against the standard one on a small problem, and let the gap between them tell you which regime you are in.

Knowledge check

Final check

Finish the article by checking the ideas you just learned.

In the article's generalized regularizer $-\sum_a \pi(a\mid s)\log\frac{\pi(a\mid s)}{p(a\mid s)}$, what does choosing a uniform reference policy $p$ recover?
Question 1 of 2Single Choice

Focus: Identify the relationship between the generalized KL-based regularizer and Shannon entropy when the reference policy is uniform.

Which pairing best matches the article's derivation to the algorithmic roles of critic and actor?
Question 2 of 2Comparison Reasoning

Focus: Connect the soft Bellman and policy optimality derivations to the roles of critic and actor in an entropy-regularized algorithm.

References

  1. [1812.05905] Soft Actor-Critic Algorithms and Applicationsar5iv.labs.arxiv.org
  2. Ground States of Quantum Many Body Lattice Models via ...proceedings.mlr.press
Practical resource

Build a stronger RL mental model

Use structured resources to connect equations, algorithms, and observable agent behavior.

Browse resources
Related sites

Continue across related AI foundations

Use LearnPyFast for Python foundations and LearnLLMFast for practical language-model and agent application concepts.

Python tutorialstutorial

LearnPyFast

Beginner-friendly Python tutorials, examples, and learning paths for practical programming foundations.

PythonProgrammingBeginners
Visit LearnPyFast
LLM tutorialstutorial

LearnLLMFast

Practical LLM tutorials for builders who want to understand prompting, workflows, agents, and AI applications.

LLMAIBuilders
Visit LearnLLMFast

Keep learning

Related reinforcement learning tutorials

Continue with nearby RL concepts, algorithms, and experiments that build on the same decision process.