Variational method for studying solitons in the Korteweg-de Vries equation