In inspiration, the diaphragm and external intercostal muscles contract, expanding the thoracic cavity vertically and horizontally. This increases the volume of the thoracic cavity, lowering the pressure inside the lungs, allowing air to flow in. In contrast, during expiration, the diaphragm and external intercostal muscles relax. The elastic recoil of the lungs and chest wall decreases the volume of the thoracic cavity, increasing the pressure inside the lungs, causing air to flow out. Inspiration is an active process requiring muscular effort, while expiration is typically a passive process relying on elastic recoil.