Method of least squares to approximate electrolytic capacitor discharge