I am trying to numerically find eigenstates of an Hamiltonian. Let $V(x)$ be some potential. Suppose my space is between $-L,L$ and that the allowed positions are every $\Delta x$, such that $\frac{1}{\Delta x}$ is some natural number $N$. I want to write the Hamiltonian, in this case $$ H = -\frac{\hbar^2}{2m}\frac{\partial^2}{\partial x^2} + V(x) $$ discretely, and then represent it as an $N\times N$ matrix in the discrete position basis. How can I transfer the continuous Hamiltonian to a discrete one?