Text this: Dynamic programming and the calculus of variations