Solution (source code)

= Solution

Write the <expectation value> as
$$
\langle O\rangle_\psi=\langle\psi|O|\psi\rangle.
$$
Differentiating and retaining the possible explicit time dependence of the <observable> gives
$$
\frac d{dt}\langle O\rangle_\psi
=\langle\dot\psi|O|\psi\rangle
+\left\langle\psi\middle|\frac{\partial O}{\partial t}\middle|\psi\right\rangle
+\langle\psi|O|\dot\psi\rangle.
$$
The <Schrödinger equation> and its adjoint are
$$
i\hbar|\dot\psi\rangle=H|\psi\rangle,
\qquad
-i\hbar\langle\dot\psi|=\langle\psi|H,
$$
where the <Hamiltonian operator> is Hermitian. Substitution yields
$$
\begin{aligned}
\frac d{dt}\langle O\rangle_\psi
&=\frac i\hbar\langle\psi|HO|\psi\rangle
-\frac i\hbar\langle\psi|OH|\psi\rangle
+\left\langle\frac{\partial O}{\partial t}\right\rangle_\psi\\
&=\boxed{\frac i\hbar\langle[H,O]\rangle_\psi
+\left\langle\frac{\partial O}{\partial t}\right\rangle_\psi}.
\end{aligned}
$$
This is the <proof of Ehrenfest theorem from the Schrodinger equation>.