Show that a photon cannot transmit its total energy to a free electron. Contradiction with Photoelectric effect? This is a problem in my textbook and I've shown it this way:
$E_{initial}=\frac{hc}{\lambda} + mc^2$
$p_{initial}=h/\lambda$
After collision with photon having zero energy we get
$p_{final}=h/\lambda$
$E_{final}=\sqrt{(\frac{hc}{\lambda})^2+(mc^2)^2}$
Which is in contradiction with the conservation of energy.
Now, this result is I think contradictory to Einstein's explanation of the photoelectric effect.
In the photoelectric effect the photon is absorbed by the free electron and this is what makes it have kinetic energy.
What am I interpreting wrong? The problem comes from the context of the Compton Effect, by the way.
 A: The original problem can be seen in terms of energy and momentum conservation.
Before scatter, there are two particles in the center of mass and the center of mass  has an invariant mass larger than the mass of the electron. For total absorption of the photon there would be only the electron left. As the electron has a fixed mass and at the center of mass it should be at rest, the reaction cannot happen.  It can only happen if a third particle is involved to conserve the overall energy and momentum , and this is what is happening with the photoelectric effect.
  a)
The incoming photon interacts with an electron that is tied to the atom by a virtual photon . The whole system takes up the energy and momentum conservation.
The inverse problem happens with a gamma generating an e+e- pair. The gamma has zero invariant mass, the pair will have at least two electon masses at the center of mass, so a gamma cannot turn into an electron positron pair , a third  particle has to be involved. The simplest is a virtual photon from some nucleus too. The Feynman diagram is the same as the one above with a different interpretation  ( incoming e- is read as outgoing e+)
     _________________

a) diagram copied
A: As the comments indicate, the answer truly is that the electrons in the solid are not really free.
But wait, I hear you say -- the free electron model approximates the electrons in the solid as a free gas of electrons. It certainly isn't perfect, but it can't be that poor of a description. Yes it can, and I'll explain why.
Consider what it means to say that a solid is filled with a free electron gas. For definiteness, say that your solid is a metal cube of side $a$. Surely the electrons in the solid are bound to the solid, which is to say, they're not free throughout all of space. They're free inside the solid. So we can model the solid as a 3d infinite square well of width $a$. 
But you can never remove a particle from an infinite square well, no matter how much energy you give, via photons or anything else. So it's utterly inadequate as a model for the photoelectric effect. You probably want then something like a very high but finite square well. 
If the well is high enough, the finiteness doesn't change the lowest eigenvalues much, which will still be given by 
$$E_{n_x,n_y,n_z} \approx \frac{\hbar^2\pi^2}{2ma^2}\left(n_x^2 + n_y^2 + n_z^2\right)$$
Since electrons are fermions, at zero temperature they will occupy the lowest energy eigenstates up to the Fermi energy $E_F$. If we assume that the energy levels are closely spaced enough that $n_x, n_y$ and $n_z$ may be treated as continuous variables, we'll have the following relation for the filled eigenstates:
$$n_x^2 + n_y^2 + n_z^2 \leq \frac{2m}{\hbar^2 \pi^2 } a^2 E_f$$
In other words, the total number of filled eigenstates is approximately given by the volume of the positive octant of a sphere of radius $\frac{a}{\hbar \pi } \sqrt{2m  E_f}$.
$$N_F \approx \frac{1}{8}\frac{4}{3} \frac{a^3}{\hbar^3 \pi^2 } (2m  E_f)^{3/2}$$
But of course, $N_F$ has to be equal to the number of electrons in the solid (well, up to a factor of two due to spin degeneracy), which is proportional to the volume of the box.
$$C a^3 = 2 N_F  \approx \frac{1}{3} \frac{a^3}{\hbar^3 \pi^2 } (2m  E_f)^{3/2}$$
So the Fermi energy will be given by
$$E_F = \left(3 \pi^2 C \right)^{2/3}\frac{\hbar^2}{2m}  $$
which in accordance with intuition and good sense doesn't depend on $a$. Instead it depends only on $C$ which is a property of the material.
So in order to remove one electron from the material, by whatever means, we need to pay at least the difference between the Fermi energy and the height of the well. This is the work function.
Now I hope it's become clear: the electrons in the box may only be regarded as free as long as their energy is small enough that you can pretend that the well is infinite.
So let's repeat your argument for a photon that has just enough energy to liberate an electron.
\begin{align}
E_{\text{initial}} &= \hbar \omega + mc^2 - W\\
p_{\text{initial}} &= \frac{\hbar \omega}{c}
\end{align}
After the photon is absorbed we have a free electron with zero kinetic energy, so
\begin{align}
E_{\text{final}} &= mc^2\\
p_{\text{final}} &= \frac{\hbar \omega}{c}
\end{align}
Since the condition that the photon has the exact minimum amount of energy to liberate one electron is precisely that $\hbar \omega = W$, the two equations are perfectly consistent and energy is conserved. Of course, since the electron is at rest, it can't have the momentum $p_{\text{final}}$ in the above. So the solid has it, and because it's so much more massive than the electron, its kinetic energy may be neglected. If you cling to the free electron model, I doubt you can go any farther than this.
You might still be feeling uneasy about the whole thing because while the energy imparted to the box is extremely small, it's non zero. That is true. However, the metal is always at some finite temperature so there's always some thermal energy available to supply the minute amount of kinetic energy imparted to the metal. Realistically this would probably be implemented by looking at how the extracted electron scatters off phonons in the lattice or some such.
A: Let's consider a free electron. If this absorbs a photon, then the Feynman diagram associated with it (the fundamental building block of all diagrams) will give probability zero. Because in the rest frame of the outgoing electron it has less energy than the incoming electron and photon. Conservation of energy is lost in this case. So an electron can't absorb a photon and move on freely.
In the same way: the diagram is topological equivalent to an incoming electron and an outgoing electron and photon, and in the centre of mass frame the incoming electron is at rest and the outgoing electron and photon have an energy that's greater than the energy of the incoming electron at rest, which contradicts conservation of energy. 
The diagram is also topological equivalent to a real incoming electron and positron and a real outgoing photon. In the COMF of the electron and positron, the total momentum before the collision is zero, while the photon's momentum can't be zero since it always travels at the speed of light, which contradicts conservation of energy.
It has to be connected with the same kind of diagram, but with an incoming real electron and outgoing real electron and photon. The resulting diagram includes a real incoming electron and photon, a virtual electron (in the "middle") and a real outgoing electron and photon. Of course, this is the first order diagram of Compton scattering.
Now a virtual electron isn't on its mass scale, i.e. its momentum and energy are unrelated so it can enforce conservation of 4-momentum at each vortex, which is to say that the combined energy of the electron and photon before the collision is the same as after the collision, as is also the case for the combined momenta of the electron and photon before and after the collision. So if the incoming electron has the described momentum and energy and the photon has zero energy (and thus zero momentum), which is the same as no photon at all, the final four-momentum for the electron must be the same as the initial four-momentum.
I think you make the error to assume that $p_{initial}=\frac h {\lambda}$. Why should it have that value? It must have a value $x$ to match $E_{initial}$ with $E_{final}$. In that case, you get the equation
$\frac{hc}{\lambda}+mc^2=\sqrt{x^2c^2+(mc^2)^2}$, which you can solve for $x$:
$x=\sqrt(\frac{h^2+2hmc\lambda} {\lambda^2})$, so if $x=0$ (in the rest frame of the electron) also $\frac h \lambda=0$.
If you look to the incoming and outgoing electrons in their rest frames then the electrons have only the $mc^2$ term as energy because the "photon" which it absorbs has zero energy, and if energy is conserved in one inertial frame (in this case the rest frame) energy is conserved in every inertial frame. 
