An inverse-variational principle for the Sturm-Liouville equation