I want to compute the expectation value of the energy $\langle H \rangle$ for a quantum system with the wave function $\psi(x)$. This is done with $$\langle H \rangle = \int_{-\infty}^{\infty} \psi^* \hat{H} \psi d x$$ where $$\hat{H} = - \frac{\hbar^2}{2 m} \frac{d^2}{d x^2} + V(x)$$ is the Hamiltonian operator for some potential $V(x)$. How do I express $\frac{d}{d x}$ in sage if I don't know on which function it will be applied?