Capacitor charging and discharging formulas