Calculates the wavefunction of a single particle in a finite potential