---
title: "Brackets, scope, and operator precedence"
description: "Mark where each operator starts and stops before attempting a calculation."
canonical_url: "https://fanout.sh/ml-math/decoder/brackets-scope-and-operator-precedence"
md_url: "https://fanout.sh/ml-math/decoder/brackets-scope-and-operator-precedence.md"
last_updated: "2026-10-31"
access: "public"
---

# Brackets, scope, and operator precedence

Mark where each operator starts and stops before attempting a calculation.

Mark where each operator starts and stops before attempting a calculation.

## Notes

### Map the scope before calculating

Draw nested scope shells from the outside inward, then execute them from the innermost valid object back outward.

#### Execute inside out

$$-\log\left(p_\theta(y\mid x)\right)$$

Evaluate the conditional model probability first, take its logarithm second, and negate that logarithm last; if the probability is one quarter, the result is log four.

#### Keep the minus outside

$$\log(-p_\theta(y\mid x))$$

Tempting reading: Moving the leading minus inside the logarithm because it is written before log.

Preserve the scope shells

The actual operand of log is a positive probability. Moving the minus inward changes the expression and asks the real logarithm to accept a negative input.

#### Add the expectation last

$$\mathbb{E}_{(x,y)\sim\mathcal{D}}[-\log p_\theta(y\mid x)]$$

A training objective wraps negative log probability in an expectation over data.

List the execution order

Keep the negative-log shells intact, then add expectation as the new outer scope: probability first, log second, negate third, average last.

---
This representation contains public Fanout content only. Protected Pro lessons, account data, billing, checkout, and pricing are not included.

Browse the public content map: https://fanout.sh/sitemap.md
