We construct an optimal execution strategy for the purchase of a large number of shares of a financial asset over a fixed interval of time. Purchases of the asset have a nonlinear impact on price, and this is moderated over time by resilience in the limit-order book that determines the price. The limit-order book is permitted to have arbitrary shape. The form of the optimal execution strategy i...