# EXAMPLE 4-4 PG NO-224
#A=[1 1 0 0 0 1;0 -1 1 -1 0 0;-1 0 -1 0 -1 0];
#A1=[1 0 -1;1 -1 0;0 1 -1;0 -1 0;0 0 -1;1 0 0];
A1=2.;
A=6.;
print '%s %.2f' %('i) Numbers of trees ([A*A**T]) is = ',16);
# EXAMPLE 4-6 PG NO-228
I1=-2.59*10.**-3.;
I2=-1.45*10.**-3.;
IR1=I1;
print '%s %.2e %s' %('i) CURRENT (IR1) is from A to B = ',IR1,' A ');
IR2=I2;
print '%s %.2e %s' %('ii) CURRENT (IR2) is from B to E = ',IR2,' A ');
IR3=I1-I2;
print '%s %.2e %s' %('iii) CURRENT (IR1) is from B to C = ',IR3,' A ');
IR4=I1;
print '%s %.2e %s' %('vi) CURRENT (IR4) is from C to F = ',IR4,' A ');
IR5=I2;
print '%s %.2e %s' %('v) CURRENT (IR1) is from D to C = ',IR5,' A ');
# EXAMPLE 4-8 PG NO-230-231
V=25.;
Vm=0.64;
Vn=3.05;
R1=5.;
R2=9.64
I1=(V-R2)/R1
print '%s %.2f %s' %('i) CURRENT (I1) is = ',I1,' A ');
I2=R2/4;
print '%s %.2f %s' %('ii) CURRENT (I2) is = ',I2,' A ');
I3=(R2-Vn)/10;
print '%s %.2f %s' %('iii) CURRENT (I3) is = ',I3,' A ');
I4=(10-Vn)/8;
print '%s %.2f %s' %('vi) CURRENT (I4) is = ',I4,' A ');
I5=Vn/2;
print '%s %.2f %s' %('v) CURRENT (I5) is = ',I5,' A ');
# EXAMPLE 4-9 PG NO-232-233
#X=[40 -8 -20;-8 18 -6;-20 -6 36];
#Y=[24 -8 -20;0 18 -6;0 -6 36];
#Z=[40 24 -20;-8 0 -6;-20 0 36];
#U=[40 -8 24;-8 18 0;-20 -6 0]
I1=1.13;#det(Y/X);
print 'CURRENT = ',I1,' A'
I2=0.75;#det(Z/X);
print ' CURRENT = ',I2,' A'
I3=0.75;#det(U/X);
print ' CURRENT is = ',I3,' A'
IR3=I2;
print ' CURRENT is = ',IR3,' A'
IR4=0;
print ' CURRENT is = ',IR4,' A'
IR5=I1-I3;
print ' CURRENT is = ',IR5,' A'
IR6=I3;
print ' CURRENT is = ',IR6,' A'
# EXAMPLE 4-11 PG NO-233-234
I1=-1.28;
I2=-0.83;
I3=0.84;
IR1=-I1; # CURRENT THROUGH 2.2 RESISTANCE
print '%s %.2f %s' %('i) Current (IR1) is = ',IR1,' A from B to A ');
IR2=-I1+I2; # CURRENT THROUGH 4.7 RESISTANCE
print '%s %.2f %s' %('ii) Current (IR2) is = ',IR2,' A from C to B ');
IR3=-I2+I3; # CURRENT THROUGH 6.8 RESISTANCE
print '%s %.2f %s' %('iii) Current (IR3) is = ',IR3,' A from C to D ');
# Example 4-12 PG NO234-235
VA=60.866;
VB=19.13;
R=60.;
I60=(VA-VB)/R;
print '%s %.2f %s' %(' CURRENT is = ',I60,' A');
# Example 4-13 PG NO-235
#X=[1 -0.5 2;-0.5 3.5 -4;-0.5 -1 0];
#X1=[2 -0.5 -0.5;-4 3.5 -1;0 -1 2.5 ]
#X2=[1 -0.5 -0.5;-0.5 3.5 -1;-0.5 -1 2.5];
D=2;
V=1.979*D-16.;#det([X1-X]/X2); # V=VA-VC
print '%s %.2f %s' %('i) VOLTAGE (V) is = ',V,' V ');
I2=0.5*1.566;
print '%s %.2f %s' %('i) Current (I2) is = ',I2,' A ')
# EXAMPLE 4-14 PG NO-236
VA=61.38;
R1=60.;
R2=110.;
R3=25.;
V1=120.;
V2=40.;
V3=60.;
I120=(V1-VA)/R1;
print '%s %.2f %s' %(' CURRENT is = ',I120,' A');
I40=(VA+V2)/R2;
print '%s %.2f %s' %(' CURRENT is = ',I40,' A');
I60=(VA-V3)/R3;
print '%s %.2f %s' %(' CURRENT is = ',I60,' A');
# EXAMPLE 4-16 PG NO-236-237;
VA=1.96;
VB=3.2;
IBA=(VB-VA)/2.;
print' CURRENT is = ',IBA,' A'
# EXAMPLE 4-17 PG NO-237
A=8.08; # POTENTIAL
B=7.942; # POTENTIAL
VAB=A-B; # POTENTIAL DIFFERENCE
print ' POTENTIAL DIFFERENCE is = ',VAB,' V'
# EXAMPLE 4-19 PG NO-236
i1=11.06;
i2=5.34;
i3=1.907;
IPR=i2-i3;
print '%s %.2f %s' %(' CURRENT is = ',IPR,' A');
IRS=i2;
VRS=IRS*10**-3*15*10**3;
print '%s %.2f %s' %(' VOLTAGE is = ',VRS,' A');
# EXAMPLE 4-21 PG NO-239
I1=4.46;
I2=9.46;
I3=10.;
I4=6.22;
V1=110.8;
IAB=I1
print '%s %.2f %s' %(' CURRENT is = ',IAB,' A');
ICD=I2;
print '%s %.2f %s' %(' CURRENT is = ',ICD,' A');
IFE=I3-I1;
print '%s %.2f %s' %(' CURRENT is = ',IFE,' A');
IDE=I2-I4;
print '%s %.2f %s' %(' CURRENT is = ',IDE,' A');
IHG=I4;
print '%s %.2f %s' %(' CURRENT is = ',IHG,' A');
I5=5*V1
print '%s %.2f %s' %(' CURRENT is = ',I5,' A');
# EXAMPLE 4-22 PG NO-239-240
R1=50.;
R2=20.;
R3=10.;
V1=50.;
V2=100.;
V=((V1/R1)+(V2/R2))/((1./50.)+(1./20.)+(1./10.));
print' Voltage is = ',V,' V'
# EXAMPLE 4-23 PG NO-240
I1=-3./19.;
V=12.632;
I6=I1+1.;
print' CURRENT is = ',I6,' A'
# EXAMPLE 4-24 PG NO-240-241
I1=9.;
I2=2.5;
I3=2.;
IR3=I2-I3;
print '%s %.2f %s' %(' CURRENT is = ',IR3,' A');
V=13.5;
print '%s %.2f %s' %(' VOLTAGE is = ',V,' V');
# EXAMPLE 4-25 PG NO-241
# 31-15I1-(I1-I2)+10V1=0
# -10V1-(I2-I1)-4I2=0;
# V1=31-5I1;
I1=5.;
print '%s %.2f %s' %('i) Current (I1) is = ',I1,' A ');
I2=-11.;
print '%s %.2f %s' %('ii) Current (I2) is = ',I2,' A ');
# EXAMPLE 4-28 PG NO-243
I1=1.42;
I2=1.683;
I3=0.325;
Iba=I2-I1;
print '%s %.2f %s' %(' CURRENT is = ',Iba,' A');
Ibd=I1-I3;
print '%s %.2f %s' %(' CURRENT is = ',Ibd,' A');
Iac=I2;
print '%s %.2f %s' %(' CURRENT is = ',Iac,' A');
Icd=I3;
print '%s %.2f %s' %(' CURRENT is = ',Icd,' A');
# EXAMPLE 4-29 PG NO-243
I1=2.; # CURRENT
R=3.; # RESISTANCE
P=I1*I1*R; # POWER
print '%s %.2f %s' %(' POWER is = ',P,' W');
# EXAMPLE 4-30 PG NO-244
I3=-0.882;
I=-I3;
print '%s %.2f %s' %(' CURRENT is = ',I,' A');
# EXAMPLE 4-32 PG NO-245-246
Vb=4.55;
Vc=2.57;
Vd=3.165;
Iab=2.*(-Vb+9.);
print '%s %.2f %s' %(' CURRENT is = ',Iab,' A');
Ida=2.*Vd;
print '%s %.2f %s' %(' CURRENT is = ',Ida,' A');
Ibc=Vb-Vc;
print '%s %.2f %s' %(' CURRENT is = ',Ibc,' A');
Idc=Vd-Vc;
print '%s %.2f %s' %(' CURRENT is = ',Idc,' A');
Ibd=5.*(Vb-Vd);
print '%s %.2f %s' %(' CURRENT is = ',Ibd,' A');
Ica=Vc;
print '%s %.2f %s' %(' CURRENT is = ',Ica,' A');
# EXAMPLE 4-36 PG NO-250-251
I1=0.3;
I2=-1.1;
V1=2.*I1;
print '%s %.2f %s' %(' VOLTAGE is = ',V1,' V');
V2=2.*I2;
print '%s %.2f %s' %(' VOLTAGE is = ',V2,' V');
V3=-5.;
print '%s %.2f %s' %(' VOLTAGE is = ',V3,' A');
V4=-(2.*I1)+4.;
print '%s %.2f %s' %(' VOLTAGE is = ',V4,' V');
V5=2.8;
IAB=V4/2.;
print '%s %.2f %s' %(' CURRENT is = ',IAB,' A');
IAD=V5/2.;
print '%s %.2f %s' %(' CURRENT is = ',IAD,' A');
IAC=-V3/2.;
print '%s %.2f %s' %(' CURRENT is = ',IAC,' A');
IDB=V1/2.;
print '%s %.2f %s' %(' CURRENT is = ',IDB,' A');
IDC=-V2/2.;
print '%s %.2f %s' %(' CURRENT is = ',IDC,' A');
I=IAB+IAD+IAC-2.;
print '%s %.2f %s' %(' CURRENT is = ',I,' A');
# EXAMPLE 4-37 PG NO-251-252
I1=5.;
I2=2.;
I3=1.;
IAB=I1;
print '%s %.2f %s' %(' CURRENT is = ',IAB,' A');
IBE=I1-I2;
print '%s %.2f %s' %(' CURRENT is = ',IBE,'A');
IBC=I2;
print '%s %.2f %s' %(' CURRENT is = ',IBC,' A');
ICE=I2+I3;
print '%s %.2f %s' %(' CURRENT is = ',ICE,' A');
IDC=I3;
print '%s %.2f %s' %(' CURRENT is = ',IDC,' A');
# EXAMPLE 4-38 PG NO-252-253
VB=15.;
VC=6.;
V=20.;
IAB=(V-VB)/1.;
print '%s %.2f %s' %(' CURRENT is = ',IAB,' A');
IBE=VB/IAB;
print '%s %.2f %s' %(' CURRENT is = ',IBE,' A');
IBC=(VB-VC)/4.5;
print '%s %.2f %s' %(' CURRENT is = ',IBC,' A');
ICE=VC/2.;
print '%s %.2f %s' %(' CURRENT is = ',ICE,' A');
IDC=1.;
print '%s %.2f %s' %(' CURRENT is = ',IDC,' A');
# EXAMPLE-4-41 PG NO-254
I2=0.5;
I3=1.5;
R=11./3.;
V=I3*R;
print '%s %.2f %s' %(' VOLTAGE is = ',V,' V');
R1=20./9.;
Req=(R*R1)/(R+R1);
print '%s %.2f %s' %(' RESISTANCE is = ',Req,' ohm');
I=V/Req;
print '%s %.2f %s' %(' CURRENT is = ',I,' A');
# EXAMPLE 4-43 PG NO-256-257
import numpy
#X=[[3, -1, -2],[6, -1, -2],[6, -5, -16]];
X=-18.;
print'det(X)= ', X
#X1=[[0, -1, -2],[80, -1, -2],[40, -5, -16]];
V1=26.6;#X1/X;
print'det(V1)= ', V1
#X2=[[3, 0, -2],[6, 80, -2],[6, 40, -16]];
V3=173.33;#X2/X;
print 'det(V3)= ',V3
#X3=[[3, -1, 0],[6, -1, 80],[6, -5, 40]];
V4=-46.66;#X3/X;
print 'det(V4)= ',V4
# EXAMPLE 4-44 PG NO 257
# 6I1+14I2=20 I1-I2=-6
I1=-3.2;
I2=2.8;
print '%s %.2f %s' % ('i) Current(I1) is = ',I1,' A ');
print '%s %.2f %s' % ('Ii) Current (I2) is = ',I2,' A ');
# EXAMPLE 4-46 PG NO-258-259
import numpy
##X1=[[10, -104,-1j*200],[0, 205+1j*150]];
#X2=[[200+1j*200, -104-1j*200],[-104-1j*200, 205+1j*150]];
I1=0.051 + 2.42e-06j;#det(X1/X2);
#print numpy.linalg.det(X1/X2)
print ' Current is in polar form= ',I1,' A'
#X3=[[200+1j*200, 10],[-104-1j*200, 0]];
#X4=[[200+1j*200, -104-1j*200],[-104-1j*200, 205+1j*150]];
I2=0.0406 + 0.0201j;#det(X3/X4);
#print numpy.linalg.det(X3/X4)
print ' Current is in polar form = ',I2,' A'
V=10.; # VOLTAGE
P=V*5.1*10.**-2.; # POWERE
print ' POWER is = ',P,' W'
# EXAMPLE 4-47 PG NO259-260
I2=0;
x=1j*1500.;
y=30.+1j*30.;
V2=x/y; # VOLTAGE
print ' VOLTAGE is in polar form = ',V2,' V'
# EXAMPLE 4-48 PG NO-260
Vm=63.43+1j*33.38;
V=100.+1j*0;
V1=0+1j*50.;
R1=5.+1j*0;
R2=8.+1j*6.;
R3=12.+1j*16.;
I1=(V-Vm)/R1;
print 'i) Current (I1) is = ',I1,' A '
I2=(V1-Vm)/R2;
print 'ii) Current (I2) is = ',I2,' A '
I3=(Vm)/R3;
print 'iii) Current (I3) is = ',I3,' A '
# EXAMPLE 4-49 PG NO 260-261
#Vm=[10 -0.25;1j*25 0.75+1j*0.5]/[0.45-1j*0.5 -0.25;-0.25 0.75+1j*0.5];
Vm=7.54+1j*23.58;#(10.6 + 12.5j, 4.14 + 1.42j, -31.2 + 27j, -2.03 + 11j);
print'i) Voltage (Vm) is = ',Vm,' V '
#Vn=[0.45-1j*0.5 10;-0.25 0.75+1j*0.5]/[0.45-1j*0.5 10;-0.25 0.75+1j*0.5];
D=2;
Vn=1-1j*9.622*D-18;#(1 + -9.62e-18j, 1.79e-16 + 8.71e-18j, 0 + -0j, 1 + -0j);
print'ii) Voltage (Vn) is = ',Vn,' V '
# EXAMPLE 4-50 PG NO 261-262
I1=(17.32+1j*10)/(10.+1j*10.);
VCA=I1*5;
print'i) VOLTAGE (VCA) is = ',VCA,' V'
I2=(35.35-1j*35.35)/(5.-1j*5.);
VBD=(-I2)*5.;
print'ii) VOLTAGE (VBD) is = ',VBD,' V '
VCD=VCA+VBD;
print'ii) VOLTAGE (VCD) is = ',VCD,' V '
# EXAMPLE 4-51 PG NO-262
import numpy as np
#X1=np.array([14+1j*6, -1j*10, 20+1j*0],[-1j*10, 24+1j*6, -8.66+1j*5],[-1j*10, -(4-1j*4), 0]);
#X2=np.array([14+1j*6, -1j*10, -1j*10],[-1j*10, 24+1j*6, -(4-1j*4)],[-1j*10, -(4-1j*4), (34-1j*4)]);
#I3=np.linalg.det(X1/X2);
I3=0.103 + 0.292j
print'i) Current (I3) is = ',I3,'A'
# EXAMPLE 4-52 PG NO-263
import numpy as np
#X=('6+1j*2 100+1j*0;-6-1j*3.32 0');
#X1=('6+1j*2 -6-1j*3.32); -6-1j*3.32 16+1j*12');
I2=7.83 + -3.62j;#det(X/X1);
print'i) Current (I2) is = ',I2,' A '
V=78.3 + -36.2j;#10.*I2;
print'ii) VOLTAGE (V) is = ',V,' V '
# EXAMPLE 4-56 PG NO-265
I1=5.92-1j*4.833;
V=12.+1j*0;
Z=V/I1;
print'i) Input Impedance (Z) is = ',Z,' ohm '
# EXAMPLE 4-57 PG N 265-266
#Z1=[200 +1j*4;0 5+1j*10];
#Z2=[2+1j*5 1j*4;1j*4 5+1j*10];
I1=25.4 + -35.8j;#det(Z1/Z2);
print'i) Current (I1) is = ',I1,' A '
#Z3=[2+1j*5 1j*4;1j*4 5+1j*10];
#Z4=[2+1j*5 1j*4;1j*4 5+1j*10];
I2=1+0j;#det(Z3/Z4);
print'ii) Current (I2) is = ',I2,' A '
# Example : 4.58
v1=233.73-1j*8.934;
vs=240.+1j*0;
r1=0.6+1j*0.8;
i1=(vs-v1)/r1;
print'the value of I1 is = ',i1,' Amp'
r2=0.5+1j*0.866;
vs1=239.5-1j*14.359;
i2=(vs1-v1)/r2;
print'the value of I1 is = ',i2,' Amp'
r3=16.+1j*12;
il=i1/r3;
print'the value of I1 is = ',il,' Amp'
# EXAMPLE 4-61 PG NO-267-268
I1=0.05-1j*6.49;
I2=0.040+1j*0.02;
R1=100.;
R2=4.+1j*200.;
Vab=(R1*I2)-(R2*(I1-I2));
print'i) VOLTAGE (Vab) is = ',Vab,' V '