Solution (source code)

= Solution

For a normalized state, the <expectation value> is
$$
\boxed{\langle Q\rangle=\langle\psi|Q|\psi\rangle=\int\psi^*(x,t)\,Q\psi(x,t)\,dx.}
$$
For a time-independent operator, differentiation gives
$$
\frac d{dt}\langle Q\rangle=\langle\dot\psi|Q|\psi\rangle+\langle\psi|Q|\dot\psi\rangle.
$$
The <Schrödinger equation> says $|\dot\psi\rangle=-iH|\psi\rangle/\hbar$. The <self-adjointness> of $H$ gives $\langle\dot\psi|=i\langle\psi|H/\hbar$, so
$$
\frac d{dt}\langle Q\rangle=\frac i\hbar\langle HQ-QH\rangle=\boxed{\frac1{i\hbar}\langle[Q,H]\rangle.}
$$
In the <integral> derivation, the same <self-adjointness> step is integration by parts with vanishing boundary terms. An explicitly time-dependent observable would also contribute $\langle\partial Q/\partial t\rangle$. These are the expectation-value equations underlying the <Heisenberg equation of motion>.