Let us look at a problem we can solve exactly.

A particle of mass m moves in the potential energy function

U(x) = ∞, x < 0, x > a,

U(x) = 0, 0 < x < a.

The energy eigenfunctions are Φ_{n}(x) = (2/a)^{½}sin(nπx/a)

with eigenvalues E_{n} =
n^{2}π^{2}ħ^{2}/(2ma^{2}), n = 1,
2, 3, ... .

k = 2π/λ = nπ/a, a = nλ/2.

∫_{0}^{a }k dx = (2π/λ) ∫_{0}^{a }dx = (2π/λ)(nλ/2)
= nπ for the eigenfunctions are Φ_{n}(x).

∫_{0}^{a }(2/λ)dx = n, n counts the number of
half-wavelength or the number of anti-nodes of the wave function in the well.

If U(x) = finite, x < 0 or x > a, the the wave function does
not go to zero at the finite edge, but extends into the classically forbidden
region.

Therefore ∫_{0}^{a }(2/λ)dx = n - ε, where ε depends on the
exact nature of the edge(s).