##Ex3_1
import math
E = 20*.10**3
e = -(1.6*10**-19)
F = e*E
print'%s %.2f %s'%("E = ",(E),"ax V/m")##initializing electic field
print'%s %.2e %s'%("e = ",(e),"C")##intializing electron charge
print'%s %.2e %s'%("F = eE = ",(F),"ax N")##calculation for force on electron due to electric field
## NOTE : answer provided in the textbook is wrong Correct answer is, -3.2*10^16ax N
##Ex3_2
import math
E = 50.*10**3
e = -1.6*10**-19
N = 10**6
F = N*e*E
print'%s %.2f %s'%("E = ",(E),"az V/m")##value of Electric field applied
print'%s %.2e %s'%("e = ",(e),"C")##value of eletron charge
print("N = (N)")##total number of charge
print'%s %.2e %s'%("F = NeE = ",(F),"az N")##force on electron
##Ex3_3
import math
v = 5.*10**6
e = -1.6*10**-19
B = 20.*10**-6
F = e*v*B
print'%s %.2f %s'%("v = ",(v),"m/s")##velocity of electron
print'%s %.2e %s'%("e = ",(e),"C")##charge of electron
print'%s %.2e %s'%("B = ",(B),"Wb/m-sq")##magnetic field
print'%s %.2e %s'%("F = e(VxB) = e*v*B = ",(F),"N")##force on the electron due to field
##Ex3_4
import math
Bx = 40.*10**-6
By = 10.*10**-6
N = 10**6
e = -1.6*10**-19
v = 8.*10**6
print'%s %.2e %s%.2e %s'%("B = ",(Bx),"ax + ",(By),"ay Wb/m-sq")##magnetic field
print'%s %.2f %s'%("N = ",(N),"")##number of electrons
print'%s %.2e %s'%("e = ",(e),"C")##electron charge
print'%s %.2e %s'%("v = ",(v),"ax m/s")##velocity of electron
print'%s %.2e %s'%("F = Q(VxB) = ",(e*N*v*By)," az N")##force on electron
##as we are taking curl of V and B,.. thus Vx X Bx = 0
##force will be only due to V x By.
##Ex3_5
import math
e = -1.6*10**-19
n = 10**6
v = 5.*10**6
J = n*e*v
print'%s %.2e %s'%("e = ",(e),"C")##charge of electrons
print'%s %.2f %s'%("n = ",(n)," /m-cube")##electron density
print'%s %.2f %s'%("v = ",(v),"m/s")##electron velocity
print'%s %.2e %s'%("J = nev = ",(abs(J)),"A/m-sq")##current density
##Ex3_6
import math
v = 2*10**7
e = -1.6*10**-19
n = 10**8
J = n*e*v
print'%s %.2f %s'%("v = ",(v),"m/s")##velocity of electron
print'%s %.2e %s'%("e = ",(e),"C")##electron charge
print'%s %.2f %s'%("n = ",(n)," /m-cube")##electron density
print'%s %.2e %s'%("J = nev = ",(abs(J)),"A/m-sq")##current density
##note: formula for current density in the solution in the textbook is misprinted
## also the answer is provide in the textbook for above problem is misprinted.
##Ex3_7
import math
l = 4.##cycle length
t = 10. *10**-6##scale setting
T = l*t##time period for full cycle
print'%s %.2e %s'%("T = ",(T)," s")
print'%s %.2f %s'%("Frequency = 1/T = ",(1./T),"Hz")##frequency of the signal
##Ex3_8
import math
Vpp = 4.2*10.*10**-3##peak to peak voltage of sinusoidal signal ##notation not used in textbook
Vm = Vpp/2.##maximum positive voltage
Vrms = Vm/(2**.5)##root mean square value of voltage
print'%s %.2f %s'% ("Vm = ",(Vm),"V")
print'%s %.2e %s'%("Vrms = Vm/(2^.5) = ",(Vrms),"V")
##Ex3_9
import math
V = 4.5*10**-3##applied dc voltage
r = 100. ## given resistance
I = V/r##flow of current
print'%s %.2e %s'%("DC voltage = ",(V),"V")
print'%s %.2e %s'%("The current in 100 ohm = ",(I),"A")
##Ex3_10
import math
l = .03
d = 0.01
L = 0.18
Va = 1000.
print'%s %.2f %s'%("l = ",(l),"m")##lenght of deflection plate
print'%s %.2f %s'%("d = ",(d),"m")##plate separation
print'%s %.2f %s'%("L = ",(L),"m")##distance of screen from plate
print'%s %.2f %s'%("Va = ",(Va),"V")##anode voltage
SE = (l*L)/(2.*d*Va)
print'%s %.2e %s'%("SE = (l*L)/(2*d*Va) = ",(SE),"m/V")
##Ex3_11
import math
print("fm = BIL")##formula used for finding FORCE ON CURRENT ELEMENT
B = 2.0
IL = 10.*10**-3
fm = B*IL
print'%s %.2f %s'%("B = ",(B),"Wb/m-sq")##magnetic field
print'%s %.2f %s'%("IL = ",(IL),"A-m")##current element
print'%s %.2f %s'%("fm =",(fm),"Newton")##answer print'%s %.2f %s'%layed
##Ex3_12
import math
print("v = (2*e*Va/m)^.5")##formula used to calculate velocity of electrons
e = -1.6*10**-19
m = 9.1*10**-31
Va = 3.0*10**3
print'%s %.2e %s'%("e = ",(e),"C")##electron charge
print'%s %.2e %s'%("m = ",(m),"Kg")##mass of electron
print'%s %.2f %s'%("Va = ",(Va),"V")##potential difference = anode voltage
v = abs((2*e*Va/m))**.5
print'%s %.2f %s'%("v = ",(v),"m/s")
W = e*Va##kinetic energy
print'%s %.2e %s'%("W = e*Va = ",(W),"joules")##Kinetic energy
##Ex3_13
import math
e = -1.6*10**-19
m = 9.1*10**-31
Va = 400.
v = (abs(2.*e*Va/m))**.5
print'%s %.2e %s'%("e = ",(e),"C")##electron charge
print'%s %.2e %s'%("m = ",(m),"Kg")##mass of electron
print'%s %.2f %s'%("Va = ",(Va),"V")##anode voltage
print'%s %.2f %s'%("v = (2*e*Va/m)^.5 = ",(v),"m/s")##formula used to calculate velocity of electrons
##as electron traces a circular path, radius of circular path
H = 47.75
micro_not = 4.*math.pi*10**-7
B = H*micro_not
print'%s %.2e %s'%("B = ",(B),"Wb/m-sq")
r = (v/(e/m)/B)
print'%s %.2f %s'%("r = (v/(e/m))/B = ",(r),"m")
## NOTE : Question is incompletely solved in the textbook
##Ex3_14
import math
l = 22.
d = 1.5
Va = 625.
e = 1.6*10**-19
m = 9.1*10**-31
print'%s %.2f %s'%("l = ",(l),"cm")##distance from location of magnetic field
print'%s %.2f %s'%("d = ",(d),"cm")##length over which magnetic field is present
print'%s %.2f %s'%("Va = ",(Va),"V")##voltage applied to anode
print'%s %.2e %s'%("e = ",(e),"C")##electron charge
print'%s %.2e %s'%("m = ",(m),"Kg")##mass of electron
SH = l*10**-2*d*10**-2*(e/(2.*m*Va))**.5
print'%s %.2f %s'%("SH = D/B = l*d*(e/(2*m*Va))^.5 = ",(SH),"m/tesla")##magnetic deflection sensitivity in terms of meter and tesla
## as B = micro_not*H
micro_not = 4.*math.pi*10**-7
print'%s %.2e %s'%("SH = D/H = micro_not*l*d*(e/(2*m*Va))^.5 = ",(SH*micro_not),"m-sq/Amp.")##magnetic deflection sensitivity in terms of meter and amperes
##Ex3_15
import math
Vd = 50.
d = 1.
print("(a)")
print'%s %.2f %s'%("Vd = ",(Vd),"V")##voltage applied to deflection plates
print'%s %.2f %s'%("d = ",(d),"cm")##plate separation
E = Vd/d/10**-2
print'%s %.2f %s'%("E = Vd/d = ",(E),"V/m")##electric field produced
print("(b)")
e = -1.6*10**-19
m = 9.1*10**-31
Va = 500.
v = abs((2.*e*Va/m))**.5
print("v = (2*e*Va/m)^.5")## formula for Velocity OF Electron
print'%s %.2e %s'%("e = ",(e),"C")##electron charge
print'%s %.2e %s'%("m = ",(m),"Kg")##mass of electron
print'%s %.2f %s'%("Va = ",(Va),"V")##voltage applied at anode
print'%s %.2f %s'%("v = ",(v),"m/s")
print("(c)")
l = 2.
L = 30.
Va = 500.
SE = l*L/2./Va/d*10.
print'%s %.2f %s'%("l = ",(l),"cm")##length of deflection plate
print'%s %.2f %s'%("L = ",(L),"cm")##distance between plates and screen
print'%s %.2f %s'%("d = ",(d),"cm")##plate separation
print'%s %.2f %s'%("Va = ",(Va),"V")##anode voltage
print'%s %.2f %s'%("SE = (l*L)/(2*Va*d) = ",(SE),"mm/volts")##Electrostatic deflection sensitivity
##Ex3_16
import math
##considering Lissajous pattern given in question
y1 = 0.
y2 = 5.
phi = math.asin(y1/y2)*57.3
print'%s %.2f %s'%("y1 = ",(y1),"cm")##minor axis
print'%s %.2f %s'%("y2 = ",(y2),"cm")##major axis
print'%s %.2f %s'%("phi = sin-1(y1/y2) = ",(phi),"degree")##phase difference
##Ex3_17
import math
##considering Lissajous pattern given in question
y1 = 4.
y2 = 5.
phi = math.asin(y1/y2)*57.3
print'%s %.2f %s'%("y1 = ",(y1),"unit")##minor axis
print'%s %.2f %s'%("y2 = ",(y2),"unit")##major axis
print'%s %.2f %s'%("phi = sin-1(y1/y2) = ",(phi),"degree")##phase difference
##Ex3_16
import math
##considering Lissajous pattern given in question
y1 = 4.
y2 = 4.
phi = math.asin(y1/y2)*57.3
print'%s %.2f %s'%("y1 = ",(y1),"cm")##minor axis
print'%s %.2f %s'%("y2 = ",(y2),"cm")##major axis
print'%s %.2f %s'%("phi = sin-1(y1/y2) = ",(phi),"degree")##phase difference
##Ex3_16
import math
##considering Lissajous pattern given in question
y1 = 2.
y2 = 6.
phi = math.asin(y1/y2)*57.3
print'%s %.2f %s'%("y1 = ",(y1),"cm")##minor axis
print'%s %.2f %s'%("y2 = ",(y2),"cm")##major axis
print'%s %.2f %s'%("phi = sin-1(y1/y2) = ",(phi),"degree")##phase difference
print("OR")
phi = 180. - phi
print'%s %.2f %s'%("phi = ",(phi),"degree")