# Boundary conditions for the numerical particle in a box example

I want to solve the one-dimensional Schrödinger equation for the particle in a box example, and want to force the wavefunctions to zero on the boundaries. I am using the matrix, $$\hat{H} = \begin{pmatrix} 2t & -t & & & & \\ -t & 2t & -t & & & \\ & -t & 2t & -t & & \\ & & & \cdots \\ & & & & -t & 2t \end{pmatrix}_{N\times N}$$ which implicitly sets $\psi_0=\psi_{N+1}=0$.

This, however, does not mean that the wavefunction is zero on the boundaries. It means that the wavefunction is $close$ to zero there, and the above eigenvalue equation gives significantly large $\psi_1$ and $\psi_N$ values for coarse grids.

I can increase $H(1,1)$ (and $H(2,2)$) to model a stronger coupling between $\psi_1$ and $\psi_0$, therefore moving $\psi_1$ arbitrarily close to zero. But there are two problems with this idea:

1. It causes instabilities in the eigenvalue solver for very large $H(1,1)$ and $H(2,2)$ values.

2. The solution becomes closer to zero on boundaries, but is not exactly zero.

Do you know how I can solve this problem?

• Have you considered identifying grid points $0$ and $N+1$ as the boundary points? – Johannes Jul 14 '17 at 12:11

I don't see how the way you wrote the Hamiltonian sets $\Psi_0$ and $\Psi_N$ to $0$.
In matrix form, wouldn't the boundary conditions you mention simply appear as $H_{1,1}=1$, $H_{1,i \neq 1} = 0$ and $H_{N,N} = 1$, $H_{N,i \neq N}= 0$?