The inverse-variational problem is considered, of how to construct a Sturm-Liouville differential equation, over an interval (0,a), and for a range of values of the parameter lambda , which will give the closest fit at the endpoint x=a of a given function of lambda , to the solution subject to prescribed initial conditions at x=0. Integral conditions are derived for the solution to the problem, and the results are applied to a simple case, using a numerical algorithm.