#Variable declaration
#From the figure 8.2
I1=1 #A
#Calculations
V1=6*I1 #V
Z11=V1/I1 #ohms
V2=6*I1 #V
Z21=V2/I1 #ohms
I2=1 #A
V1=6*I2 #V
Z12=V1/I2 #ohms
V2=6*I2 #V
Z22=V2/I2 #V
A=[[Z11,Z12],[Z21,Z22]]
#Result
print "A=",A
#Variable declaration
#From figure 8.3
I1=1 #A
V2=0 #V
#Calculations
V1=12*I1 #V
Z21=V2/I1 #ohms
Z11=V1/I1 #ohms
I2=1 #A
V2=3*I2 #V
V1=0 #V
Z12=V1/I2 #ohms
V2=3*I2 #V
Z22=V2/I2 #ohms
A=[[Z11,Z12],[Z21,Z22]]
#Result
print "A=",A
#Variable declaration
#From figure 8.4
I1=1 #A
I2=1 #A
#Calculations
V1=18*I1 #V
V2=6*I1 #V
Z11=V1/I1 #ohms
Z21=V2/I1 #ohms
V2=9*I2 #V
V1=6*I2 #V
Z12=V1/I2 #ohms
Z22=V2/I2 #ohms
A=[[Z11,Z12],[Z21,Z22]]
#Result
print "A=",A
#Variable declaration
#From figure 8.7
V2=1 #V
V1=1 #V
V2=0 #V
#Calculations
I1=0.05*V1 #A
I2=-0.05*V1 #A
Y11=I1/V1 #mho
Y21=I2/V1 #mho
I2=0.05*V2 #A
I1=-0.05*V2 #A
Y12=-0.05 #mho
Y22=0.05 #mho
A=[[Y11,Y12],[Y21,Y22]]
#Result
print "A=",A
#Variable declaration
#From figure 8.8
V1=1 #V
V2=1 #V
#Calculations
I1=0.0225/0.325*V1 #A
VN=I1/(0.2+0.025) #V
I2=-0.2*VN #A
Y11=I1/V1 #mho
Y21=I2/V1 #mho
I2=0.025/0.325*V2 #A
VM=I2/(0.1+0.025) #V
I1=-0.1*VM #A
Y12=I1/V2 #mho
Y22=I2/V2 #mho
A=[[Y11,Y12],[Y21,Y22]]
#Result
print "A=",A
#Variable declaration
#From figure 8.9
V1=1 #V
V2=1 #V
#Calculations
I1=0.1192*V1 #A
IN=0.05*I1/(0.05+(0.1*(0.2+0.025)/(0.1+0.2+0.025))) #A
IM=0.2*0.0692*V1/(0.2+0.025) #A
I2=-(IN+IM) #A
Y11=I1/V1 #mho
Y21=I2/V1 #mho
I2=(0.05+0.2*(0.1+0.025)/(0.2+0.1+0.025))*V2 #A
IN=0.05*I2/(0.05+(0.2*(0.1+0.025)/(0.2+.1+0.025))) #A
IM=0.1*0.0769*V2/(0.1+0.025) #A
I1=-(IN+IM) #A
Y12=I1/V2 #mho
Y22=I2/V2 #mho
A=[[Y11,Y12],[Y21,Y22]]
#Result
print "A=",A
#Variable declaration
#From figure 8.12
I1=1 #A
#Calculations
V1=14*I1 #V
I2=-2./3*I1 #A
h11=V1/I1
h21=I2/I1
V2=9*I2 #V
V1=6*I2 #V
h12=V1/V2
h22=I2/V2
A=[[h11,h12],[h21,h22]]
#Result
print "A=",A
#Variable declaration
#From figure 8.13
I1=1 #A
#Calculations
I2=-I1 #A
V1=I1 #V
B=-V1/I2
D=-I1/I2
V2=V1 #V
I1=0 #A
A=V1/V2
C=I1/V2
M=[[A,B],[C,D]]
#Result
print "A=",M
import math
import cmath
#Calculations&Results
V1in=0.5*((10*cmath.exp(complex(0,math.pi/180*0)))+(50*(.1*cmath.exp(complex(0,math.pi/180*40)))))
print "V1in=",V1in
V1ref=0.5*((10*cmath.exp(complex(0,math.pi/180*0)))-(50*(.1*cmath.exp(complex(0,math.pi/180*40)))))
print "V1ref=",V1ref
V2in=0.5*((12*cmath.exp(complex(0,math.pi/180*30)))+(50*(.15*cmath.exp(complex(0,math.pi/180*100)))))
print "V2in=",V2in
V2ref=0.5*((12*cmath.exp(complex(0,math.pi/180*30)))-(50*(.15*cmath.exp(complex(0,math.pi/180*100)))))
print "V2ref=",V2ref
from fractions import Fraction
#Variable declaration
n=10.
#Calculations
S11=(n**2-1)/(n**2+1)
S11 = str(Fraction(S11).limit_denominator())
S21=2*n/(n**2+1)
S21 = str(Fraction(S21).limit_denominator())
S22=(1-n**2)/(1+n**2)
S22 = str(Fraction(S22).limit_denominator())
S12=2*n/(n**2+1)
S12 = str(Fraction(S12).limit_denominator())
A=[[S11,S12],[S21,S22]]
#Result
print "The S-parameters are:\n",A
#Variable declaration
Zo1=50 #ohms
Zo2=50 #ohms
Vs1=1 #V
Vs2=1 #V
#Calculations
Z1=complex(0,50)+(50*complex(0,-25)/complex(50,-25))
S11=(Z1-Zo1)/(Z1+Zo1)
Z2=(complex(50,50)*complex(0,-25))/complex(50,(50-25))
S22=(Z2-Zo2)/(Z2+Zo2)
V2=complex(10,-20)/complex(50,50)+complex(10,-20)*Vs1
S21=2*V2/Vs1
V2=complex(10,-30)/complex((50+10),-30)*Vs2
V1=50/complex(50,50)*V2
S12=2*V1/Vs2
A=[[S11,S12],[S21,S22]]
#Result
print "The Scattering parameters are:\n",A