Why does the energy of an electron depend on the size of the well? In the square well the energy states of the electron depend on the width of the square well. That means that by changing the physical shape of the confinement region (making it a parabolic well) or making the width twice as big, or twice as small, would affect the observable energy states of the electron.
Maybe I just forgot, or maybe I never-stood why this should be the case? I don't think there's a classical analog to this QM affect? If I stick a soccer ball in my book bag vs in my garage vs in my house. The ball doesn't get more or less energy depending on where I confine it. Yet, the electron seemingly gets more kinetic energy. At least in a infinite square well, with zero potential. If I make the width smaller the energy goes up. So why not do this forever, and make the electron have infinite energy? Sorry that's a question in a question.
 A: Others have pointed out the basics:

*

*The energy of a particle depends on its frequency $E=\hbar\omega$.

*Stationary bound states of an infinite square well form standing waves based on the width of the well.

*The width of the well sets the longest wavelength $\rightarrow$ lowest frequency $\rightarrow$ lowest energy available to the particle.

So why can't you squeeze the box and get infinite energy by raising the ground state?  The energy gained by the electron has to come from somewhere.
In fact it takes energy to change the size of the box.  Imagine the infinite square well has one moveable wall.  The work you do to move the wall will be transferred to the electron wave in the box.  You can figure out how much work you need to do, just from thinking about how the electron's energy changes.
This is analogous to the work you do on a box of gas in thermodynamics.  When you squeeze a box of gas, it takes work to overcome the pressure and maybe raise the internal energy of the gas.
Assuming the electron stays in the $n=1$ ground state the whole time while you squeeze the box:
$$W = \Delta E = E_f - E_i = \frac{\pi^2\hbar^2}{2 m_e}\left[\frac{1}{L_f^2}-\frac{1}{L_i^2} \right].$$
Taking the limit that $L_f\rightarrow 0$, we see it would take infinite work to compress the box all the way to zero.
A: You need to fulfill the boundary conditions, which are $\psi(0)=0$ and $\psi(L)=0$ with $L$ being the width of the well with infinite high walls.
Consider the one-dimensional and stationary Schrödinger equation for vanishing potential:
\begin{equation}
-\frac{\hbar^2}{2m}\psi''(x)
=E\psi(x)
\end{equation}
(The stationary Schrödinger equation for vanishing potential is a Helmholtz equation mathmatically. Since the Laplace operator only has negative eigenvalues and $m>0$, we have $E>0$.) A solution is of the form $\psi(x)=A\sin(ax)+B\cos(bx)$. The boundary condition $\psi(0)=0$ immediatly yields $B=0$, so $\psi(x)=A\sin(ax)$. Putting this into the upper equation yields:
\begin{equation}
E=\frac{\hbar^2}{2m}a^2
\end{equation}
Since we have the boundary condition $\psi(L)=0$ left, $a$ can't be arbitrary. ($A$ can't be as well, since $\psi$ has to be normed with $\|\psi\|_{L^2}=1$.) We get:
\begin{equation}
\psi(L)=A\sin(aL)\stackrel{!}{=}0
\Rightarrow\mathop{\exists}_{n\in\mathbb{N}}\colon
aL=n\pi
\Rightarrow
E=\frac{\pi^2\hbar^2}{2mL^2}n^2
\end{equation}
The energy is therefore dependend on the width $L$ and also the new quantum number $n$ giving rise to the quantization of energy. I also remembered a nice little cartoon explaing this, but couldn't find it again, so I just drew it myself:

A: The quintessence of non-relativistic quantum mechanics is that microscopic objects do not behave as classical particles, where for the latter we do not expect quantised energy levels if they are confined within a certain region. (Such a confined region is what the 'infinite well' simulates, although in the end it is of course unrealistic, since there are no infinite potentials). I am sure you saw the math: The Schroedinger equation asks for a wave like solution to the problem, and a wave that is zero at the boundaries can only have discrete number of crests and nodes, corresponding to the allowed energy levels of the electron.
If the electron would be in a well that is much much wider than the typical wavelength corresponding to the electron, the energy levels would also get closer and closer. Remember that the energy levels scale with the square of the inverse of the well's width, meaning that also the lowest energy level tends to zero if the well is wide.
If you want to compare this with the macroscopic ball, but want to see it as a quantum object, you have to realise that it's corresponding deBroglie wavelength will be minuscule due to it's large mass. So putting it in a garage corresponds to incredible close energy levels that seem continuous, since such a container is much larger than the corresponding deBroglie wavelength. I would also think you are thinking about a ball with basically zero kinetic energy. Even classically the situation could be different if it moves and decreasing the containers size would increase the balls kinetic energy (see below).
If you have an electron within a well at lowest energy level, then it's energy should increase when you make the well smaller, while I would imagine the energy comes from the energy from the 'moving' potential well. I think heuristically this can be pictured analogous to a moving classical point particle within two walls. The energy would be constant if all the collisions are elastic, but it would gain energy from collisions with the wall if that would move towards it, making the confined region smaller. However, I don't think this analogy holds pretty well.
A: A particle in a box with "hard" walls is described by a wavefunction that is a standing wave which vanishes at the walls.  The electron energy is proportional to the wave frequency, $E=\hbar \omega.$  If one compares the ground state energies of two electrons in boxes of different sizes, the electron in the smaller box will have a smaller wavelength, which means a higher frequency, which means a higher ground state energy than the electron in the larger box. This qualitative argument explains the $L$ in the denominator of $E=\dfrac{n^2 \pi^2\hbar^2}{2mL^2}.$
The same argument can be applied to wells with finite walls.  For wells of the same depth, the width essentially determines the size of the wavelength of the bound states.
A: A confined particle will have some nonzero kinetic energy due to the uncertainty principle,
$$
\sigma_p \sigma_x \ge \hbar/2
$$
because the way to compute the uncertainty is
$$
\sigma_p^2 = \left<p^2\right> - \left<p\right>^2
$$
The stationary states of the square well are … well, they’re stationary, with $\left<p\right> = 0$, achieved as the sum of a left-going and right-going wave.  But the whole point of the Schrödinger equation is to find wavefunctions $\psi$ for which
$
\left(
\frac{\hat p^2}{2m} - \hat E
\right)
\psi = 0
$.
The zero-energy solution is $\psi=0$, which we reject because it can’t be normalized.
Note that if someone twisted your arm and forced you to accept $\psi(x) = \text{constant}$ as a wavefunction, it would have zero energy, but also $\left<x^2\right>=\infty$, so the uncertainty principle is still followed.
A useful homework problem is to compute $\sigma_p$ and $\sigma_x$ for the states of the square well, or of the harmonic oscillator, or whichever other potential interests you.  In general the ground state is closest to a minimum-uncertainty wave packet.
A sports ball which is rolling around your garage is a “classical object” because its de Broglie wavelength $\lambda = h/p$ is smaller than its actual size.  Even if your sports ball is at rest, thermal motions mean it remains a classical object.  Another useful homework problem is to compare the quantum-mechanical confinement energy of a golf ball in a bag to its thermal energy. You can also compare the confinement energy associated with squeezing the golf ball into some smaller volume with the work it would take to squeeze a golf ball in a vise.
