# Chapter2-Network Theorem 1¶

## Ex1-pg2.4¶

In [1]:
##Network Theorem-1
##pg no.-2.4
##example2.1
print("\nConverting the two delta networks formed by resistors 4.5 Ohm,  3Ohm, and 7.5Ohm into equivalent star networks");
a=4.5;
b=3.;
c=7.5;
R1= (a*c)/(a+b+c);
R2= (c*b)/(c+b+a);
R3= (a*b)/(a+b+c);
print'%s %.2f %s %.2f %s %.2f %s '%("\nR1=R6 = ",R1," Ohm" and "\nR2=R5 =",R2," Ohm"  and "\nR3=R4 =" ,R3," Ohm");

Converting the two delta networks formed by resistors 4.5 Ohm,  3Ohm, and 7.5Ohm into equivalent star networks

R1=R6 =  2.25
R2=R5 = 1.50
R3=R4 = 0.90  Ohm


## Ex2-pg2.5¶

In [4]:
##Network Theorem-1
##pg no.-2.2
##example2.5
##converting delta network to star network
a=10.;
b=10.;
c=10.;
R=(a*b)/(a+b+c);
print("\nConverting the delta formed by three resistors of 10 Ohm into an equivalent star network");
print'%s %.2f %s'%("\nR1=R2=R3= ",R," Ohm");

Converting the delta formed by three resistors of 10 Ohm into an equivalent star network

R1=R2=R3=  3.33  Ohm


## Ex3-pg2.7¶

In [5]:
##Network Theorem-1
##pg no.-2.7
##example2.3
a=4.;
b=3.;
c=6.;
##star to delta conversion
R1=c+a+((a*c)/b);
R2=c+b+((c*b)/a);
R3=a+b+((a*b)/c);
x=1.35;
y=0.9;
RAB=(c*(x+y))/(c+x+y);
print'%s %.2f %s'%("\nR1 = ",R1," Ohm");
print'%s %.2f %s'%("\nR2 = ",R2," Ohm");
print'%s %.2f %s'%("\nR3 = ",R3," Ohm");
print'%s %.2f %s'%("\nThe network can be simplified as, \nRAB = ",RAB," Ohm");

R1 =  18.00  Ohm

R2 =  13.50  Ohm

R3 =  9.00  Ohm

The network can be simplified as,
RAB =  1.64  Ohm


## Ex5-pg2.9¶

In [6]:
##Network Theorem-1
##pg no.-2.9
##example2.5
##converting delta network to star network
a=25.;
b=20.;
c=35.;
R1=(b*c)/(a+b+c);
R2=(a*b)/(a+b+c);
R3=(a*c)/(a+b+c);
print("\nConverting the delta formed by resistors 20 Ohm ,25 Ohm, 35 Ohm  into an equivalent star network");
print'%s %.2f %s'%("\nR1= ",R1," Ohm");
print'%s %.2f %s'%("\nR2= ",R2," Ohm");
print'%s %.2f %s'%("\nR3= ",R3," Ohm");

Converting the delta formed by resistors 20 Ohm ,25 Ohm, 35 Ohm  into an equivalent star network

R1=  8.75  Ohm

R2=  6.25  Ohm

R3=  10.94  Ohm


## Ex8-pg2.15¶

In [7]:
##Network Theorem-1
##pg no.-2.15
##example2.8
a=5;
b=4;
c=3;
##Star to delta conversion
R1=a+b+((a*b)/c);
R2=c+b+((c*b)/a);
R3=a+c+((a*c)/b);
a1=6;
b1=4;
c1=8;
##Satr to delta conversion
R4=a1+b1+((a1*b1)/c1);
R5=c1+b1+((c1*b1)/a1);
R6=a1+c1+((a1*c1)/b1);
x=6.17;
y=9.78;
RAB=(x*y)/(x+y);
print("\nConverting star network formed by 3 Ohm,4 Ohm ,5 Ohm into equivalent delta network ");
print'%s %.2f %s %.2f %s %.2f %s'%("\nR1= ",R1," Ohm" and " \nR2= ",R2," Ohm" and " \nR3 = ",R3," Ohm");
print("\nSimilarly, converting star network formed by 6 Ohm,4 Ohm ,8 Ohm into equivalent delta network");
print'%s %.2f %s %.2f %s %.2f %s '%("\nR4= ",R4," Ohm" and " \nR5= ",R5," Ohm " and "\nR6 =",R6," Ohm");
print'%s %.2f %s'%("\n Simplifying the parallel networks, we get \nRAB = ",RAB," Ohms");

Converting star network formed by 3 Ohm,4 Ohm ,5 Ohm into equivalent delta network

R1=  15.00
R2=  9.00
R3 =  11.00  Ohm

Similarly, converting star network formed by 6 Ohm,4 Ohm ,8 Ohm into equivalent delta network

R4=  13.00
R5=  17.00
R6 = 26.00  Ohm

Simplifying the parallel networks, we get
RAB =  3.78  Ohms


## Ex9-pg2.18¶

In [8]:
##Network Theorem 1
##page no-2.18
##example2.9
import math
import numpy
print("Applying KVL to mesh 1");
print("10*I1-3*I2-6*I3=0")##equation 1
print("Applying KVL to mesh 2");
print("-3*I1+10*I2=-5");##equation 2
print("Applying KVL to mesh 3");
print("-6*I1+10*I3=25");##equation 3
print("Solving the three equations");
A=numpy.matrix([[10, -3, -6],[-3 ,10 ,0],[-6, 0, 10]])   ##solving the equations in matrix form
B=numpy.matrix([[10], [-5], [25]])
X=numpy.dot(numpy.linalg.inv(A),B)

print[X];
print("I1=4.27 A");
print("I2=0.78 A");
print("I3=5.06 A");
print("I5ohm=4.27 A");

Applying KVL to mesh 1
10*I1-3*I2-6*I3=0
Applying KVL to mesh 2
-3*I1+10*I2=-5
Applying KVL to mesh 3
-6*I1+10*I3=25
Solving the three equations
[matrix([[ 4.27272727],
[ 0.78181818],
[ 5.06363636]])]
I1=4.27 A
I2=0.78 A
I3=5.06 A
I5ohm=4.27 A


## Ex10-pg2.19¶

In [9]:
##Network Theorem 1
##page no-2.19
##example 2.10
import math
import numpy
from numpy import linalg
print("Applying KVL to mesh 1");
print("7*I1-I2=10")##equation 1
print("Applying KVL to mesh 2");
print("-I1+6*I2-3*I3=0");##equation 2
print("Applying KVL to mesh 3");
print("-3*I2+13*I3=-20");##equation 3
print("Solving the three equations");
A=numpy.matrix([[7 ,-1, 0],[-1, 6, -3],[0 ,-3, 13]]);##solving the equations in matrix form
B=numpy.matrix([[10], [0], [-20]])
X=numpy.dot(numpy.linalg.inv(A),B);
print[X];
print("I1=1.34 A");
print("I1=-0.62 A");
print("I3=-1.68 A");
print("I2ohm=1.34 A");

Applying KVL to mesh 1
7*I1-I2=10
Applying KVL to mesh 2
-I1+6*I2-3*I3=0
Applying KVL to mesh 3
-3*I2+13*I3=-20
Solving the three equations
[matrix([[ 1.34042553],
[-0.61702128],
[-1.68085106]])]
I1=1.34 A
I1=-0.62 A
I3=-1.68 A
I2ohm=1.34 A


## Ex11-pg2.20¶

In [10]:
##Network Theorem 1
##page no-2.20
##example 2.11
import math
import numpy
print("Applying KVL to mesh 1");
print("3*I1-I2-2*I3=8");##equation 1
print("Applying KVL to mesh 2");
print("-I1+8*I2-3*I3=10");##equation 2
print("Applying KVL to mesh 3");
print("-2*I1-3*I2+10*I3=12");##equation 3
print("Solving the three equations");
A=numpy.matrix([[3 ,-1 ,-2],[-1, 8 ,-3],[-2 ,-3 ,10]]);##solving the equations in matrix form
B=numpy.matrix([[8], [10] ,[12]])
X=numpy.dot(numpy.linalg.inv(A),B);
print[X];
print("I1=6.01 A");
print("I1=3.27 A");
print("I3=3.38 A");
print("I5ohm=3.38 A");

Applying KVL to mesh 1
3*I1-I2-2*I3=8
Applying KVL to mesh 2
-I1+8*I2-3*I3=10
Applying KVL to mesh 3
-2*I1-3*I2+10*I3=12
Solving the three equations
[matrix([[ 6.01257862],
[ 3.27044025],
[ 3.3836478 ]])]
I1=6.01 A
I1=3.27 A
I3=3.38 A
I5ohm=3.38 A


## Ex12-pg2.21¶

In [11]:
##Network Theorem 1
##page no-2.21
##example 2.12
import numpy
print("Applying KVL to mesh 1");
print("8*I1-I2-4*I3=4");##equation 1
print("Applying KVL to mesh 2");
print("-I1+8*I2-5*I3=0");##equation 2
print("Applying KVL to mesh 3");
print("-4*I1-5*I2+15*I3=0");##equation 3
print("Solving the three equations");
A=numpy.matrix([[8 ,-1 ,-4],[-1 ,8 ,-5],[-4 ,-5 ,15]]);##solving the equations in matrix form
B=numpy.matrix([[4] ,[0], [0]])
X=numpy.dot(numpy.linalg.inv(A),B);
print[X];
print("I1=0.66");
print("I1=0.24 A");
print("I3=0.26 A");
print("current supplied by the battery = 0.66 A");

Applying KVL to mesh 1
8*I1-I2-4*I3=4
Applying KVL to mesh 2
-I1+8*I2-5*I3=0
Applying KVL to mesh 3
-4*I1-5*I2+15*I3=0
Solving the three equations
[matrix([[ 0.65857886],
[ 0.24263432],
[ 0.25649913]])]
I1=0.66
I1=0.24 A
I3=0.26 A
current supplied by the battery = 0.66 A


## Ex13-pg2.22¶

In [12]:
##Network Theorem 1
##page no-2.22
##example 2.13
import math
import numpy
print("Applying KVL to mesh 1");
print("V+13*I1-2*I2-5*I3=20");##mesh equation 1
print("Applying KVL to mesh 2");
print("2*I1-6*I2+I3=0");##mesh equation 2
print("Applying KVL to mesh 3");
print("V+5*I1+I2-10*I3=0");##mesh equation 3
print("putting I1=0 in equation 1, 2 and 3 we get");
print("V-2*I2-5*I3=20");##equation 1
print("-6*I2+I3=0");##equation 2
print("V+I2-10*I3=0");##equation 3
print("Solving the three equations");
A=numpy.matrix([[1 ,-2 ,-5],[0 ,-6 ,1],[1 ,1 ,-10]]);##solving the equations in matrix form
B=numpy.matrix([[20], [0] ,[0]])
X=numpy.dot(numpy.linalg.inv(A),B);
print[X];
print("V=43.7 V")

Applying KVL to mesh 1
V+13*I1-2*I2-5*I3=20
Applying KVL to mesh 2
2*I1-6*I2+I3=0
Applying KVL to mesh 3
V+5*I1+I2-10*I3=0
putting I1=0 in equation 1, 2 and 3 we get
V-2*I2-5*I3=20
-6*I2+I3=0
V+I2-10*I3=0
Solving the three equations
[matrix([[ 43.7037037 ],
[  0.74074074],
[  4.44444444]])]
V=43.7 V


## Ex14-pg2.22¶

In [13]:
##Network Theorem 1
##page no-2.13
##example2.14
import math
import numpy
print("Mesh 1 contains a current source of 6A.Hence, we cannot write KVL equation for Mesh 1.direction of current source and mesh current I1 are same,");
print("I1=6A");##equation 1
print("Applying KVL to mesh 2");
print("18*I2-6*I3=108");##equation 2
print("Applying KVL to mesh 3");
print("6*I2-11*I3=9");##equation 3
print("Solving the three equations");
A=numpy.matrix([[18, -6],[6 ,-11]])##solving the equations in matrix form
B=numpy.matrix([[108] ,[9]])
X=numpy.dot(numpy.linalg.inv(A),B);
print[X];
print("I3 = 3A");
print("I2ohm = 3A");

Mesh 1 contains a current source of 6A.Hence, we cannot write KVL equation for Mesh 1.direction of current source and mesh current I1 are same,
I1=6A
Applying KVL to mesh 2
18*I2-6*I3=108
Applying KVL to mesh 3
6*I2-11*I3=9
Solving the three equations
[matrix([[ 7.],
[ 3.]])]
I3 = 3A
I2ohm = 3A


## Ex15-pg2.23¶

In [14]:
##Network Theorem 1
##page no-2.23
##example2.15
print("from the fig,");
print("IA=I1");##equation 1
print("IB=I2");##equation 2
print("Applying Kvl to mesh 1:");
print("5-5*I1-10*IB-10*(I1-I2)-5*IA=0");
print("5-5*I1-10*I2-10*I1+10*I2-5*I1=0");
print("-20*I1=-5");
I1=5./20.;
print'%s %.2f %s'%("I1= ",I1," A");##equation 3
print("Applying Kvl to mesh 2:");
print("15*I1-15*I2=10");##equation 4
print("Put I1=0.25 A in equation 4");
print("-6.25=15*I2");
I2=-6.25/15.;
print'%s %.2f %s '%("I2= ",I2," A");

from the fig,
IA=I1
IB=I2
Applying Kvl to mesh 1:
5-5*I1-10*IB-10*(I1-I2)-5*IA=0
5-5*I1-10*I2-10*I1+10*I2-5*I1=0
-20*I1=-5
I1=  0.25  A
Applying Kvl to mesh 2:
15*I1-15*I2=10
Put I1=0.25 A in equation 4
-6.25=15*I2
I2=  -0.42  A


## Ex17-pg2.24¶

In [15]:
##Network Theorem 1
##page no-2.25
##example2.17
import math
import numpy
print("from the fig,");
print("V1=-5*I1");##equation 1
print("V2=2*I2");##equation 2
print("Applying Kvl to mesh 1:");
print("20*I1+3*I2=-5");##equation 3
print("Applying Kvl to mesh 2:");
print("11*I1-3*I2=10");##equation 4
print("Solving equations 3 and 4");##solving equations in matrix form
A=numpy.matrix([[20, 3],[11, -3]]);
B=numpy.matrix([[-5], [10]])
X=numpy.dot(numpy.linalg.inv(A),B);
print[X];
print("I1=0.161 A");
print("I2=-2.742 A");

from the fig,
V1=-5*I1
V2=2*I2
Applying Kvl to mesh 1:
20*I1+3*I2=-5
Applying Kvl to mesh 2:
11*I1-3*I2=10
Solving equations 3 and 4
[matrix([[ 0.16129032],
[-2.74193548]])]
I1=0.161 A
I2=-2.742 A


## Ex18-pg2.25¶

In [16]:
##Network Theorem-1
##pg no.-2.25
##example2.18
import numpy
print("from the fig,");
print("Iy=I1");##equation 1
print("Ix=I1-I2");##equation 2
print("Applying Kvl to mesh 1:");
print("-10*I1+3*I2=5");##equation 3
print("Applying Kvl to mesh 2:");
print("-I1-3*I2=10");##equation 4
print("Solving equations 3 and 4");##solving equations in matrix form
A=numpy.matrix([[-10 ,3],[-1, -3]]);
B=numpy.matrix([[5] ,[10]])
X=numpy.dot(numpy.linalg.inv(A),B);
print[X];
print("I1=-1.364 A");
print("I2=-2878 A");
x=-1.364;
y=-2.878;
Ix=x-y;
print'%s %.2f %s %.2f %s '%("\nIy = ",x," A" and " \nIx = ",Ix," A");

from the fig,
Iy=I1
Ix=I1-I2
Applying Kvl to mesh 1:
-10*I1+3*I2=5
Applying Kvl to mesh 2:
-I1-3*I2=10
Solving equations 3 and 4
[matrix([[-1.36363636],
[-2.87878788]])]
I1=-1.364 A
I2=-2878 A

Iy =  -1.36
Ix =  1.51  A


## Ex19-pg2.26¶

In [17]:
##Network Theorem 1
##page no-2.26
##example2.19
import math
import numpy
print("Applying KVL to mesh 1:");
print("11*I1-10*I2=2");##equation 1
print("Writing current equation to supermesh:")
print("I3-I2=4");##equation 2
print("Applying KVL to outer path of supermesh:");
print("2*I1-3*I2-3*I3=0");##equation 3
print("solving these equations we get :");##solving equations in matrix form
A=numpy.matrix([[11, -10, 0],[0 ,-1 ,1],[2 ,-3, -3]]);
B=numpy.matrix([[2] ,[4] ,[0]])
X=numpy.dot(numpy.linalg.inv(A),B);
print[X];
I1=-2.35
I2=-2.78
I3=1.22
I4=I1-I2;
print'%s %.2f %s'%("\ncurrent through the 10 ohm resistor = I1-I2 = ",I4," A");

Applying KVL to mesh 1:
11*I1-10*I2=2
Writing current equation to supermesh:
I3-I2=4
Applying KVL to outer path of supermesh:
2*I1-3*I2-3*I3=0
solving these equations we get :
[matrix([[-2.34782609],
[-2.7826087 ],
[ 1.2173913 ]])]

current through the 10 ohm resistor = I1-I2 =  0.43  A


## Ex20-pg2.26¶

In [18]:
##Network Theorem 1
##page no-2.26
##example2.20
import math
import numpy
print("writing equation for supermesh,");
print("I1-I3=7");##equation 1
print("Applying Kvl to the outer path of the supermesh:");
print("-I1+4*I2-4*I3 = -7");##equation 2
print("Applying Kvl to mesh 2:");
print("I1-6*I2+3*I3 = 0");##equation 3
print("Solving equations 1 ,2 and 3");##solving equations in matrix form
A=numpy.matrix([[1 ,0 ,-1],[-1 ,4 ,-4],[1 ,-6 ,3]]);
B=numpy.matrix([[7], [-7], [0]])
X=numpy.dot(numpy.linalg.inv(A),B);
print[X];
print("I1=9 A");
print("I2=-2.5 A");
print("I3=-2 A");
x=2.5;
y=2;
z=x-y;
print'%s %.2f %s'%("\nCurrent through the 3-Ohm resistor = I2-I3 =",z," A");

writing equation for supermesh,
I1-I3=7
Applying Kvl to the outer path of the supermesh:
-I1+4*I2-4*I3 = -7
Applying Kvl to mesh 2:
I1-6*I2+3*I3 = 0
Solving equations 1 ,2 and 3
[matrix([[ 9. ],
[ 2.5],
[ 2. ]])]
I1=9 A
I2=-2.5 A
I3=-2 A

Current through the 3-Ohm resistor = I2-I3 = 0.50  A


## Ex21-pg2.27¶

In [19]:
##Network Theorem 1
##page no-2.27
##example2.21
import math
import numpy
print("Applying KVL to mesh 1:");
print("15*I1-10*I2-5*I3=50");##equation 1
print("Writing current equation to supermesh:")
print("I2-I3=2 A");##equation 2
print("Applying KVL to outer path of supermesh:");
print("-15*I1+12*I2+6*I3=0");##equation 3
print("solving these equations we get :");##solving equations in matrix form
A=numpy.matrix([[15, -10, -5],[0 ,1 ,-1],[-15, 12, 6]]);
B=numpy.matrix([[50] ,[2] ,[0]])
X=numpy.dot(numpy.linalg.inv(A),B);
print[X];
I1=20.
I2=17.33
I3=15.33
I4=I1-I3;
print'%s %.2f %s'%("\ncurrent through the 5 ohm resistor = I1-I3 = ",I4," A");

Applying KVL to mesh 1:
15*I1-10*I2-5*I3=50
Writing current equation to supermesh:
I2-I3=2 A
Applying KVL to outer path of supermesh:
-15*I1+12*I2+6*I3=0
solving these equations we get :
[matrix([[ 20.        ],
[ 17.33333333],
[ 15.33333333]])]

current through the 5 ohm resistor = I1-I3 =  4.67  A


## Ex22-pg2.28¶

In [20]:
##Network Theorem 1
##page no-2.28
##example2.22
import math
import numpy
print("from the fig,");
print("I4=40");##equation 1
print("\nmeshes 2 and 3 form a supermesh. current equation for supermesh,")
print("-I1+2*I2-I3 = 0");##equation 2
print("Applying Kvl to supermesh:");
print("-1/5(I2-I1)-1/20*I2-1/15*I3-1/2(I3-I4)=0");##equation 3
print("applying KVL to mesh 1");
print("-1/10*I1-1/5(I1-I2)-1/6(I1-I4)=6");##equation 4
print("Solving equations 1 ,2 ,3 and 4");##solving equations in matrix form
A=numpy.matrix([[0 ,0 ,0 ,1],[-1, 2 ,-1 ,0],[0.2, -0.25, -17/30, 0.5],[-7/15, 0.2, 0 ,1/6]]);
B=numpy.matrix([[40], [0] ,[0], [6]])
X=numpy.dot(numpy.linalg.inv(A),B);
print[X];
print("I1=10 A");
print("I2=-20 A");
print("I3=30 A");
print("I4=40 A");

from the fig,
I4=40

meshes 2 and 3 form a supermesh. current equation for supermesh,
-I1+2*I2-I3 = 0
Applying Kvl to supermesh:
-1/5(I2-I1)-1/20*I2-1/15*I3-1/2(I3-I4)=0
applying KVL to mesh 1
-1/10*I1-1/5(I1-I2)-1/6(I1-I4)=6
Solving equations 1 ,2 ,3 and 4
[matrix([[ -4.72636816],
[  6.3681592 ],
[ 17.46268657],
[ 40.        ]])]
I1=10 A
I2=-20 A
I3=30 A
I4=40 A


## Ex24-pg2.29¶

In [21]:
##Network Theorem 1
##page no-2.29
import numpy
##example2.24
print("Applying KCL to node 1:");
print("2*V1-V2 = 2");##equation 1
print("Applying KCL to node 2:");
print("3*V2-V1 = 4");##equation 2
print("Solving equations 1 and 2");##solving equations in matrix form
A=([[2 ,-1],[-1 ,3]]);
B=([[2] ,[4]])
X=numpy.dot(numpy.linalg.inv(A),B);
print[X];
print("V1= 2 V");
print("V2=-2 V");

Applying KCL to node 1:
2*V1-V2 = 2
Applying KCL to node 2:
3*V2-V1 = 4
Solving equations 1 and 2
[array([[ 2.],
[ 2.]])]
V1= 2 V
V2=-2 V


## Ex25-pg2.30¶

In [22]:
##Network Theorem 1
##page no-2.30
##example2.25
import numpy
print("Applying KCL to node 1:");
print("8*VA-2*VB = 50");##equation 1
print("Applying KCL to node 2:");
print("-3*VA+9*VB = 85");##equation 2
print("Solving equations 1 and 2");##solving equations in matrix form
A=([[8 ,-2],[-3 ,9]]);
B=([[50], [85]])
X=numpy.dot(numpy.linalg.inv(A),B);
print[X];
print("VA= 9.39 V");
print("VB= 12.58 V");

Applying KCL to node 1:
8*VA-2*VB = 50
Applying KCL to node 2:
-3*VA+9*VB = 85
Solving equations 1 and 2
[array([[  9.39393939],
[ 12.57575758]])]
VA= 9.39 V
VB= 12.58 V


## Ex26-pg2.30¶

In [24]:
##Network Theorem 1
##page no-2.30
import numpy
##example2.26
print("Applying KCL to node 1:");
print("5*V1-2*V2 = -24");##equation 1
print("Applying KCL to node 2:");
print("10*V1-31*V2+6*V3 = 300");##equation 2
print("Applying KCL to node 3:");
print("-4*V2 +9*V3 = 160");##equation 3
print("Solving equations 1,2 and 3");##solving equations in matrix form
A=([[5, -2 ,0],[10, -31, 6],[0, -4, 9]]);
B=([[-24] ,[300] ,[160]])
X=numpy.dot(numpy.linalg.inv(A),B);
print[X];
print("V1= -8.77 V");
print("V2= -9.92 V");
print("V3= 13.37 V");
x=13.37;
y=-9.92;
z=(x-y)/5.;
print'%s %.2f %s'%("\ncurrent through the 5 ohm resistor = V3-V2/5 = ",z," A");

Applying KCL to node 1:
5*V1-2*V2 = -24
Applying KCL to node 2:
10*V1-31*V2+6*V3 = 300
Applying KCL to node 3:
-4*V2 +9*V3 = 160
Solving equations 1,2 and 3
[array([[ -8.76712329],
[ -9.91780822],
[ 13.36986301]])]
V1= -8.77 V
V2= -9.92 V
V3= 13.37 V

current through the 5 ohm resistor = V3-V2/5 =  4.66  A


## Ex27-pg2.31¶

In [25]:
##Network Theorem 1
##page no-2.31
##example2.27
import numpy
print("Applying KCL to node 1:");
print("50*V1-20*V2 = 2400");##equation 1
print("Applying KCL to node 2:");
print("-10*V1+19*V2 = 240");##equation 2
print("Solving equations 1 and 2");##solving equations in matrix form
A=([[50, -20],[-10, 19]]);
B=([[2400] ,[240]])
X=numpy.dot(numpy.linalg.inv(A),B);
print[X];
print("V1= 67.2 V");
print("V2=-48 V");

Applying KCL to node 1:
50*V1-20*V2 = 2400
Applying KCL to node 2:
-10*V1+19*V2 = 240
Solving equations 1 and 2
[array([[ 67.2],
[ 48. ]])]
V1= 67.2 V
V2=-48 V


## Ex28-pg2.32¶

In [3]:
##Network Theorem 1
##page no-2.32
##example2.28
import numpy
print("Applying KCL to node 1:");
print("4*VA-2*VB = 5");##equation 1
print("Applying KCL to node 2:");
print("-2*VA+3*VB = 4");##equation 2
print("Solving equations 1 and 2");##solving equations in matrix form
A=([[4, -2],[-2 ,3]]);
B=([[5], [4]])
X=numpy.dot(numpy.linalg.inv(A),B);

print(X);
print("VA= 2.88 V");
print("VB= 3.25 V");

Applying KCL to node 1:
4*VA-2*VB = 5
Applying KCL to node 2:
-2*VA+3*VB = 4
Solving equations 1 and 2
[[ 2.875]
[ 3.25 ]]
VA= 2.88 V
VB= 3.25 V


## Ex29-pg2.33¶

In [27]:
import numpy
##Network Theorem 1
##page no-2.33
##example2.29
print("Applying KCL to node 1:");
print("4*V1-2*V2-V3 = -24");##equation 1
print("Applying KCL to node 2:");
print("-50*V1+71*V2-20*V3 = 0");##equation 2
print("Applying KCL to node 3:");
print("-5V1-4*V2 +10*V3 = 180");##equation 3
print("Solving equations 1,2 and 3");##solving equations in matrix form
A=numpy.matrix([[4, -2, -1],[-50 ,71 ,-20],[-5, -4 ,10]]);
B=numpy.matrix([[-24], [0], [180]])
X=numpy.dot(numpy.linalg.inv(A),B);
print[X];
print("V1= 6.35 V");
print("V2= 11.76 V");
print("V3= 25.88 V");
x=25.88;
y=11.76;
z=(x-y);
print'%s %.2f %s'%("\ncurrent through the 5 ohm resistor = V3-V2/5 = ",z," A");

Applying KCL to node 1:
4*V1-2*V2-V3 = -24
Applying KCL to node 2:
-50*V1+71*V2-20*V3 = 0
Applying KCL to node 3:
-5V1-4*V2 +10*V3 = 180
Solving equations 1,2 and 3
[matrix([[  6.35294118],
[ 11.76470588],
[ 25.88235294]])]
V1= 6.35 V
V2= 11.76 V
V3= 25.88 V

current through the 5 ohm resistor = V3-V2/5 =  14.12  A


## Ex30-pg2.34¶

In [28]:
##Network Theorem 1
##page no-2.34
##example2.30
import numpy
print("Applying KCL to node 1:");
print("8*V1-V2 = 50");##equation 1
print("Applying KCL to node 2:");
print("-2*V1+11*V2 = -500");##equation 2
print("Solving equations 1 and 2");##solving equations in matrix form
A=([[8, -1],[-2, 17]]);
B=([[50] ,[-500]])
X=numpy.dot(numpy.linalg.inv(A),B);
print[X];
print("V1= 2.61 V");
print("V2=-29.1 V");
x=2.61;
y=-29.1;
I1=-x/2.;
I2=(x-y)/10.;##current through 10 Ohm resistor
I3=(y+50)/2.;##50 volts is the supply to the circuit
print'%s %.2f %s %.2f %s %.2f %s '%("\nI1= ",I1," A" and  "\nI2= ",I2,"A" and " \nI3= ",I3," A");

Applying KCL to node 1:
8*V1-V2 = 50
Applying KCL to node 2:
-2*V1+11*V2 = -500
Solving equations 1 and 2
[array([[  2.6119403 ],
[-29.10447761]])]
V1= 2.61 V
V2=-29.1 V

I1=  -1.30
I2=  3.17
I3=  10.45  A


## Ex31-pg2.34¶

In [29]:
##Network Theorem 1
##page no-2.34
##example2.31
import numpy
print("Applying KCL to node a:");
print("0.5*Va-0.2*Vb = 34.2");#equation 1
print("Applying KCL to node b:");
print("0.1*Va-0.4*Vb = -32.4");##equation 2
print("Solving equations 1 and 2");##solving equations in matrix form
A=numpy.matrix([[0.5,0.2],[0.1, -0.4]]);
B=numpy.matrix([[34.2], [-32.4]])
X=numpy.dot(numpy.linalg.inv(A),B);
print[X];
print("Va= 112 V");
print("Vb= 109 V");
x=112.;
y=109.;
I1=(120.-x)/0.2;
I2=(x-y)/0.3;
I3=(110-y)/0.1;
print'%s %.2f %s %.2f %s %.2f %s '%("\nI1=",I1," A " and "\nI2= ",I2," A" and " \nI3= ",I3," A");

Applying KCL to node a:
0.5*Va-0.2*Vb = 34.2
Applying KCL to node b:
0.1*Va-0.4*Vb = -32.4
Solving equations 1 and 2
[matrix([[ 32.72727273],
[ 89.18181818]])]
Va= 112 V
Vb= 109 V

I1= 40.00
I2=  10.00
I3=  10.00  A


## Ex32-pg2.35¶

In [35]:
##Network Theorem 1
##page no-2.35
##example2.35
import numpy
print("Applying KCL to node 1:");
print("V1 = 50");##equation 1
print("Applying KCL to node 2:");
print("-2*V1+17*V2 = 50");#equation 2
print("Solving equations 1 and 2");##solving equations in matrix form
A=([[1, 0],[-2, 17]]);
B=([[50] ,[50]])
X=numpy.dot(numpy.linalg.inv(A),B);
print[X];
print("V1= 50 V");
print("V2= 8.82 V");
x=8.82;
y=(x/10.);
print'%s %.2f %s'%("\ncurrent in the 10-Ohm resistor =V2/10 =",y," A");

Applying KCL to node 1:
V1 = 50
Applying KCL to node 2:
-2*V1+17*V2 = 50
Solving equations 1 and 2
[array([[ 50.        ],
[  8.82352941]])]
V1= 50 V
V2= 8.82 V

current in the 10-Ohm resistor =V2/10 = 0.88  A


## Ex33-pg2.36¶

In [33]:
##Network Theorem 1
##page no-2.36
##example2.33
import numpy
print("Applying KCL to node a:");
print("6*Va-5*Vb = -20");##equation 1
print("Applying KCL to node b:");
print("-10*Va+17*Vb-5*Vc = 0");##equation 2
print("At node c");
print("Vc = 20");
print("Solving equations 1,2 and 3");##solving equations in matrix form
A=numpy.matrix([[6 ,-5 ,0],[-10 ,17 ,-5],[0, 0, 1]]);
B=numpy.matrix([[-20], [0] ,[20]])
X=numpy.dot(numpy.linalg.inv(A),B);
print[X];
print("Va= 3.08 V");
print("Vb= 7.69 V");
x=3.08;
y=7.69;
z=20.;
Va = x-y;
Vb = y-z;
print'%s %.2f %s %.2f %s '%("\nV1 = Va-Vb =  ",Va,"V" and "\nV2 = Vb-Vc = ",Vb," V");

Applying KCL to node a:
6*Va-5*Vb = -20
Applying KCL to node b:
-10*Va+17*Vb-5*Vc = 0
At node c
Vc = 20
Solving equations 1,2 and 3
[matrix([[  3.07692308],
[  7.69230769],
[ 20.        ]])]
Va= 3.08 V
Vb= 7.69 V

V1 = Va-Vb =   -4.61
V2 = Vb-Vc =  -12.31  V


## Ex34-pg2.37¶

In [32]:
##Network Theorem 1
##page no-2.37
##example2.334
import math
import numpy
print("At node A:");
print("VA = 60");##equation 1
print("Applying KCL to node B:");
print("-VA+3*VB-VC = 12");##equation 2
print("Applying KCL to node C:");
print("-2*VA-5*VB+10*VC");##equation 3
print("Solving equations 1,2 and 3");##solving equations in matrix
A=numpy.matrix([[1 ,0 ,0],[-1 ,3 ,-1],[-2 ,-5 ,10]]);
B=numpy.matrix([[60], [12], [24]])
X=numpy.dot(numpy.linalg.inv(A),B)
print[X];
print("VC= 31.68 V");
print("Voltage across the 100 Ohm resistor = 31.68 V");

At node A:
VA = 60
Applying KCL to node B:
-VA+3*VB-VC = 12
Applying KCL to node C:
-2*VA-5*VB+10*VC
Solving equations 1,2 and 3
[matrix([[ 60.  ],
[ 34.56],
[ 31.68]])]
VC= 31.68 V
Voltage across the 100 Ohm resistor = 31.68 V


## Ex35-pg2.38¶

In [31]:
##Network Theorem 1
##page no-2.38
##example2.35
import math
import numpy
print("Applying KCL to node 1:");
print("2.5*V1-0.5*V2 = 5");##equation 1
print("Applying KCL to node 2:");
print("V1-V2 = 0");##equation 2
print("Solving equations 1 and 2");##solving equations in matrix form
A=numpy.matrix([[2.5, -0.5],[1 ,-1]]);
B=numpy.matrix([[5] ,[0]])
X=numpy.dot(numpy.linalg.inv(A),B);
print[X];
print("V1= 2.5 V");
print("V2=-2.5 V");

Applying KCL to node 1:
2.5*V1-0.5*V2 = 5
Applying KCL to node 2:
V1-V2 = 0
Solving equations 1 and 2
[matrix([[ 2.5],
[ 2.5]])]
V1= 2.5 V
V2=-2.5 V


## Ex37-pg2.39¶

In [30]:
##Network Theorem 1
##page no-2.39
##example2.37\
import math
import numpy
print("Applying KCL to node 1:");
print("2*V1+17*V2 = 0")##equation 1
print("Applying KCL to node 2:");
print("V1+6V2 = 0");##equation 2
print("Solving equations 1 and 2")##solving equations in matrix form
A=numpy.matrix([[2 ,17],[1, 6]]);
B=numpy.matrix([[0], [0]])
X=numpy.dot(numpy.linalg.inv(A),B)
print(X);
print("V1= 0 V");
print("V2= 0 V");

Applying KCL to node 1:
2*V1+17*V2 = 0
Applying KCL to node 2:
V1+6V2 = 0
Solving equations 1 and 2
[[ 0.]
[ 0.]]
V1= 0 V
V2= 0 V


## Ex38-pg2.40¶

In [1]:
##Network Theorem 1
##page no-2.40
##example2.38
import numpy
import math
print("Applying KCL to node a:");
print("2*Va-0.5*Vb-0.5*Vc = 5");##equation 1
print("Applying KCL to node b:");
print("-3/2*Va+5/6*Vb+2/3*Vc = -1");##equation 2
print("Applying KCL to node c:");
print("1/2*Va+1/3*Vb-31/30*Vc = -1");##equation 3
print("Solving equations 1,2 and 3");##solving equations in matrix form
A=numpy.matrix([[2, -0.5, -0.5],[-3/2, 5/6, 2/3],[0.5 ,1/3 ,-31/30 ]]);
B=numpy.matrix([[5], [-1], [0]])
X=numpy.dot(numpy.linalg.inv(A),B)
print[X];

print("Va= 4.303 V");
print("Vb= 3.87 V");
print("Vc= 3.33 V");

Applying KCL to node a:
2*Va-0.5*Vb-0.5*Vc = 5
Applying KCL to node b:
-3/2*Va+5/6*Vb+2/3*Vc = -1
Applying KCL to node c:
1/2*Va+1/3*Vb-31/30*Vc = -1
Solving equations 1,2 and 3
[matrix([[ 0.5  ],
[-8.125],
[ 0.125]])]
Va= 4.303 V
Vb= 3.87 V
Vc= 3.33 V


## Ex39-pg2.41¶

In [3]:
##Network Theorem 1
##page no-2.41
##example2.39
import math
import numpy
print("from the figure");
print("V4= 40 V");##equation 1
print("nodes 2 and 3 form suoernode:");
print("V1-2*V2+V3 = 0");##equation 2
print("Applying KCL to node 1:");
print("7/15*V1-1/5*V2 = 2/3");##equation 3
print("Applying KCL to supernode :");
print("-23/30*V1 +83/60*V3 = 20");##equation 4
print("Solving equations 1,2,3 and 4");##solving equations in matrix form
A=numpy.matrix([[0, 0 ,0 ,1],[1 ,-2 ,1 ,0],[7/15 ,-1/5, 0, 0],[-23/30, 83/60, 0 ,0]]);
B=numpy.matrix([[40] ,[0], [2/3], [20]])
X=numpy.dot(numpy.linalg.inv(A),B)
print[X];
print("V1= 10 V");
print("V2= 20 V");
print("V3= 30 V");

from the figure
V4= 40 V
nodes 2 and 3 form suoernode:
V1-2*V2+V3 = 0
Applying KCL to node 1:
7/15*V1-1/5*V2 = 2/3
Applying KCL to supernode :
-23/30*V1 +83/60*V3 = 20
Solving equations 1,2,3 and 4
[matrix([[-20.],
[  0.],
[ 20.],
[ 40.]])]
V1= 10 V
V2= 20 V
V3= 30 V


## Ex40-pg2.42¶

In [2]:
##Network Theorem 1
##page no-2.42
##example2.40
import math
import numpy
print("selecting central node as reference node");
print("V1= -12 V");##equation 1
print("Applying KCL at node 1:");
print("-2*V1+2.5*V2-0.5V3 = 14");##equation 2
print("nodes 3 and 4 form a supernode");
print("0.2*V1+V3-1.2*V4 = 0");##equation 3
print("Applying KCL to supernode :");
print("0.1*V1-V2+0.5*V3+1.4*V4 = 0");##equation 4
print("Solving equations 1,2,3 and 4");##solving equations in matrix form
A=numpy.matrix([[1, 0, 0 ,0],[-2 ,2.5 ,-0.5 ,0],[0.2 ,0 ,1, -1.2],[0.1 ,-1 ,0.5, 1.4]]);
B=numpy.matrix([[-12], [14] ,[0],[0]])
X=numpy.dot(numpy.linalg.inv(A),B)
print[X];
print("V1= -12 V");
print("V2= -4 V");
print("V3= 0");
print("V4= -2 V");

selecting central node as reference node
V1= -12 V
Applying KCL at node 1:
-2*V1+2.5*V2-0.5V3 = 14
nodes 3 and 4 form a supernode
0.2*V1+V3-1.2*V4 = 0
Applying KCL to supernode :
0.1*V1-V2+0.5*V3+1.4*V4 = 0
Solving equations 1,2,3 and 4
[matrix([[ -1.20000000e+01],
[ -4.00000000e+00],
[  4.44089210e-16],
[ -2.00000000e+00]])]
V1= -12 V
V2= -4 V
V3= 0
V4= -2 V