# physics/expectation-expand

Expand expectation-value helpers to explicit angle brackets.

https://texform.dev/rules/physics/expectation-expand

## Metadata

| Field | Value |
| --- | --- |
| Key | physics/expectation-expand |
| Level | faithful |
| Fidelity | render |
| Enabled by packages | physics |
| Profiles | Faithful, Corpus, Equiv |

## Rewrite patterns

### expectation-body-auto-sized

From:

```latex
\ev{#1}
```

To:

```latex
\left\langle #1 \right\rangle
```

### expectation-body-fixed-size

From:

```latex
\ev*{#1}
```

To:

```latex
\langle #1 \rangle
```

### expectation-state-auto-sized

From:

```latex
\ev{#1}{#2}
```

To:

```latex
\left\langle #2 \right\vert #1 \left\vert #2 \right\rangle
```

### expectation-state-fixed-size

From:

```latex
\ev*{#1}{#2}
```

To:

```latex
\langle #2 \vert #1 \vert #2 \rangle
```

### expectation-state-middle-sized

From:

```latex
\ev**{#1}{#2}
```

To:

```latex
\left\langle #2 \middle\vert #1 \middle\vert #2 \right\rangle
```

## Examples

Examples show the rule in isolation, not a complete normalization profile.

### Expectation state label

Before:

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

After this rule:

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

Packages: base, physics.

Rendering verified with the declared packages.

### Expectation state argument

Before:

```latex
\ev{H}{\psi}=E_0
```

After this rule:

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

Packages: base, physics.

Rendering verified with the declared packages.

### Expectation star body fixed size

Before:

```latex
\ev*{A(t)}
```

After this rule:

```latex
\langle A(t) \rangle
```

Packages: base, physics.

Rendering verified with the declared packages.

### Expectation star state fixed size

Before:

```latex
\ev*{H}{\psi}
```

After this rule:

```latex
\langle \psi \vert H \vert \psi \rangle
```

Packages: base, physics.

Rendering verified with the declared packages.

### Expectation double star state middle sized

Before:

```latex
\ev**{H}{\psi}
```

After this rule:

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

Packages: base, physics.

Rendering verified with the declared packages.

## Triggers

- [\\ev](https://texform.dev/latex/commands/ev)

## Eliminates

- [\\ev](https://texform.dev/latex/commands/ev)

## Produces

- [\\left](https://texform.dev/latex/commands/left)
- [\\middle](https://texform.dev/latex/commands/middle)
- [\\right](https://texform.dev/latex/commands/right)

## Same family

- [physics/matrixel-expand](https://texform.dev/rules/physics/matrixel-expand): Expand matrix elements to explicit angle-bracket and bar fences.
- [physics/physics-bra-expand](https://texform.dev/rules/physics/physics-bra-expand): Expand bra to an explicit angle-bracket and bar fence form.
- [physics/physics-braket-expand](https://texform.dev/rules/physics/physics-braket-expand): Expand braket to an explicit angle-bracket form with a middle bar.
- [physics/physics-ket-expand](https://texform.dev/rules/physics/physics-ket-expand): Expand ket to an explicit bar and angle-bracket fence form.
- [physics/commutator-expand](https://texform.dev/rules/physics/commutator-expand): Expand commutators to explicit square-bracket fences.
- [physics/poisson-bracket-expand](https://texform.dev/rules/physics/poisson-bracket-expand): Expand poisson brackets to explicit brace fences.

## 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

```python
TransformEngine(profile="corpus", disable_rules=["physics/expectation-expand"])
```

```javascript
new TransformEngine({ profile: 'corpus', disableRules: ['physics/expectation-expand'] })
```

[Open in Playground](https://play.texform.dev/?input=%5Cev%7BH%7D_%7B%5Cpsi%7D%3DE_0)
