Formula for calculating work in capacitor