A novel exact analytical solution is derived for the equation y ð4Þ þ x n y ¼ 0 in the region x ≥ 0, which is important for the analysis of piles in soil with stiffness varying with depth. To date, exact solutions for long piles are available only for the cases where n ¼ −4, 0, and 1. For other values of the exponent n, solutions have formerly been obtained numerically, mainly by the finite-difference method or approximate analytical solutions. An inherent difficulty in obtaining solutions for long beams (which are used to model flexible piles) lies in the inability to isolate the regular, converging part of the solution over the singular part that diverges with increasing x. In this paper, an exact solution is derived for n > −4, focusing on the important case of semi-infinite beams. Key aspects of the problem such as the stiffness and flexibility matrices at the pile head, and the peak bending moments due to eccentrically acting lateral loads, are discussed. A novel approach for deriving Winkler spring moduli for combined force and moment loading is proposed and shown to provide good agreement with rigorous numerical continuum results.