Rewrite Rulesphysics/expectation-expand

physics/expectation-expand

Expand expectation-value helpers to explicit angle brackets.

Rewrite patterns#

  1. expectation-body-auto-sized\ev{#1}\left\langle #1 \right\rangle
  2. expectation-body-fixed-size\ev*{#1}\langle #1 \rangle
  3. expectation-state-auto-sized\ev{#1}{#2}\left\langle #2 \right\vert #1 \left\vert #2 \right\rangle
  4. expectation-state-fixed-size\ev*{#1}{#2}\langle #2 \vert #1 \vert #2 \rangle
  5. expectation-state-middle-sized\ev**{#1}{#2}\left\langle #2 \middle\vert #1 \middle\vert #2 \right\rangle

Examples#

Each example shows this rule applied in isolation. A complete normalization profile may make additional changes.

Expectation state label#

Before

\ev{H}_{\psi}=E_0

After this rule

\left\langle H \right\rangle_{\psi}=E_0

Rendering verified with the declared packages.

Expectation state argument#

Before

\ev{H}{\psi}=E_0

After this rule

\left\langle \psi \right\vert H \left\vert \psi \right\rangle=E_0

Rendering verified with the declared packages.

Expectation star body fixed size#

Before

\ev*{A(t)}

After this rule

\langle A(t) \rangle

Rendering verified with the declared packages.

Expectation star state fixed size#

Before

\ev*{H}{\psi}

After this rule

\langle \psi \vert H \vert \psi \rangle

Rendering verified with the declared packages.

Expectation double star state middle sized#

Before

\ev**{H}{\psi}

After this rule

\left\langle \psi \middle\vert H \middle\vert \psi \right\rangle

Rendering verified with the declared packages.

Same family#

Notes#

Covers body-only and braced-state branches. The second star only changes the braced-state branch; body-only double-star input renders like the single-star body branch.

Disable this rule#

TransformEngine(profile="corpus", disable_rules=["physics/expectation-expand"])
new TransformEngine({ profile: 'corpus', disableRules: ['physics/expectation-expand'] })

Open in Playground