Lagrangian and energy for nonlinear dielectrics