When we compress a piston, its total internal energy increases, however I don't understand why.
As the piston compresses, the temperature should change, as the total energy density increases.
As a piston compresses, work is done to compress the gas. However, this is solely fighting a differential in pressure, as well as the force to accelerate the piston. It seems none (or very little) of this energy should be imparted to the gas - so why does the internal energy significantly increase?
The last one is somewhat explicable, however, when we pull back on a piston, uncompressing the air, we're not taking energy away from the air. While the overall energy density changes, the total energy itself shouldn't, as no process is removing energy. However, it does - so where is the energy going?
Ultimately I think this comes down to: where does the energy go, and how does it get there?