Necessary conditions for solutions to variational problems