Calculation of circuit impedance