Calculus Of Variations And Its Application To Liquid Crystals