In a free-piston expander-compressor (FPEC) the work of an expanding gas or vapor is used to compress another gas or vapor through a direct connection of one piston-cylinder assembly to another, without rotary motion. Each section of the FPEC operates like the piston-cylinder of a shaft-connected reciprocating machine. The expander section operates like that of a steam engine: high-pressure gas or vapor is freely admitted through part of the expansion process, but stopped at the "cutoff" part way through the expansion. The compressor section is like that of a shaft-driven reciprocating compressor: low-pressure gas is admitted during the intake stroke, compressed during the compression stroke, and then discharged when it has reached the downstream high pressure. The design of an FPEC is complicated by the fact that the expander and compressor have different relationships between force and position. The force on the expander piston decreases as the stroke progresses, while that on the compressor piston increases. The force difference must be made up by momentum change of the pistons and connecting rod, which accelerate in the early part of the stroke and decelerate in the latter part. The balance between the expanding fluid, the moving mass, and the compressed fluid can be described either dynamically (force and momentum) or thermodynamically (work and energy). It is shown that the mechanical design (piston areas, stroke, oscillating mass, and frequency) of an idealized FPEC is highly constrained by the thermodynamics of the high-pressure stream expansion and the low-pressure stream compression. For simple cases, dynamic models in differential equation form can be compared to thermodynamic analyses in algebraic form. The thermodynamic models provide a baseline design point for an ideal FPSE. The dynamic models can then be used to study non-ideal cases.