On Wikipedia derivation on Timoshenko beam equation we arrive at this:
$$ \delta U = \int_L \left[-M_{xx}\frac{\partial (\delta\varphi)}{\partial x} + Q_{x}\left(-\delta\varphi + \frac{\partial (\delta w)}{\partial x}\right)\right]~\mathrm{d}L $$
then:
Integration by parts, and noting that because of the boundary conditions the variations are zero at the ends of the beam, leads to
$$ \delta U = \int_L \left[\left(\frac{\partial M_{xx}}{\partial x} - Q_x\right)~\delta\varphi - \frac{\partial Q_{x}}{\partial x}~\delta w\right]~\mathrm{d}L $$
But why are the variations on the angle $\delta\varphi$ and displacement $\delta w$ zero at the ends? If we have a beam resting on two supports at the ends, then I can understand why the displacement variation would be zero since the beam is bound there, but I don't see how the angle variation could be zero, since more the beam is displaced along its length, bigger the change in angle at the ends. And if we are dealing with a beam, say, attached to a wall with one end free, the one of the ends experiences a difference in both the angle and the vertical displacement.