Calculus of Variations with Applications