For a particle in an infinite square well with its left-hand edge at the origin (see Figure 1.), the potential $V(x)$ is defined as
\[ V(x) = \begin{cases}0, \textrm{ if } 0 \leq x \leq L \tag{1} \label{Eq:V=0}\\ \infty, \textrm{ otherwise} \end{cases} \]
Once again, the wave function $\Psi(x)$ outside the well is set to zero with
\[ \Psi(x) = 0 \text { when } x<0 \text{ or } x>L \]
In order to have $\Psi(x)$ remain continuous, the Dirichlet boundary conditions are set as
\[ \Psi(0)=\Psi(L) = 0 \notag \]
No restriction for continuity is made on $d \Psi(x)/dx $ at the boundary.
In the majority of introductory textbooks, the general solution to the Time-Independent Schrodinger equation for the potential given by Eq.$\eqref{Eq:V=0}$ is given as
\[ \Psi(x) = A \cos kx + B \sin kx \qquad A,B \in \mathbb{R} \]
with
\[ k=\sqrt{\frac{2mE}{\hbar^2}} \tag{2} \label{Eq:k} \]
Applying the boundary condition $\Psi(0)=0$ eliminates the constant $A$ which leaves
\[ \Psi(x) = B \sin kx \notag \]
In order for $\Psi(L)=0$,
\[ kL = n \pi \]
thereby giving
\[ k_{n} = \frac{n \pi}{L}, \text{ with } n=1,2,3, \dots \]
From Eq.$\eqref{Eq:k}$, the energy E is quantized as
\[ E_{n} =\frac{n^{2} \pi ^{2} \hbar^{2}}{2mL^{2}} \label{Eq:E1} \]
The constant $B$ is found by normalizing $\Psi(x)$ as
\[ \int_{0}^{L} \Big | \Psi(x) \Big |^2 dx = 1 \notag \]
which gives
\[ B= \sqrt{\frac{2}{L}} \notag \]
Finally, the wave solution for the particle in the infinite square well is given by
\[ \Psi_{n}(x) = \sqrt {\frac{2}{L}} \sin \Big( \frac{n \pi}{L}x \Big ) \qquad n= \pm 1, \pm 2, \pm 3, \dots \label{Eq:StdSolution} \]