In [48]:

```
from __future__ import division
from cmath import rect
#Given data
Z1 = 50 # in ohm
Z2 = 250 # in ohm
Z3 = 200 # in ohm
theta1 = 80 # in degree
theta2 = 0 # in degree
theta3 = 30 # in degree
#bridge balance equation, Z1*Z4 = Z2*Z3
Z4 = (Z2*Z3)/Z1 # in ohm
#phase angle condition, theta1+theta4 = theta2+theta3
theta4 = theta2+theta3-theta1 # in degree
theta4= theta4*pi/180 # in radian
Z4= rect(Z4,theta4)
print "The resistance part of Z4 = %0.2f Ω" %Z4.real
print "while it is in series with capacitive reactance of",abs(round(Z4.imag,1)),"Ω"
```

In [50]:

```
#Given data
Z1 = 50 # in ohm
Z2 = 100 # in ohm
Z3 = 15 # in ohm
Z4 = 30 # in ohm
theta1 = 40 # in degree
theta2 = -90 # in degree
theta3 = 45 # in degree
theta4 = 30 # in degree
if abs(Z1*Z4)== abs(Z3*Z2) :
flag1=1
print "The condition of balance for magnitude is satisfied"
else :
flag1=0
print "The condition of balance for magnitude is not satisfied"
if theta1+theta4 == theta2+theta3 :
flag2=1
print "The condition of balance for phase is also satisfied"
else :
flag2=0
print "But the condition of balance for phase is not satisfied"
if flag1==1 :
if flag2==1 :
print "Hence the bridge is under balanced condition"
else :
print "Hence the bridge is not under balanced condition"
else :
print "Hence the bridge is not under balanced condition"
```

In [3]:

```
#Given data
C3 = 10 # in µF
C3 = C3*10**-6 # in F
R1 = 1.2 # in k ohm
R1 = R1 * 10**3 # in ohm
R2 = 100 # in k ohm
R2 = R2 * 10**3 # in ohm
R3 = 120 # in k ohm
R3 = R3 * 10**3 # in ohm
Rx = (R2*R3)/R1 #unknown resistance in ohm
Rx = Rx * 10**-6 # in M ohm
print "The value of Rx = %0.f MΩ " %Rx
Cx = (R1*C3)/R2 # in F
Cx = Cx * 10**6 #unknown capacitance in µF
print "The value of Cx = %0.2f µF " %Cx
```

In [4]:

```
#Given data
L3 = 8 # in mH
L3 = L3 * 10**-3 # in H
R1 = 1 # in k ohm
R1 = R1 * 10**3 # in ohm
R2 = 25 # in k ohm
R2 = R2 * 10**3 # in ohm
R3 = 50 # in k ohm
R3 = R3 * 10**3 # in ohm
Rx = (R2*R3)/R1 #unknown resistance in ohm
Rx = Rx * 10**-6 # in M ohm
print "The value of Rx = %0.2f MΩ " %Rx
Lx = (R2*L3)/R1 #unknown inductance in H
Lx = Lx * 10**3 # in mH
print "The value of Lx = %0.f mH " %Lx
```

In [6]:

```
#Given data
C1 = 0.5 # in µF
C1 = C1 * 10**-6 # in µF
R1 = 1200 # in ohm
R2 = 700 # in ohm
R3 = 300 # in ohm
# From bridge balance equation
Rx = (R2*R3)/R1 # in ohm
print "Component of the brach BC :"
print "Rx = ",int(Rx),"Ω"
Lx = R2*R3*C1 # in H
Lx = Lx * 10**3 # in mH
print "Lx = ",int(Lx),"mH"
```

In [7]:

```
#Given data
R2 = 1000 #resistance in ohm
R3 = 500 # resistance in ohm
R4 = 1000 # resistance in ohm
C = 3 #capacitance in µF
C = C * 10**-6 # in F
r = 100 # in ohm
Rx = (R2*R3)/R4 #value of Rx in ohm
print "The value of Rx = %0.f Ω " %Rx
Lx = ((C*R2)/R4)*( (R3*r) + (R4*r) + (R3*R4) ) #value of Lx in H
print "The value of Lx = %0.2f H " %Lx
```

In [8]:

```
#Given data
R1 = 5.1 # in k ohm
R1 = R1 * 10**3 # in ohm
R2 = 7.9 # in k ohm
R2 = R2 * 10**3 # in ohm
R3 = 790 # in ohm
C1 = 2 # in µF
C1 = C1 * 10**-6 # in F
omega = 1000 # in rad/sec
Rx = (((omega)**2)*R1*((C1)**2)*R2*R3)/( 1+(((omega)**2) * ((R1)**2)* ((C1)**2)) ) # unknown resistance in ohm
Rx = Rx * 10**-3 # in k ohm
print "The value of unknown resistance = %0.3f kΩ " %Rx
Lx = (R2*R3*C1)/( 1+(((omega)**2) * ((R1)**2)* ((C1)**2)) ) # unknown inductance in H
Lx = Lx * 10**3 # in mH
print "The value of unknown inductance = %0.2f mH " %Lx
```

In [10]:

```
from numpy import pi
#Given data
R1 = 1.2 # in k ohm
R1 = R1 * 10**3 # in ohm
R2 = 4.7 # in k ohm
R2 = R2 * 10**3 # in ohm
C1 = 1 # in µF
C1 = C1 * 10**-6 # in F
C3 = 1 # in µF
C3 = C3 * 10**-6 # in F
Rx = (R2*C1)/C3 # unknown resistance in ohm
Rx = Rx * 10**-3 # in k ohm
Cx = (R1*C3)/R2 # unknown capacitance in F
Cx = Cx * 10**6 # in µF
print "The unknown resistance = %0.1f kΩ is " %Rx
print "The unknown capacitance = %0.3f µF " %Cx
f = 0.5 # in kHz
f = f * 10**3 # in Hz
# omega = 2*pi*f
D = 2*pi*f*Cx*10**-6*Rx*10**3 # dissipation factor
print "The dissipation factor = %0.3f " %D
```

In [18]:

```
#Given data
R1 = 2.7 # in k ohm
R1 = R1 * 10**3 # in ohm
R2 = 22 # in k ohm
R2 = R2 * 10**3 # in ohm
R4 = 100 # in k ohm
R4 = R4 * 10**3 # in ohm
C1 = 5 # in µF
C1 = C1 * 10**-6 # in F
f = 2.2 # in kHz
f = f * 10**3 # in Hz
#From omega**2 = 1/(R1*C1*R3*C3)
# C3 = 1/(R1*C1*R3*(omega**2)) (i)
# R2/R4 = R1/R3 + C3/C1 (ii)
# From eq(i) and (ii)
R3 = R4*(R1+1/((2*pi*f)**2*R1*C1**2))/R2 # equivalent parallel resistance in ohm
R3= R3*10**-3 # in k ohm
print "The equivalent parallel resistance = %0.3f kΩ " %R3
R3= R3*10**3 # in ohm
C3 = 1/(R1*C1*R3*((2*pi*f)**2)) # equivalent parallel capacitance in F
C3 = C3 * 10**12 # in pF
print "The equivalent parallel capacitance = %0.2f pF " %C3
```

In [20]:

```
from __future__ import division
#Given data
C1 = 550 # in pF
C2 = 110 # in pF
Cd = (C1-(4*C2))/3 # distributed capacitance in pF
print "The distributed capacitance = %0.2f pF " %Cd
Cd = Cd * 10**-12 # in F
C1 = C1 * 10**-12 # in F
f1 = 1.5 # in MHz
f1 = f1 * 10**6 # in Hz
# f1 = 1/(2*pi*(sqrt( L*(C1+Cd))))
L = ((1/(2*pi*f1))**2) * (1/(C1+Cd)) # distributed inductance in H
L = L * 10**6 # in µH
print "The distributed inductance = %0.2f µH " %L
```

In [22]:

```
#Given data
f = 1.5 #frequency in MHz
f = f * 10**6 # in Hz
C = 60 # in pF
C = C * 10**-12 # in F
R = 8 # in ohm
R_SH = 0.02 # in ohm
omega = 2*pi*f
Qactual = 1/(omega*C*R) # true value of Q
Qobserved = 1/(omega*C*(R+R_SH)) # observed value of Q
PerError = ((Qactual-Qobserved)/Qactual) * 100 # Percentage error in %
print "The Percentage error = %0.2f %% " %PerError
```

In [23]:

```
#Given data
f1 = 2 #frequency in MHz
f1 = f1 * 10**6 # in Hz
C1 = 500 # in pF
C2 = 60 # in pF
# f1 = 1/(2*pi*sqrrt(L*(C1+Cd))) (i)
# f2 = 1/(2*pi*sqrrt(L*(C2+Cd))) (ii)
# and f2 = 2.5*f1 (iii)
#From eq(i),(ii) and (iii)
Cd = (C1 - (6.25*C2))/5.25 # value of self capacitance in pF
print "The value of self capacitance = %0.2f pF " %Cd
```

In [25]:

```
#Given data
f = 1 # in MHz
f = f * 10**6 # in Hz
omega = 2*pi*f # in rad/sec
C = 65 # in pF
C = C * 10**-12 # in F
R = 10 # in ohm
R_SH = 0.02 # in ohm
# Q = X_L/R = X_C/R = 1/(omega*C*R)
Qactual = 1/(omega*C*R) # True value of Q
Qmeasured = 1/(omega*C*(R+R_SH)) # measured value of Q
PerError = ((Qactual-Qmeasured)/Qactual)*100 #percentage error in %
print "The Percentage error = %0.1f %% " %PerError
```

In [26]:

```
#Given data
C1 = 450 #capacitance in pF
C1 = C1 * 10**-12 # in F
C2 = 60 #capacitance in pF
C2 = C2 * 10**-12 # in F
# f1 = 1/(2*pi*(sqrt(L*(C1+Cd)))) (i)
# f2 = 1/(2*pi*(sqrt(L*(C2+Cd)))) (ii)
# and f2 = 2.5*f1 (iii)
# from eq(i),(ii) and (iii)
Cd = (C1 - (6.25*C2))/5.25 # value of self capacitance in F
Cd = Cd * 10**12 # in pF
print "The value of self capacitance = %0.2f pF " %Cd
```

In [31]:

```
from __future__ import division
#Given data
f1 = 8 #frequency in MHz
f1= f1*10**6 # in Hz
f2 = 12 #frequency in MHz
f2= f2*10**6 # in Hz
C1 = 120 #capacitance in pF
C1 = C1 * 10**-12 # in F
C2 = 40 #capacitance in pF
C2 = C2 * 10**-12 # in F
# f1 = 1/(2*pi*(sqrt(L*(C1+Cd)))) (i)
# f2 = 1/(2*pi*(sqrt(L*(C2+Cd)))) (ii)
# From eq(i) and (ii)
Cd= (f2**2*C2-f1**2*C1)/(f1**2-f2**2) # in F
# From eq(i)
C=C1+Cd
L=1/((C1+Cd)*(2*pi*f1)**2) # inductance in H
L= L*10**6 # in µH
Cd= Cd*10**12 # self capacitance in pF
print "The self capacitance = %0.1f pF " %Cd
print "The inductance = %0.3f µH " %L
```

In [32]:

```
#Given data
f1 = 1 #frequency in MHz
f1= f1*10**6 # in Hz
f2 = 2 #frequency in MHz
f2= f2*10**6 # in Hz
C1 = 500 #capacitance in pF
C1 = C1 * 10**-12 # in F
C2 = 110 #capacitance in pF
C2 = C2 * 10**-12 # in F
# f1 = 1/(2*pi*(sqrt(L*(C1+Cd)))) (i)
# f2 = 1/(2*pi*(sqrt(L*(C2+Cd)))) (ii)
# From eq(i) and (ii)
Cd= (f2**2*C2-f1**2*C1)/(f1**2-f2**2) # in F
# From eq(i)
C=C1+Cd
L=1/((C1+Cd)*(2*pi*f1)**2) # in H
L= L*10**6 #inductance in µH
Cd= Cd*10**12 # self capacitance in pF
print "The self capacitance = %0.f pF " %Cd
print "The inductance = %0.2f µH " %L
```

In [57]:

```
#Given data
f = 1 #frequency in kHz
f = f * 10**3 # in Hz
R1 = 400 #resistance in ohm
R2 = 150 #resistance in ohm
C2 = 0.2 #capacitance in µF
C2 = C2 * 10**-6 # in F
XC2= 1/(2*pi*f*C2)
R3 = 100 #resistance in ohm
L3 = 10 #inductance in mH
L3 = L3 * 10**-3 # in H
XL3= 2*pi*f*L3
Z1= complex(R1,0) # in Ω
Z2= R2-1j*XC2 # in Ω
Z3= R3+1j*XL3 # in Ω
Z4= Z2*Z3/Z1 # in Ω
R4= Z4.real#resistance in Ω
XC4= abs(Z4.imag) # in Ω
C4= 1/(2*pi*f*XC4) # in F
C4= C4*10**6 # in µF
print "The components of branch CD : "
print "R4 = ",round(R4,1)," Ω"
print "C4 = ",round(C4,4)," µF"
```

In [34]:

```
#Given data
C3 = 10 #capacitance in µF
C3 = C3 * 10**-6 # in F
R1 = 1.2 #resistance in k ohm
R1 = R1 * 10**3 # in ohm
R2 = 100 #resistance in k ohm
R2 = R2 * 10**3 # in ohm
R3 = 120 #resistance in k ohm
R3 = R3 * 10**3 # in ohm
Rx = (R2*R3)/R1 #resistance of unknown impedance in ohm
Rx = Rx * 10**-6 # in M ohm
print "The resistance of unknown impedance = %0.f MΩ " %Rx
Cx = (R1*C3)/R2 #capacitance of unknown impedance in F
Cx = Cx * 10**6 # in µF
print "The capacitance of unknown impedance = %0.2f µF " %Cx
```

In [61]:

```
#Given data
f = 1000 #frequency in Hz
C1 = 0.2 #capacitance in µF
C1 = C1 * 10**-6 # in F
XC1= 1/(2*pi*f*C1)
R2= 500 # in Ω
R3= 300 # in Ω
C3= 0.1*10**-6 # in F
XC3= 1/(2*pi*f*C3)
omega = 2*pi*f # in rad/sec
Z1= 0-1j*XC1 # in Ω
Z2= R2 # in Ω
Y3= 1/R3+1j*1/XC3 # in Ω
Z3= R3*XC3/(R3+XC3) # in Ω
Z4= Z2/(Z1*Y3) # in Ω
R4= Z4.real # in Ω
XL4= abs(Z4.imag) # in Ω
L4= XL4/(2*pi*f) # in F
L4= L4*10**3 # in mH
print "The components of branch CD : "
print "Rx = ",round(R4,2),"Ω"
print "Lx = %0.f mH" %L4
```

In [62]:

```
#Given data
f = 2 # in kHz
f = f * 10**3 # in Hz
omega = 2*pi*f # in rad/sec
Z1 = 10 # in k ohm
Z2 = 50 # in k ohm
R3 = 100 # in k ohm
C3 = 100 # in µF
C3 = C3 * 10**-6 # in F
XC3= 1/(2*pi*f*C3)
Z3= R3-1j*XC3 # in Ω
# From balance equation, Z1*Z4= Z2*Z3
Z4= Z2*Z3/Z1 # in Ω
R4= Z4.real # in kΩ
XC4= abs(Z4.imag) # in kΩ
C4= 1/(2*pi*f*XC4) # in F
C4= C4*10**6 # in µF
print "The components of branch DC : "
print "Rx= %0.f kΩ" %R4
print "Cx= %0.f µF" %C4
```

In [67]:

```
#Given data
f = 1 # in kHz
f = f * 10**3 # in Hz
omega = 2*pi*f # in rad/sec
Z1 = 200 # in ohm
R2 = 200 # in ohm
C2 = 5 # in µF
C2 = C2 * 10**-6 # in F
XC2= 1/(2*pi*f*C2)
Z2= R2-1j*XC2 # in Ω
R3 = 500 # in ohm
C3 = 0.2 # in µF
C3 = C3 * 10**-6 # in F
XC3= 1/(2*pi*f*C3)
Z3= R3-1j*XC3 # in Ω
# From balance equation, Z1*Z4= Z2*Z3
Z4= Z2*Z3/Z1 # in Ω
R4= Z4.real# in Ω
XC4= abs(Z4.imag) # in Ω
C4= 1/(2*pi*f*XC4) # in F
C4= C4*10**9 # in nF
print "The components of Zx : "
print "Rx = ",round(R4,3),"Ω"
print "Cx = ",round(C4,3),"nF"
```

In [69]:

```
#Given data
f = 1 # in kHz
f = f * 10**3 # in Hz
omega = 2*pi*f # in rad/sec
Z1 = 1.65 # in k ohm
Z2 = 15.3 # in k ohm
R3 = 2.5 # in k ohm
C3 = 10 # in µF
C3 = C3 * 10**-6 # in F
XC3= 1/(2*pi*f*C3)
Z3= R3-1j*XC3 # in Ω
# From balance equation, Z1*Z4= Z2*Z3
Z4= Z2*Z3/Z1 # in Ω
R4= Z4.real # in kΩ
XC4= abs(Z4.imag) # in kΩ
C4= 1/(2*pi*f*XC4) # in F
C4= C4*10**6 # in µF
print "The components of branch DC : "
print "Rx = ",round(R4,3)," kΩ"
print "Cx = ",round(C4,2)," µF"
```

In [76]:

```
#Given data
f = 1 # in kHz
f = f * 10**3 # in Hz
R1 = 600 # in ohm
C1 = 1 # in µF
C1 = C1 * 10**-6 # in F
XC1= 1/(2*pi*f*C1)
R2 = 100 # in ohm
R3 = 1 # in k ohm
R3 = R3 * 10**3 # in ohm
omega = 2*pi*f # in rad/sec
Y1= 1/R1+1j*1/XC1 # in Ω
Z2=R2 # in Ω
Z3= R3 # in Ω
# From balance equation, Z1*Z4= Z2*Z3
Z4= Z2*(Z3*Y1) # in Ω
R4= Z4.real # in Ω
XL4= abs(Z4.imag) # in Ω
L4= XL4/(2*pi*f) # in F
print "Rx= ",int(R4)," Ω"
print "Lx= %0.3f H" %L4
```

In [81]:

```
#Given data
R2 = 842 #resistance in ohm
C2 = 0.135 #capacitance in µF
C2 = C2 * 10**-6 # in F
f=1000 #frequency in Hz
XC2= 1/(2*pi*f*C2)
R3= 10 #resistance in ohm
C4= 1*10**-6 #capacitance in F
XC4= 1/(2*pi*f*C4)
Z2= R2-1j*XC2 #impedance in ohm
Z3= complex(R3,0) #impedance in ohm
Z4= -1j*XC4 #impedance in ohm
# From balance equation
Z1= Z2*Z3/Z4 # in Ω
R1= Z1.real # in Ω
XL1= abs(Z1.imag) # in Ω
L1= XL1/(2*pi*f) # in F
L1= L1*10**3 # in mH
print "The value of R1 = %0.3f Ω " %R1
print "The value of L1 = %0.2f mH " %L1
```

In [42]:

```
#Given data
L2 = 47.8 #inductance in mH
R2 = 1.36 #resistance in ohm
r1 = 32.7 #resistance in ohm
R1 = 1.36 #resistance in ohm
#At balance, 100*(r1+J*oemga*L1) = 100*((R2+r2)+(J*omega*L2))
L1 = L2 # in mH (equating imaginary terms)
print "The inductance of coil = %0.1f mH " %L1
# R2+r2 = r1 (equating real terms)
r2 = r1-R1 #resistance of coil in ohm
print "The resistance of coil = %0.2f ohm " %r2
# Note: In the book the value of L1 is wrong.
```

In [82]:

```
#Given data
R=1.36 #resistance in ohm
r2= 32.7 #resistance in ohm
L2= 47.8 #inductance in mH
L2= L2*10**-3 # in H
f=1000 #frequency in Hz
XL2=2*pi*f*L2 # in Ω
Z3 = 100 # in ohm
Z4 = 100 # in ohm
Z2= r2+1j*XL2 # in ohm
# Under balance condition
Z1= Z2*Z3/Z4 # in ohm
R1= Z1.real # in ohm
r1= R1-R #resistance of the coil in ohm
XL1= Z1.imag # in ohm
L1= XL1/(2*pi*f) #inductance of the coil in F
L1= L1*10**3 # in mH
print "The resistance of the coil = %0.2f Ω " %r1
print "The inductance of the coil = %0.1f mH " %L1
```

In [85]:

```
#Given data
Z1 = 400 # in ohm
Z2 = 200 # in ohm
Z3 = 800 # in ohm
Z4 = 400 # in ohm
theta1 = 50 # in degree
theta2 = 40 # in degree
theta3 = -50 # in degree
theta4 = 20 # in degree
if abs(Z1*Z4) == abs(Z3*Z2) : # Applying the condition of balance for magnitude
flag1=1
print "The condition of balance for magnitude is satisfied"
else :
flag1=0
print "The condition of balance for magnitude is not satisfied"
if theta1+theta4==theta2+theta3 : # Applying the condition of balance for phases
flag2=1
print "The condition of balance for phase is also satisfied"
else :
flag2=0
print "But the condition of balance for phase is not satisfied"
if flag1==1 :
if flag2==1 :
print "Hence the bridge is under balanced condition"
else :
print "Hence the bridge is not under balanced condition"
else :
print "Hence the bridge is not under balanced condition"
```

In [86]:

```
#Given data
Z1 = 200 # in ohm
Z2 = 400 # in ohm
Z3 = 300 # in ohm
Z4 = 600 # in ohm
theta1 = 60 # in degree
theta2 = -60 # in degree
theta3 = 0 # in degree
theta4 = 30 # in degree
if abs(Z1*Z4)== abs(Z3*Z2) : # Applying the condition of balance for magnitude
flag1=1
print "The condition of balance for magnitude is satisfied"
else :
flag1=0
print "The condition of balance for magnitude is not satisfied"
if theta1+theta4==theta2+theta3 : # Applying the condition of balance for phases
flag2=1
print "The condition of balance for phase is also satisfied"
else :
flag2=0
print "But the condition of balance for phase is not satisfied"
if flag1==1 :
if flag2==1 :
print "Hence the bridge is under balanced condition"
else :
print "Hence the bridge is not under balanced condition"
else :
print "Hence the bridge is not under balanced condition"
```

In [91]:

```
#Given data
f = 1 #frequency in kHz
f = f * 10**3 # in Hz
C1 = 0.2 # in µF
C1 = C1 * 10**-6 # in F
XC1= 1/(2*pi*f*C1) # in Ω
C2 = 0.1 # in µF
C2 = C2 * 10**-6 # in F
XC2= 1/(2*pi*f*C2) # in Ω
R2= 300 # in Ω
R3= 500 # in Ω
Z1= 0-1j*XC1 # in Ω
Z2= R2*-1j*XC2/(R2-1j*XC2) # in Ω
Z3=R3 # in Ω
# For balanced condition
Z4= Z2*Z3/Z1 # in Ω
R4= Z4.real # in Ω
XL4= Z4.imag # in Ω
L4= XL4/(2*pi*f) # in H
L4= L4*10**3 # in mH
print "Components of arm CD : "
print "L4 =",round(L4,2),"mH"
print "R4 =",round(R4,4),"Ω"
```

In [51]:

```
#Given data
R3 = 100 # in ohm
R4 = 200 # in ohm
R2 = 250 # in ohm
C = 1 # in µF
C = C * 10**-6 # in F
r = 229.7 # in ohm
r1 = 43.1 # in ohm
# Value of unknown resistance for Anderson's bridge
R1 = ((R2*R3)/R4) - r1 #resistance in ohm
print "The resistance = %0.1f ohm " %R1
L1 = ((C*R3)/R4) * ( ((R2+R4)*r) + (R2*R4) ) #inductance in H
L1 = L1 * 10**3 # in mH
print "The inductance = %0.4f mH " %L1
```

In [92]:

```
#Given data
f = 450 #frequency in Hz
omega = 2*pi*f # in rad/sec
R2 = 4.8 # in ohm
R3 = 200 # in ohm
R4 = 2850 # in ohm
C2 = 0.5 # in µF
C2 = C2*10**-6 # in F
XC2= 1/(2*pi*f*C2) # in Ω
r2 = 0.4 # in ohm
Z2= (R2+r2)-1j*XC2 # in Ω
Z3= R3 # in Ω
Z4= R4 # in Ω
# For balanced condition
Z1= Z2*Z3/Z4 # in Ω
r1= Z1.real # in Ω
XC1= abs(Z1.imag) # in Ω
C1= 1/(2*pi*f*XC1) # in F
Df= 2*pi*f*C1*r1 # dissipating factor
C1= C1*10**6 # in µF
print "The value of r1 = %0.4f Ω " %r1
print "The value of C1 = %0.3f µF " %C1
print "The dissipating factor = %0.6f " %Df
```

In [99]:

```
#Given data
f = 2 #frequency in kHz
f = f * 10**3 # in Hz
omega = 2*pi*f # in rad/sec
R2 = 834 #resistance in ohm
C2 = 0.124 #capacitance in µF
C2 = C2 * 10**-6 # in F
XC2= 1/(2*pi*f*C2) # in Ω
R3= 100 #resistane in Ω
C4= 0.1*10**-6 #capacitance in F
XC4= 1/(2*pi*f*C4) # in Ω
Z2= R2-1j*XC2 # in Ω
Z3=R3 # in Ω
Z4= 0-1j*XC4 # in Ω
# For balanced condition, effective impedance
Z1= Z2*Z3/Z4 #in Ω
print "The effective impedance = (",round(Z1.real,4),"+ j",round(Z1.imag,4),")Ω"
```

In [102]:

```
#Given data
R1= 20*10**3 #resistance in ohm
R2= 50*10**3 #resistance in ohm
C2= 0.003*10**-6 #capacitance in F
R4= 10*10**3 #resistance in ohm
C1= 150*10**-12 #capacitance in F
omega= 10**6 # in rad/sec
Z1= R1/(1+1j*omega*C1*R1) # in ohm
Z2= (1+1j*omega*C2*R2)/(1j*omega*C2) # in ohm
# At balance condition : Z1*R4 = Z2*(Rx+1j*omega*Lx) or
# R4= omega**2*R1*C2*(R1*R4*C1-Lx) (i)
# R4= R1*(Rx*C2-R4*C1)/(R2*C2) (ii)
Rx= R4*(R1*C1+R2*C2)/(R1*C2) # in Ω from eq(ii)
Lx= R4*(R2*C1-1/(omega**2*R1*C2)) # in H from eq (i)
Rx= Rx*10**-3 # in ohm
Lx= Lx*10**3 # in mH
print "The value of Rx = %0.1f Ω " %Rx
print "The value of Lx = %0.3f mH " %Lx
```

In [55]:

```
#Given data
R2 = 1000 #resistance in Ω
R3 = 1000 #resistance in Ω
R4 = 1000 #resistance in Ω
C4 = 0.5 #capacitance in µF
C4 = C4 * 10**-6 # in F
#At balance, (R1+(%i*omega*L1))*(R4/( 1+(%i*omega*C4*R4) )) = R2*R3
# R1*R4 + (%i*omega*L1*R4) = (R2*R3) + (%i*omega*R2*R4*C4)
R1 = (R2*R3)/R4 # in Ω (equating real terms)
L1 = R2*R3*C4 # in H (equating imaginary terms)
print "The value of R1 = %0.f ohm " %R1
print "The value of L1 = %0.1f H " %L1
```

In [56]:

```
#Given data
R3 = 260 #resistance in ohm
C4 = 0.5 # in µF
C4 = C4 * 10**-6 # in F
C2 = 106 # in pF
C2 = C2 * 10**-12 # in F
R4 = 1000/pi #resistance in ohm
r1 = (C4/C2)*R3 #resistance in ohm
C1 = (R4/R3)*C2 # in F
Epsilon_o = 8.854*10**-12
d = 4.5# in mm
d = d * 10**-3 # in m
D= 0.12 # in m
A= pi*D**2/4 # in m**2
print "The resistance = %0.2e Ω " %r1
C1= C1*10**12 # in pF
print "The capacitance = %0.2f pF " %C1
C1= C1*10**-12 # in F
f = 50 # in Hz
omega = 2*pi*f # in rad/sec
Pf= omega*C1*r1 # power factor
print "The power factor = %0.2f " %Pf
# C1 = Epsilon_r*Epsilon_o*(A/d)
Epsilon_r = (C1*d)/(Epsilon_o*A) # the relative permittivity
print "The relative permittivity = %0.1f " %Epsilon_r
# Note: The calculation of evaluating the value of C1 is wrong, so the answer of C1 in the book is wrong.
# But they putted the correct value of C1 to find the value of relative permittivity
```

In [76]:

```
from math import atan
from numpy import pi
#Given data
C2 = 500 # capacitance in nF
C2 = C2 * 10**-9 # in F
f = 50 #frequency in Hz
omega = 2*pi*f # in rad/sec
C4 = 0.148 #capacitance in µF
C4 = C4 * 10**-6 # in F
R4 = 72.6 #resistance in ohm
R3 = 300 #resistance in ohm
C1 = C2*(R4/R3) # capacitance in F
C1 = C1 * 10**6 # in µF
print "The capacitance = %0.3f µF " %C1
delta = 90-(atan(omega*C4*R4)*180/pi) #dielectric loss angle of capacitance in degree
print "The dielectric loss angle of capacitance = %0.2f degree " %delta
# Note: The calculation in the book is wrong, so the answer in the book is wrong.
```

In [69]:

```
#Given data
f1 = 3 #frequency in MHz
f1 = f1 * 10**6 # in Hz
C1 = 251 #capacitance in pF
C1 = C1 * 10**-12 # in F
f2 = 6 #frequency in MHz
f2 = f2 * 10**6 # in Hz
C2 = 50 #capacitance in pF
C2 = C2 * 10**-12 # in F
# f1 = 1/(2*pi*(sqrt(L*(C1+Cd))) ) (i)
# f2 = 1/(2*pi*(sqrt(L*(C2+Cd))) ) (ii)
# From eq(i) and (ii)
Cd = (C1 - (4*C2))/3 # self capacitance of the coil in F
Cd = Cd * 10**12 # in pF
print "The self capacitance of the coil = %0.f pF " %Cd
```

In [103]:

```
#Given data
f=500 #frequency in Hz
R2 = 2410 #resistance in ohm
R3 = 750 #resistance in ohm
R4 = 64.5 #resistance in ohm
R_C4 = 0.4 #resistance in ohm
C4 = 0.35 #capacitance in µF
C4 = C4 * 10**-6 # in F
XC4= 1/(2*pi*f*C4) # in Ω
Z4= R4+R_C4-1j*XC4 # in Ω
Z2= R2 # in Ω
Z3= R3 # in Ω
Z1= Z2*Z3/Z4 # in Ω
R1= Z1.real #resistance of choke coil in Ω
XL1= Z1.imag # in Ω
L1= XL1/(2*pi*f) #inductance of choke coil in H
print "The resistance of choke coil = %0.4f Ω " %R1
print "The inductance of choke coil = %0.4f H " %L1
```

In [105]:

```
#Given data
f = 50 # in Hz
omega = 2*pi*f # in rad/sec
R1 = 50 # in ohm
L1 = 0.1 # in H
XL1= 2*pi*f*L1 # in Ω
R2= 100 # in Ω
R3= 1000 # in Ω
Z1= R1+1j*XL1 # in Ω
Z2= R2 # in Ω
Z3= R3 # in Ω
# The bridge balance condition
Zx= Z2*Z3/Z1 # in Ω
# Comparing real part
Rx= Zx.real # in Ω
# Comparing imaginary part
XCx= abs(Zx.imag) # in Ω
Cx= 1/(2*pi*f*XCx) # in F
print "The value of Rx = %0.4f Ω " %Rx
print "The value of Cx = %0.4f µF " %(Cx*10**6)
```

In [110]:

```
from math import atan2
from numpy import pi
#Given data
f = 2 # in kHz
f = f * 10**3 # in Hz
R2= 834 # in Ω
C2= 0.124*10**-6 # in F
XC2= 1/(2*pi*f*C2) # in Ω
R3= 100 # in Ω
C4 = 0.1 # in µF
C4 = C4*10**-6 # in F
XC4= 1/(2*pi*f*C4) # in Ω
Z2= R2+1j*XC2 # in Ω
Z3= R3 # in Ω
Z4= -1j*XC4 # in Ω
# The bridge balance condition
Z1= Z2*Z3/Z4 # in Ω
mag= abs(Z1) # magnitude of effective impedence in Ω
theta= atan2(Z1.imag,Z1.real)*180/pi # phase angle of effective impedence in °
print "The magnitude of effective impedence = %0.2f Ω " %mag
print "The phase angle of effective impedence = %0.2f ° " %theta
```

In [73]:

```
#Given data
L1 = 52.6 #inductance in mH
R2 = 1.68 #resistance in ohm
# 80*(r1+(J*omega*L1)) = 80*( (R2+r2) + (J*omega*L2) )
L2 = L1 #inductance of the coil in mH
print "The inductance of the coil = %0.1f mH " %L2
r1 = 28.5 # in ohm
r2 = r1-R2 #resistance of the coil in ohm
print "The resistance of the coil = %0.2f ohm " %r2
```

In [74]:

```
#Given data
Q = 1 # in k ohm
Q = Q * 10**3 # in ohm
S = Q # in ohm
P = 500 # in ohm
r = 100 # in ohm
C = 0.5 # in µF
C = C * 10**-6 # in F
#Using standard condition, Rx = (R2*R3)/R4
Rx = (P*Q)/S # in ohm
print "The value of Rx = %0.f Ω " %Rx
#Lx = ((C*R2)/R4) * ( (R3*r) + (R4*r) + (R3*R4) )
Lx = ((C*P)/S) * ( (Q*r) + (S*r) + (Q*S) ) # in H
print "The value of Lx = %0.1f H " %Lx
```