# Commits

committed f985484

Added laboratory reports from the first four semesters.

• Participants
• Parent commits fa35eed
• Branches default

# File Electricity&Magnetism/140/data/part1.py

+from numpy import *
+from tools import *
+
+nuapprox, U, I, x, m = tuple(map(array, transpose([
+    [20.0, 0.0245, 98.36, 2 * 4.9, 5.0],
+    [30.0, 0.0363, 98.62, 2 * 3.3, 5.0],
+    [40.0, 0.0478, 98.73, 2 * 6.3, 2.0],
+    [50.0, 0.0593, 98.85, 2 * 5.0, 2.0],
+    [60.0, 0.0704, 99.18, 2 * 4.2, 2.0],
+    [70.0, 0.0813, 99.34, 2 * 3.6, 2.0],
+    [80.0, 0.0922, 99.59, 2 * 3.2, 2.0],
+    [90.0, 0.1025, 99.75, 2 * 5.6, 1.0],
+    [100.0, 0.1122, 99.87, 2 * 5.0, 1.0]
+])))
+
+dU = ones(len(U)) * 0.0001
+dI = ones(len(I)) * 0.20
+I, dI = I / 1000, dI / 1000
+
+T = x * m / 1000.
+dT = 2 * 0.2 * m / 1000.
+
+nu = 1 / T
+dnu = nu * (dT/T)
+
+zeta = U / I / nu
+dzeta = zeta * sqrt((dU / U)**2 + (dI / I)**2 + (dnu / nu)**2)
+
+nu2 = nu ** 2
+dnu2 = 2 * nu * dnu
+
+writeCSV('part1_graph.csv', ["nu2", "dnu2", "zeta", "dzeta"],
+    [transpose([nu2, dnu2, zeta, dzeta])])
+
+_, zeta0, _, dzeta0 = interpolateLinearly(nu2, zeta, dnu2, dzeta)
+print "z0 = ", zeta0, "+-", dzeta0
+
+U, dU = roundErr(U, dU)
+I, dI = roundErr(I, dI)
+T, dT = roundErr(T, dT)
+nu, dnu = roundErr(nu, dnu)
+nu2, dnu2 = roundErr(nu2, dnu2)
+zeta, dzeta = roundErr(zeta, dzeta)
+
+writeCSV('part1_data.csv', ["U", "dU", "I", "dI", "T", "dT", "nu", "dnu", "nu2", "dnu2", "zeta", "dzeta"],
+    [transpose([U, dU, I, dI, T, dT, nu, dnu, nu2, dnu2, zeta, dzeta])])
+
+######################################### part 2
+
+nu, U, I, x0, x, m = tuple(map(array, transpose([
+    [100., 0.1120, 99.58, 5.1, 3.2, 1],
+    [500., 0.2620, 97.47, 5.1, 4.5, 0.2],
+    [1000., 0.2837, 97.50, 5.2, 4.9, 0.1],
+    [2000., 0.2852, 95.93, 5.2, 5.3, 0.05],
+    [3000., 0.2818, 94.44, 3.5, 3.6, 0.05],
+    [4000., 0.2760, 92.51, 6.4, 6.8, 0.02],
+    [5000., 0.2696, 90.30, 5.0, 5.6, 0.02],
+    [6000., 0.2626, 88.00, 4.2, 4.8, 0.02],
+    [7000., 0.2548, 85.38, 7.2, 8.4, 0.01],
+    [8000., 0.2460, 82.42, 6.3, 7.5, 0.01],
+    [9000., 0.2365, 79.15, 5.6, 6.8, 0.01],
+    [10000., 0.2281, 76.16, 5.0, 6.3, 0.01],
+    [12000., 0.2110, 69.89, 4.3, 5.5, 0.01],
+    [14000., 0.1957, 63.77, 7.3, 9.7, 0.005],
+    [16000., 0.1799, 56.90, 6.3, 8.5, 0.005],
+    [18000., 0.1665, 50.54, 5.6, 8.0, 0.005],
+    [20000., 0.1549, 44.29, 5.1, 7.5, 0.005],
+    [22000., 0.1563, 43.22, 4.6, 6.9, 0.005],
+    [24000., 0.1400, 34.63, 4.3, 6.5, 0.005],
+    [26000., 0.1259, 26.51, 3.8, 6.1, 0.005],
+    [28000., 0.1128, 18.59, 3.6, 6.0, 0.005],
+    [30000., 0.1005, 10.75, 3.4, 6.0, 0.005]
+])))
+
+dU = ones(len(U)) * 0.0001
+dI = ones(len(I)) * 0.02
+I, dI = I / 1000, dI / 1000
+
+T = 2 * x0 * m / 1000.
+dT = 2 * 0.2 * m / 1000.
+
+phi = pi * x / x0
+dphi = phi * sqrt((0.2 / x)**2 + (0.2 / x0)**2)
+
+nu = 1 / T
+dnu = nu * (dT/T)
+
+phi -= pi/4 + pi/2
+
+nu12 = sqrt(nu)
+dnu12 = nu12 * sqrt(1./4. * (dnu/nu)**2)
+
+writeCSV('part2_graph.csv', ["nu12", "dnu12", "phi", "dphi"],
+    [transpose([nu12, dnu12, phi, dphi])])
+
+k, _, dk, _ = interpolateLinearly(*map(lambda a: a[1:-3], (nu12, phi, dnu12, dphi)))
+print "k = ", k, "+-", dk
+
+h, dh = 1.3 / 1000., 0.1 / 1000.
+a, da = 21 / 1000., 1 / 1000.
+
+mu =  1
+mu0 = 4 * pi * 10**(-7)
+
+# k = h * sqrt(mu mu0 sigma pi) => (k / h)**2 / (mu mu0 pi) = sigma
+
+sigma = (k / h)**2 / (mu * mu0 * pi)
+dsigma = sigma * sqrt(4 * (dk/k)**2 + 4 * (dh/h)**2)
+print "sigma = ", sigma, "+-", dsigma
+
+###########################################################################
+
+zeta = U / I / nu
+dzeta = zeta * sqrt((dU / U)**2 + (dI / I)**2 + (dnu / nu)**2)
+
+k = zeta / zeta0
+dk = k * sqrt((dzeta / zeta)**2 + (dzeta0 / zeta0)**2)
+
+kth = 2 * sqrt(2.) / a * sqrt(2.0/(mu0 * mu * sigma * 2 * pi * nu)) * exp(-h * sqrt(mu0 * mu * sigma * pi * nu))
+
+writeCSV("part3_graph.csv", ["nu12", "dnu12", "k", "dk", "kth"],
+    [transpose([nu12, dnu12, k, dk, kth])])
+
+############################################################################
+
+delta1 = sqrt(2 / (mu0 * mu * sigma * pi * 50))
+ddelta1 = delta1 * sqrt(1./4. * (dsigma/sigma)**2)
+
+delta2 = sqrt(2 / (mu0 * mu * sigma * pi * 10**5))
+ddelta2 = delta2 * sqrt(1./4. * (dsigma/sigma)**2)
+
+print "delta1 = ", delta1, "+-", ddelta1
+print "delta2 = ", delta2, "+-", ddelta2
+
+U, dU = roundErr(U, dU)
+I, dI = roundErr(I, dI)
+T, dT = roundErr(T, dT)
+nu12, dnu12 = roundErr(nu12, dnu12)
+phi, dphi = roundErr(phi, dphi)
+k, dk = roundErr(k, dk)
+kth,_ = roundErr(kth, kth / 100)
+
+writeCSV('part2_data.csv', ["U", "dU", "I", "dI", "T", "dT", "nu12", "dnu12", "phi", "dphi"],
+    [transpose([U, dU, I, dI, T, dT, nu12, dnu12, phi, dphi])])
+
+writeCSV("part3_data.csv", ["nu12", "dnu12", "k", "dk", "kth"],
+    [transpose([nu12, dnu12, k, dk, kth])])

# File Electricity&Magnetism/140/data/part1_data.csv

+U     dU     I     dI     T     dT     nu     dnu     nu2     dnu2     zeta     dzeta
+0.0245     0.0001     0.0984     0.0002     0.049     0.002     20.4     0.8     420.0     30.0     0.0122     0.0005
+0.0363     0.0001     0.0986     0.0002     0.033     0.002     30.0     2.0     900.0     100.0     0.0121     0.0007
+0.0478     0.0001     0.0987     0.0002     0.0252     0.0008     40.0     1.0     1570.0     100.0     0.0122     0.0004
+0.0593     0.0001     0.0988     0.0002     0.02     0.0008     50.0     2.0     2500.0     200.0     0.012     0.0005
+0.0704     0.0001     0.0992     0.0002     0.0168     0.0008     60.0     3.0     3500.0     300.0     0.0119     0.0006
+0.0813     0.0001     0.0993     0.0002     0.0144     0.0008     69.0     4.0     4800.0     500.0     0.0118     0.0007
+0.0922     0.0001     0.0996     0.0002     0.0128     0.0008     78.0     5.0     6100.0     800.0     0.0119     0.0007
+0.1025     0.0001     0.0998     0.0002     0.0112     0.0004     89.0     3.0     8000.0     600.0     0.0115     0.0004
+0.1122     0.0001     0.0999     0.0002     0.01     0.0004     100.0     4.0     10000.0     800.0     0.0112     0.0005
+

# File Electricity&Magnetism/140/data/part1_graph.csv

+nu2     dnu2     zeta     dzeta
+416.493127863     33.9994390093     0.0122051647011     0.000501269358891
+918.273645546     111.30589643     0.012146623403     0.000737330691501
+1574.70395566     99.9812035337     0.0122005469462     0.000388945088764
+2500.0     200.0     0.0119979767324     0.000480958371966
+3543.08390023     337.436561926     0.011924984876     0.000568617717622
+4822.5308642     535.836762689     0.0117849808738     0.000655311277865
+6103.515625     762.939453125     0.0118501857616     0.000741130300361
+7971.93877551     569.424198251     0.0115087719298     0.000411827874607
+10000.0     800.0     0.0112346049865     0.000450058440475
+

# File Electricity&Magnetism/140/data/part2.py

+from numpy import *
+from tools import *
+import json
+
+R, n, Uk, U0 = tuple(transpose([
+    [1000.0, 3, 4.2/10, 2.4],
+    [1250.0, 4, 2.4/10, 4.1],
+    [1500.0, 4, 1.2/10, 3.8],
+    [1750.0, 3, 1.8/10, 3.6],
+    [2000.0, 2, 3.6/10, 3.6],
+    [2250.0, 2, 2.4/10, 3.4],
+    [2500.0, 2, 1.6/10, 3.1],
+    [3000.0, 2, 0.8/10, 2.8]
+]))
+
+R, n, Uk, U0 = array(R), array(n), array(Uk), array(U0)
+
+RL =  12.8  # ohm
+L = 152.65 # mH
+
+R += RL
+dR = ones(len(R)) * (0.1)
+
+dUk = ones(len(R)) * 0.1 / 10
+dU0 = ones(len(R)) * 0.1
+
+theta = 1.0/n * log(U0/Uk)
+dtheta = 1.0/n * sqrt((dU0 / U0)**2 + (dUk / Uk)**2)
+
+rtheta = 1.0 / theta**2
+drtheta = abs(rtheta) * sqrt(4 * (dtheta / theta)**2)
+rR = 1.0 / R**2
+drR = rR * sqrt(4 * (dR / R)**2)
+
+writeCSV('part2_graph1.csv', ["R", "dR", "theta", "dtheta"],
+    [transpose([R, dR, theta, dtheta])])
+
+writeCSV('part2_graph2.csv', ["rR", "drR", "rtheta", "drtheta"],
+    [transpose([rR, drR, rtheta, drtheta])])
+
+k, _, dk, _ = interpolateLinearly(R, theta, dR, dtheta)
+# k = 2 pi / R_cr
+Rcr = 2 * pi / k
+dRcr = Rcr * sqrt((dk/k)**2)
+
+print "Rcr = ", Rcr, "+-", dRcr
+
+C = 0.005 * 10**(-6)
+Rcrth = 2 * sqrt((L / 1000) / C)
+dRcrth = Rcrth * sqrt(0.5**2 * (0.001 / 0.005)**2)
+
+print "Rcrth = ", Rcrth, "+-", dRcrth
+
+Q = pi / theta
+dQ = Q * dtheta/theta
+
+Qth = 1.0 / R * sqrt((L/1000) / C)
+dQth = Qth * sqrt((dR/R)**2 + 0.5**2 * (1.0/5)**2)
+
+#R, dR = roundErr(R, dR)
+Uk, dUk = roundErr(Uk, dUk)
+U0, dU0 = roundErr(U0, dU0)
+theta, dtheta = roundErr(theta, dtheta)
+rtheta, drtheta = roundErr(rtheta, drtheta)
+#rR, drR = roundErr(rR, drR)
+
+Q, dQ = roundErr(Q, dQ)
+Qth, dQth = roundErr(Qth, dQth)
+
+writeCSV('part2_data.csv', ["R", "Uk", "dUk", "U0", "dU0", "theta", "dtheta", "rtheta", "drtheta", "rR", "Q", "dQ", "Qth", "dQth"],
+    [transpose([R, Uk, dUk, U0, dU0, theta, dtheta, rtheta, drtheta, rR, Q, dQ, Qth, dQth])])

# File Electricity&Magnetism/140/data/part2_data.csv

+U     dU     I     dI     T     dT     nu12     dnu12     phi     dphi
+0.112     0.0001     0.09958     2e-05     0.0102     0.0004     9.9     0.2     -0.4     0.1
+0.262     0.0001     0.09747     2e-05     0.00204     8e-05     22.1     0.4     0.4     0.2
+0.2837     0.0001     0.0975     2e-05     0.00104     4e-05     31.0     0.6     0.6     0.2
+0.2852     0.0001     0.09593     2e-05     0.00052     2e-05     43.9     0.8     0.8     0.2
+0.2818     0.0001     0.09444     2e-05     0.00035     2e-05     53.0     2.0     0.9     0.3
+0.276     0.0001     0.09251     2e-05     0.000256     8e-06     62.5     1.0     1.0     0.1
+0.2696     0.0001     0.0903     2e-05     0.0002     8e-06     71.0     1.0     1.2     0.2
+0.2626     0.0001     0.088     2e-05     0.000168     8e-06     77.0     2.0     1.2     0.2
+0.2548     0.0001     0.08538     2e-05     0.000144     4e-06     83.0     1.0     1.3     0.1
+0.246     0.0001     0.08242     2e-05     0.000126     4e-06     89.0     1.0     1.4     0.2
+0.2365     0.0001     0.07915     2e-05     0.000112     4e-06     94.0     2.0     1.5     0.2
+0.2281     0.0001     0.07616     2e-05     0.0001     4e-06     100.0     2.0     1.6     0.2
+0.211     0.0001     0.06989     2e-05     8.6e-05     4e-06     108.0     3.0     1.7     0.2
+0.1957     0.0001     0.06377     2e-05     7.3e-05     2e-06     117.0     2.0     1.8     0.1
+0.1799     0.0001     0.0569     2e-05     6.3e-05     2e-06     126.0     2.0     1.9     0.2
+0.1665     0.0001     0.05054     2e-05     5.6e-05     2e-06     134.0     2.0     2.1     0.2
+0.1549     0.0001     0.04429     2e-05     5.1e-05     2e-06     140.0     3.0     2.3     0.2
+0.1563     0.0001     0.04322     2e-05     4.6e-05     2e-06     147.0     3.0     2.4     0.2
+0.14     0.0001     0.03463     2e-05     4.3e-05     2e-06     152.0     4.0     2.4     0.3
+0.1259     0.0001     0.02651     2e-05     3.8e-05     2e-06     162.0     4.0     2.7     0.3
+0.1128     0.0001     0.01859     2e-05     3.6e-05     2e-06     167.0     5.0     2.9     0.3
+0.1005     0.0001     0.01075     2e-05     3.4e-05     2e-06     171.0     5.0     3.2     0.4
+

# File Electricity&Magnetism/140/data/part2_graph.csv

+nu12     dnu12     phi     dphi
+9.90147542977     0.194146577054     -0.384999099705     0.145443233626
+22.1403721385     0.434124943892     0.415799027681     0.164301803415
+31.0086836473     0.596320839371     0.604152433383     0.166024069283
+43.8529009654     0.843325018564     0.845813406736     0.172531015019
+53.4522483825     1.52720709664     0.8751579535     0.257531408135
+62.5     0.9765625     0.981747704247     0.143244568282
+70.7106781187     1.41421356237     1.16238928183     0.188679775967
+77.151674981     1.83694464241     1.23419711391     0.227180870693
+83.3333333333     1.15740740741     1.308996939     0.134092838595
+89.0870806375     1.41408064504     1.38379676408     0.155059588293
+94.4911182523     1.68734139736     1.45859658917     0.176495921862
+100.0     2.0     1.60221225333     0.202142873625
+107.832773203     2.50773891171     1.66212169463     0.237238800548
+117.041147196     1.60330338625     1.81825054266     0.143137498858
+125.98815767     1.9998120265     1.88246226465     0.167490978872
+133.630620956     2.3862610885     2.13179501494     0.195653191061
+140.028008403     2.74564722358     2.26379470626     0.219095707377
+147.441956155     3.20525991641     2.35619449019     0.246242899981
+152.498570333     3.54647837983     2.39272463733     0.264838031386
+162.221421131     4.2689847666     2.68688845373     0.312714369599
+166.666666667     4.62962962963     2.87979326579     0.339231030302
+171.498585143     5.0440760336     3.18779254555     0.374837434907
+

# File Electricity&Magnetism/140/data/part3.py

+from numpy import *
+from tools import *
+import json
+
+R, n, Uk, U0 = tuple(transpose([
+    [1000.0, 3, 0.8, 4.6],
+    [1250.0, 3, 0.4, 3.6],
+    [1500.0, 3, 0.3, 3.6],
+    [1750.0, 2, 0.4, 3.4],
+    [2000.0, 2, 0.3, 3.1],
+    [2250.0, 1, 1.0, 3.8],
+    [2500.0, 1, 0.7, 3.0],
+    [3000.0, 1, 0.6, 3.6],
+]))
+
+R, n, Uk, U0 = array(R), array(n), array(Uk), array(U0)
+
+RL =  12.8  # ohm
+L = 152.65 # mH
+
+R += RL
+dR = ones(len(R)) * (0.1)
+
+dUk = ones(len(R)) * 0.1 / 10
+dU0 = ones(len(R)) * 0.1
+
+theta = 1.0/n * log(U0/Uk)
+dtheta = 1.0/n * sqrt((dU0 / U0)**2 + (dUk / Uk)**2)
+
+rtheta = 1.0 / theta**2
+drtheta = abs(rtheta) * sqrt(4 * (dtheta / theta)**2)
+rR = 1.0 / R**2
+drR = rR * sqrt(4 * (dR / R)**2)
+
+writeCSV('part3_graph1.csv', ["R", "dR", "theta", "dtheta"],
+    [transpose([R, dR, theta, dtheta])])
+
+writeCSV('part3_graph2.csv', ["rR", "drR", "rtheta", "drtheta"],
+    [transpose([rR, drR, rtheta, drtheta])])
+
+k, _, dk, _ = interpolateLinearly(R, theta, dR, dtheta)
+# k = 2 pi / R_cr
+Rcr = 2 * pi / k
+dRcr = Rcr * sqrt((dk/k)**2)
+
+print "Rcr = ", Rcr, "+-", dRcr
+
+C = 0.005 * 10**(-6)
+Rcrth = 2 * sqrt((L / 1000) / C)
+dRcrth = Rcrth * sqrt(0.5**2 * (0.001 / 0.005)**2)
+
+print "Rcrth = ", Rcrth, "+-", dRcrth
+
+Q = pi / theta
+dQ = Q * dtheta/theta
+
+Qth = 1.0 / R * sqrt((L/1000) / C)
+dQth = Qth * sqrt((dR/R)**2 + 0.5**2 * (1.0/5)**2)
+
+#R, dR = roundErr(R, dR)
+Uk, dUk = roundErr(Uk, dUk)
+U0, dU0 = roundErr(U0, dU0)
+theta, dtheta = roundErr(theta, dtheta)
+rtheta, drtheta = roundErr(rtheta, drtheta)
+#rR, drR = roundErr(rR, drR)
+
+Q, dQ = roundErr(Q, dQ)
+Qth, dQth = roundErr(Qth, dQth)
+
+writeCSV('part3_data.csv', ["R", "Uk", "dUk", "U0", "dU0", "theta", "dtheta", "rtheta", "drtheta", "rR", "Q", "dQ", "Qth", "dQth"],
+    [transpose([R, Uk, dUk, U0, dU0, theta, dtheta, rtheta, drtheta, rR, Q, dQ, Qth, dQth])])

# File Electricity&Magnetism/140/data/part3_data.csv

+nu12     dnu12     k     dk     kth
+9.9     0.2     0.93     0.04     1.02
+22.1     0.4     0.45     0.02     0.381
+31.0     0.6     0.25     0.01     0.238
+43.9     0.8     0.126     0.006     0.139
+53.0     2.0     0.085     0.005     0.0988
+62.5     1.0     0.062     0.002     0.0739
+71.0     1.0     0.049     0.002     0.0578
+77.0     2.0     0.041     0.002     0.0481
+83.0     1.0     0.035     0.001     0.0406
+89.0     1.0     0.031     0.001     0.0348
+94.0     2.0     0.027     0.001     0.0303
+100.0     2.0     0.024     0.001     0.0264
+108.0     3.0     0.021     0.001     0.0218
+117.0     2.0     0.0182     0.0007     0.0175
+126.0     2.0     0.0162     0.0007     0.0142
+134.0     2.0     0.015     0.0007     0.0119
+140.0     3.0     0.0145     0.0007     0.0104
+147.0     3.0     0.0135     0.0007     0.00881
+152.0     4.0     0.0142     0.0007     0.0079
+162.0     4.0     0.0147     0.0009     0.00642
+167.0     5.0     0.018     0.001     0.00585
+171.0     5.0     0.026     0.002     0.00529
+

# File Electricity&Magnetism/140/data/part3_graph.csv

+nu12     dnu12     k     dk     kth
+9.90147542977     0.194146577054     0.934400804807     0.0434544798117     1.02210168044
+22.1403721385     0.434124943892     0.446629725289     0.0207674765271     0.380786473095
+31.0086836473     0.596320839371     0.246476314089     0.0113043202661     0.238178350363
+43.8529009654     0.843325018564     0.125917343197     0.00577503768913     0.139038877667
+53.4522483825     1.52720709664     0.0850629002496     0.00530502147866     0.0988438172161
+62.5     0.9765625     0.0622081803167     0.00248892194303     0.0738569885671
+70.7106781187     1.41421356237     0.0486350385613     0.00229370341167     0.057752170362
+77.151674981     1.83694464241     0.0408327342926     0.00219579704532     0.0480795076167
+83.3333333333     1.15740740741     0.0350020029142     0.00130770698303     0.04059005152
+89.0870806375     1.41408064504     0.0306309293331     0.00123745128002     0.0348441730313
+94.4911182523     1.68734139736     0.027257459777     0.00118805547646     0.0303058947188
+100.0     2.0     0.0243941382754     0.00115048444898     0.0263761710884
+107.832773203     2.50773891171     0.0211472060745     0.00111653692172     0.0217616641167
+117.041147196     1.60330338625     0.0182467028737     0.000676604311623     0.0174750869088
+125.98815767     1.9998120265     0.0162235756317     0.00065545403328     0.0142048705005
+133.630620956     2.3862610885     0.0150263727738     0.000654993354458     0.0119488375209
+140.028008403     2.74564722358     0.0145279067942     0.000675589083012     0.0103645737773
+147.441956155     3.20525991641     0.0135493723723     0.000679498936763     0.00881233622089
+152.498570333     3.54647837983     0.0141589527036     0.000747640927861     0.00790080673978
+162.221421131     4.2689847666     0.0146989641381     0.00085649787601     0.00642405743722
+166.666666667     4.62962962963     0.0177917776325     0.00108404171488     0.00585135678975
+171.498585143     5.0440760336     0.0258894989766     0.00165544740915     0.00529085967665
+

# File Electricity&Magnetism/140/data/tolatex.py

+from __future__ import absolute_import
+from tools import *
+import sys
+
+import contract
+contract.checkmod(__name__)
+import doctest
+doctest.testmod()
+
+if __name__ == "__main__":
+    desc, data = readCSV(sys.argv[1])
+    writeLatexTable(sys.argv[2], desc, data)

# File Electricity&Magnetism/140/data/tools.py

+import numpy as np
+import numpy.random as nprnd
+from collections import namedtuple
+
+def roundErr(x, dx):
+    if isinstance(x, np.ndarray):
+        x = x[:]
+        dx = dx[:]
+        for i in range(len(x)):
+            x[i], dx[i] = roundErr(x[i], dx[i])
+        return (x, dx)
+    else:
+        from math import log10, floor
+        digits = -int(floor(log10(dx)))
+        return (round(x, digits), round(dx, digits))
+
+def interpolateLinearly(x, y, dx, dy, steps = 10000):
+    """
+    pre:
+        len(x) == len(y) == len(dx) == len(dy)
+    """
+
+    def newSample():
+        nx = []
+        ny = []
+        for i in range(len(x)):
+            nx.append(x[i] + nprnd.normal(scale=dx[i]))
+            ny.append(y[i] + nprnd.normal(scale=dy[i]))
+        return (np.array(nx), np.array(ny))
+
+    m = np.zeros(steps)
+    b = np.zeros(steps)
+
+    for i in range(steps):
+        nx, ny = newSample()
+        m[i], b[i] = np.polyfit(nx, ny, 1)
+
+    return (np.mean(m), np.mean(b), np.std(m, ddof=1), np.std(b, ddof=1))
+
+def nearest(value, values, count):
+    """
+    Returns indices of the "count" nearest
+    values to the given one.
+
+    pre:
+        isinstance(values, np.ndarray) or isinstance(values, list)
+        isinstance(value, float) or isinstance(value, int)
+        len(values) >= count
+    post:
+        isinstance(__return__, tuple)
+        len(__return__) == count
+
+    >>> nearest(2, [1, 2, 3], 1)
+    (1,)
+    >>> nearest(2.1, [2.1, 2.2, 90], 1)
+    (0,)
+    >>> nearest(4, [1, 2, 3], 3)
+    (0, 1, 2)
+    >>> nearest(6, [1, 2, 3, 4, 5], 2)
+    (3, 4)
+    >>> nearest(6, [1, 2, 3, 99, 5], 2)
+    (3, 4)
+    >>> nearest(3.4, [1, 2, 3, 4, 5], 3)
+    (1, 2, 3)
+    """
+
+    values = zip(range(len(values)), values)
+    lesser = filter(lambda x: x[1] < value, values)
+    lesser.sort(key=lambda x: (abs(x[1] - value), x[0]))
+    greater = filter(lambda x: x[1] >= value, values)
+    greater.sort(key=lambda x: (abs(x[1] - value), x[0]))
+
+    result = []
+
+    def nextIndex():
+        while True:
+            lists = [lesser, greater]
+            lists = filter(lambda l: len(l) > 0, lists)
+            lists.sort(key=lambda x: abs(x[0][1] - value))
+            for l in lists:
+                yield l.pop(0)[0]
+
+    gen = nextIndex()
+    for _ in range(count):
+        result.append(gen.next())
+
+    result.sort()
+    return tuple(result)
+
+def transpose(rows):
+    """
+    >>> transpose([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
+    [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
+    """
+    return [[rows[y][x] for y in range(len(rows))] for x in range(len(rows[0]))]
+
+def readGenCSV(path):
+    import csv
+
+    def parseValue(value):
+        try:
+            return float(value)
+        except:
+            return value
+
+    with open(path, 'rb') as f:
+        reader = csv.reader(f, delimiter=' ', skipinitialspace=True, quotechar='"')
+
+        yield reader.next()
+
+        rows = []
+        for row in reader:
+            #print row
+            if len(row) == 1 and row[0] == '':
+                yield rows
+                rows = []
+            else:
+                rows.append([parseValue(x) for x in row if x != ''])
+        yield rows
+
+CSVDocument = namedtuple("CSVDocument", "desc values")
+
+def readCSV(path):
+    gen = readGenCSV(path)
+    desc = gen.next()
+    values = list(gen)
+    return CSVDocument(desc, values)
+
+def writeCSV(path, desc, values):
+    with open(path, 'wb') as f:
+        f.write('     '.join(desc))
+        f.write('\n')
+
+        for rows in values:
+            for row in rows:
+                f.write('     '.join(str(x) for x in row))
+                f.write('\n')
+            f.write('\n')
+
+def writeLatexTable(path, desc, values):
+    with open(path, 'wb') as f:
+        f.write("\\begin{center}\n")
+        f.write("  \\topcaption{}\n")
+        f.write("  \\tabletail{\hline}\n")
+        f.write("  \\begin{xtabular}" +
+            "{|" + "|".join(['c' for _ in desc]) + "|}\n")
+        f.write("    \\hline\n")
+
+        # write description row
+        f.write("    " + " & ".join(desc) + "\\\\ \hline \hline \n")
+
+        parts = []
+        for rows in values:
+            lines = []
+            for row in rows:
+                lines.append("    " + " & ".join(str(x) for x in row))
+            parts.append("\\\\ \\hline\n".join(lines))
+        f.write("\\\\ \\hline \\hline\n".join(parts))
+        f.write("\\\\ \\hline\n")
+
+        f.write("  \end{xtabular}\n")
+        f.write("\end{center}\n")
+
+import contract
+contract.checkmod(__name__)
+import doctest
+doctest.testmod()

# File Electricity&Magnetism/140/report.tex

+\documentclass[a4paper, 9pt, cmr, twocolumn]{report}
+
+% packages for utf8 + russian language
+\usepackage[utf8]{inputenc}
+\usepackage{cmap}
+\usepackage[T2A]{fontenc}
+\usepackage[english,russian]{babel}
+\renewcommand{\familydefault}{cmr}
+
+% other used packages
+\usepackage{amssymb, amsfonts, amsthm, amsmath, mathtext, enumerate, float, lmodern}
+\usepackage{color, textcomp, epsf, tikz, pgf}
+\usepackage[cm]{fullpage}
+\usepackage{nonfloat}
+\usepackage{xtab}
+
+% graphics package
+\usepackage{graphicx}
+\graphicspath{{pictures/}}
+
+% set different dimensions
+\setlength{\columnsep}{0.5cm}
+\setlength{\parindent}{0.4cm}
+
+% vectors look better this way imho
+\renewcommand{\vec}{\overline}
+
+% a symbol usually used for electromotive force
+\newcommand{\Epsilon}{\mathcal{E}}
+\newcommand{\arccot}{\mathrm{arccot}}
+\newcommand{\comment}[1]{}
+
+\title{Работа 140\\Скин-эффект}
+\author{Коновалов Александр}
+\date{\today}
+
+\setcounter{chapter}{1}
+
+\begin{document}
+  \maketitle
+  \tableofcontents
+  \input{text/theory.tex}
+  \input{text/tables-and-figures.tex}
+\end{document}

# File Electricity&Magnetism/140/text/data/part1_data.tex

+\begin{center}
+  \topcaption{Данные к пункту 1}
+  \label{tab:part1_data}
+  \tabletail{\hline}
+  \begin{xtabular}{|c|c|c|c|c|c|c|c|c|c|c|c|}
+    \hline
+    $U [V]$ & $\Delta U [V]$ & $I [A]$ & $\Delta I [A]$ & $T [s]$ & $\Delta T [s]$ & $f [s^{-1}]$ & $\Delta f [s^{-1}]$ & $f^2 [s^{-2}]$ & $\Delta f^2 [s^{-2}]$ & $\xi$ & $\Delta \xi$\\ \hline \hline
+    0.0245 & 0.0001 & 0.0984 & 0.0002 & 0.049 & 0.002 & 20.4 & 0.8 & 420.0 & 30.0 & 0.0122 & 0.0005\\ \hline
+    0.0363 & 0.0001 & 0.0986 & 0.0002 & 0.033 & 0.002 & 30.0 & 2.0 & 900.0 & 100.0 & 0.0121 & 0.0007\\ \hline
+    0.0478 & 0.0001 & 0.0987 & 0.0002 & 0.0252 & 0.0008 & 40.0 & 1.0 & 1570.0 & 100.0 & 0.0122 & 0.0004\\ \hline
+    0.0593 & 0.0001 & 0.0988 & 0.0002 & 0.02 & 0.0008 & 50.0 & 2.0 & 2500.0 & 200.0 & 0.012 & 0.0005\\ \hline
+    0.0704 & 0.0001 & 0.0992 & 0.0002 & 0.0168 & 0.0008 & 60.0 & 3.0 & 3500.0 & 300.0 & 0.0119 & 0.0006\\ \hline
+    0.0813 & 0.0001 & 0.0993 & 0.0002 & 0.0144 & 0.0008 & 69.0 & 4.0 & 4800.0 & 500.0 & 0.0118 & 0.0007\\ \hline
+    0.0922 & 0.0001 & 0.0996 & 0.0002 & 0.0128 & 0.0008 & 78.0 & 5.0 & 6100.0 & 800.0 & 0.0119 & 0.0007\\ \hline
+    0.1025 & 0.0001 & 0.0998 & 0.0002 & 0.0112 & 0.0004 & 89.0 & 3.0 & 8000.0 & 600.0 & 0.0115 & 0.0004\\ \hline
+    0.1122 & 0.0001 & 0.0999 & 0.0002 & 0.01 & 0.0004 & 100.0 & 4.0 & 10000.0 & 800.0 & 0.0112 & 0.0005\\ \hline
+  \end{xtabular}
+\end{center}

# File Electricity&Magnetism/140/text/data/part2_data.tex

+\begin{center}
+  \topcaption{Данные к пункту 2}
+  \label{tab:part2_data}
+  \tabletail{\hline}
+  \begin{xtabular}{|c|c|c|c|c|c|c|c|c|c|}
+    \hline
+    $U [V]$ & $\Delta U [V]$ & $I [A]$ & $\Delta I [A]$ & $T [s]$ & $\Delta T [s]$ & $\sqrt{f} [s^{-1/2}]$ & $\Delta \sqrt{f} [s^{-1/2}]$ & $\varphi - \frac{3 \pi}{4}$ & $\Delta \varphi$\\ \hline \hline
+    0.112 & 0.0001 & 0.09958 & 2e-05 & 0.0102 & 0.0004 & 9.9 & 0.2 & -0.4 & 0.1\\ \hline
+    0.262 & 0.0001 & 0.09747 & 2e-05 & 0.00204 & 8e-05 & 22.1 & 0.4 & 0.4 & 0.2\\ \hline
+    0.2837 & 0.0001 & 0.0975 & 2e-05 & 0.00104 & 4e-05 & 31.0 & 0.6 & 0.6 & 0.2\\ \hline
+    0.2852 & 0.0001 & 0.09593 & 2e-05 & 0.00052 & 2e-05 & 43.9 & 0.8 & 0.8 & 0.2\\ \hline
+    0.2818 & 0.0001 & 0.09444 & 2e-05 & 0.00035 & 2e-05 & 53.0 & 2.0 & 0.9 & 0.3\\ \hline
+    0.276 & 0.0001 & 0.09251 & 2e-05 & 0.000256 & 8e-06 & 62.5 & 1.0 & 1.0 & 0.1\\ \hline
+    0.2696 & 0.0001 & 0.0903 & 2e-05 & 0.0002 & 8e-06 & 71.0 & 1.0 & 1.2 & 0.2\\ \hline
+    0.2626 & 0.0001 & 0.088 & 2e-05 & 0.000168 & 8e-06 & 77.0 & 2.0 & 1.2 & 0.2\\ \hline
+    0.2548 & 0.0001 & 0.08538 & 2e-05 & 0.000144 & 4e-06 & 83.0 & 1.0 & 1.3 & 0.1\\ \hline
+    0.246 & 0.0001 & 0.08242 & 2e-05 & 0.000126 & 4e-06 & 89.0 & 1.0 & 1.4 & 0.2\\ \hline
+    0.2365 & 0.0001 & 0.07915 & 2e-05 & 0.000112 & 4e-06 & 94.0 & 2.0 & 1.5 & 0.2\\ \hline
+    0.2281 & 0.0001 & 0.07616 & 2e-05 & 0.0001 & 4e-06 & 100.0 & 2.0 & 1.6 & 0.2\\ \hline
+    0.211 & 0.0001 & 0.06989 & 2e-05 & 8.6e-05 & 4e-06 & 108.0 & 3.0 & 1.7 & 0.2\\ \hline
+    0.1957 & 0.0001 & 0.06377 & 2e-05 & 7.3e-05 & 2e-06 & 117.0 & 2.0 & 1.8 & 0.1\\ \hline
+    0.1799 & 0.0001 & 0.0569 & 2e-05 & 6.3e-05 & 2e-06 & 126.0 & 2.0 & 1.9 & 0.2\\ \hline
+    0.1665 & 0.0001 & 0.05054 & 2e-05 & 5.6e-05 & 2e-06 & 134.0 & 2.0 & 2.1 & 0.2\\ \hline
+    0.1549 & 0.0001 & 0.04429 & 2e-05 & 5.1e-05 & 2e-06 & 140.0 & 3.0 & 2.3 & 0.2\\ \hline
+    0.1563 & 0.0001 & 0.04322 & 2e-05 & 4.6e-05 & 2e-06 & 147.0 & 3.0 & 2.4 & 0.2\\ \hline
+    0.14 & 0.0001 & 0.03463 & 2e-05 & 4.3e-05 & 2e-06 & 152.0 & 4.0 & 2.4 & 0.3\\ \hline
+    0.1259 & 0.0001 & 0.02651 & 2e-05 & 3.8e-05 & 2e-06 & 162.0 & 4.0 & 2.7 & 0.3\\ \hline
+    0.1128 & 0.0001 & 0.01859 & 2e-05 & 3.6e-05 & 2e-06 & 167.0 & 5.0 & 2.9 & 0.3\\ \hline
+    0.1005 & 0.0001 & 0.01075 & 2e-05 & 3.4e-05 & 2e-06 & 171.0 & 5.0 & 3.2 & 0.4\\ \hline
+  \end{xtabular}
+\end{center}

# File Electricity&Magnetism/140/text/data/part3_data.tex

+\begin{center}
+  \topcaption{Данные к пункту 3}
+  \label{tab:part3_data}
+  \tabletail{\hline}
+  \begin{xtabular}{|c|c|c|c|c|}
+    \hline
+    $\sqrt{f} [s^{-1/2}]$ & $\Delta \sqrt{f} [s^{-1/2}]$ & $k = \frac{H_{0c}}{H_0}$ & $\Delta k = \Delta \frac{H_{0c}}{H_0}$ & $k_{th}$\\ \hline \hline
+    9.9 & 0.2 & 0.93 & 0.04 & 1.02\\ \hline
+    22.1 & 0.4 & 0.45 & 0.02 & 0.381\\ \hline
+    31.0 & 0.6 & 0.25 & 0.01 & 0.238\\ \hline
+    43.9 & 0.8 & 0.126 & 0.006 & 0.139\\ \hline
+    53.0 & 2.0 & 0.085 & 0.005 & 0.0988\\ \hline
+    62.5 & 1.0 & 0.062 & 0.002 & 0.0739\\ \hline
+    71.0 & 1.0 & 0.049 & 0.002 & 0.0578\\ \hline
+    77.0 & 2.0 & 0.041 & 0.002 & 0.0481\\ \hline
+    83.0 & 1.0 & 0.035 & 0.001 & 0.0406\\ \hline
+    89.0 & 1.0 & 0.031 & 0.001 & 0.0348\\ \hline
+    94.0 & 2.0 & 0.027 & 0.001 & 0.0303\\ \hline
+    100.0 & 2.0 & 0.024 & 0.001 & 0.0264\\ \hline
+    108.0 & 3.0 & 0.021 & 0.001 & 0.0218\\ \hline
+    117.0 & 2.0 & 0.0182 & 0.0007 & 0.0175\\ \hline
+    126.0 & 2.0 & 0.0162 & 0.0007 & 0.0142\\ \hline
+    134.0 & 2.0 & 0.015 & 0.0007 & 0.0119\\ \hline
+    140.0 & 3.0 & 0.0145 & 0.0007 & 0.0104\\ \hline
+    147.0 & 3.0 & 0.0135 & 0.0007 & 0.00881\\ \hline
+    152.0 & 4.0 & 0.0142 & 0.0007 & 0.0079\\ \hline
+    162.0 & 4.0 & 0.0147 & 0.0009 & 0.00642\\ \hline
+    167.0 & 5.0 & 0.018 & 0.001 & 0.00585\\ \hline
+    171.0 & 5.0 & 0.026 & 0.002 & 0.00529\\ \hline
+  \end{xtabular}
+\end{center}

# File Electricity&Magnetism/140/text/tables-and-figures.tex

+\onecolumn
+  \input{text/data/part1_data.tex}
+  \input{text/data/part2_data.tex}
+  \input{text/data/part3_data.tex}
+
+\newpage
+  \begin{figure}
+    \centering
+    \includegraphics[width=0.8\linewidth]{scheme}
+    \figcaption{Схема установки}
+    \label{fig:scheme}
+  \end{figure}
+
+  \begin{figure}
+    \centering
+    \includegraphics[width=\linewidth]{part1_graph}
+    \figcaption{Зависимость $\xi \left( f^2 \right)$}
+    \label{fig:part1_graph}
+  \end{figure}
+
+  \begin{figure}
+    \centering
+    \includegraphics[width=\linewidth]{part2_graph}
+    \figcaption{Зависимость $\varphi \left( f^{1/2} \right)$}
+    \label{fig:part2_graph}
+  \end{figure}
+
+  \begin{figure}
+    \centering
+    \includegraphics[width=\linewidth]{part3_graph}
+    \figcaption{Зависимость $\xi \left( f^{1/2} \right)$}
+    \label{fig:part3_graph}
+  \end{figure}

# File Electricity&Magnetism/140/text/theory.tex

+\section{Измерение отношения абсолютных величин амплитуд магнитного поля внутри и вне экрана}
+  Cхему установки можно посмотреть на рисунке \ref{fig:scheme}.
+
+  С помощью вольтметра «V» мы измеряем действующее значение ЭДС
+индукции, которая возникает в измерительной катушке, находящейся в переменном магнитном поле:
+
+    H_{0c}(t) = H_{0c} e^{i \omega t}.
+
+
+  ЭДС индукции в измерительной катушке
+
+    \Epsilon_i = -S N \frac{dB_{0c}(t)}{dt} = -i \mu_0 S N \omega H_{0c} e^{i \omega t},
+
+
+  где $S N$ — произведение площади витка на число витков измерительной катушки. Обозначим показание вольтметра «V» через $U$, тогда
+
+    U = \frac{\mu_0 S N \omega}{\sqrt{2}} |H_{0c}|.
+
+
+  Видно, что отставание фазы увеличивается на $\frac{\pi}{2}$:
+
+    \Delta \varphi = \frac{3 \pi}{4} + \frac{h \sqrt{\mu \mu_0 \sigma \omega}}{\sqrt{2}}
+
+
+  Также из этого соотношения следует, что абсолютная величина амплитуды магнитного поля внутри экрана
+
+    H_{0c} \sim \frac{U}{\omega} \sim \frac{U}{f}.
+
+
+  где f — частота генератора в герцах ($\omega = 2 \pi f$). Но поле внутри экрана пропорционально полю вне экрана $H_0$ , а $H_0 \sim I_A$, где $I_A$ — показание амперметра «A» в цепи соленоида. Следовательно, амплитуда поля внутри экрана, приведённая к единичному току через соленоид,
+
+    |H_{0c}| \sim \frac{U}{f I_A}
+
+
+  Обозначим величину, пропорциональную $|H_{0c}|$, через $\xi_{0c}$:
+
+    \xi_{0c} = \frac{U}{f I_A}
+
+
+  Нам теперь необходимо найти амплитуду поля вне экрана при том же единичном токе через соленоид. Проведя измерения $\xi_{0c}$ в диапазоне самых малых частот, мы строим график зависимости $\xi_{0с}$ от $f$. Эта зависимость имеет вид прямой. Экстраполируя её к $f = 0$, мы и получим $\xi_{0c}(0) = \xi_0$, которая пропорциональна амплитуде поля вне экрана при единичном токе через соленоид. Отношение амплитуд магнитного поля внутри экрана и вне при фиксированном f будет равно
+
+    \frac{|H_{0c}|}{|H_0|} = \frac{\xi_{0c}(f)}{\xi_0} = \frac{U}{f I_A \xi_0}
+
+
+  Такой способ измерения коэффициента ослабления магнитного поля проводящим экраном не требует поддерживать постоянный ток через соленоид при измерении частотной зависимости этого коэффициента.
+
+\section{Определение проводимости материала экрана}
+  В нашем случае в качестве экрана используется медная труба промышленного производства. Технология изготовления труб оказывает заметное влияние на её электропроводимость. Электропроводимость меди нашей трубы отличается от табличного значения в область заниженного значения. Для определения электропроводимости меди нашего экрана предлагается использовать частотную зависимость фазового сдвига между магнитными полями внутри экрана и вне в области больших частот.
+В области больших частот зависимость $\Delta \varphi(\sqrt{f})$  аппроксимируется прямой проходящей через точку $\Delta \varphi(0) = \frac{3 \pi}{4}$. По наклону этой прямой можно вычислить проводимость материала экрана.
+
+\section{Результаты и их обработка}
+  Радиус цилиндра $a = 21 \pm 1 [mm]$, толщина стенок $h = 1.3 \pm 0.1 [mm]$.
+
+  График $\xi \left( f^2 \right)$ приведен на рисунке \ref{fig:part1_graph}. Из него найдем $\xi_0 = 0.0123 \pm 0.0003$.
+
+  График $\varphi \left( f^{1/2} \right)$ приведен на рисунке \ref{fig:part2_graph}. Его наклон $k = 0.015 \pm 0.001$. Из этого наклона найдем $\sigma = (33 \pm 7) \cdot 10^6$. Большую часть этой погрешности составляет погрешность $h$.
+
+  График $\frac{H_{0c}}{H_0} = g \left( f^{1/2} \right)$ приведен на рисунке \ref{fig:part3_graph}. На нем также построена теоретическая зависимость.
+
+  Зная $\sigma$ посчитаем глубину проникновения $\delta(50 [Hz]) = 0.017 \pm 0.002 [m]$ и $\delta(10^{4} [Hz]) = 0.00039 \pm 0.00004 [m]$.

# File Electricity&Magnetism/3.2.1/data/R.py

+from __future__ import absolute_import
+
+import numpy as np
+from tools import *
+
+pnu, dpnu, phi, dphi = tuple(transpose(readCSV('rlc100_graph_noabs.csv').values[0]))
+indices = nearest(0, pnu, 8)
+pnu, dpnu, phi, dphi = tuple(transpose([(pnu[i], dpnu[i], phi[i], dphi[i]) for i in indices]))
+print interpolateLinearly(pnu, phi, dpnu, dphi)

# File Electricity&Magnetism/3.2.1/data/params.csv

+what                    value
+"$\nu[Hz]$"             1000
+"$C[\mu F]$"            0.5
+"$L[mH]$"               50
+"$r[\Omega]$"           12.3
+"$R_L[\Omega]$"         32.5
+"$\Delta C[\mu F]$"     "$\approx 0$"
+"$\Delta L[mH]$"        "$\approx 0$"
+"$\Delta r[\Omega]$"    0.1
+"$\Delta R_L[\Omega]$"  0.1
+"$\Delta x$"            0.05
+"$\Delta nu$"           10

# File Electricity&Magnetism/3.2.1/data/phase_rc.py

+from __future__ import absolute_import, division
+
+import numpy as np
+from tools import *
+
+params = [x[1] for x in readCSV('params.csv').values[0]]
+nu = params[0]
+C = params[1] / 1000.0**2
+L = params[2] / 1000.0
+r = params[3]
+RL = params[4]
+dr = params[7]
+dRL = params[8]
+dx = params[9]
+
+def doRC():
+    R, x0, x = tuple(transpose(readCSV('rc.csv').values[0]))
+    R, x0, x = np.array(R), np.array(x0), np.array(x)
+
+    Rsum = R + r
+    dRsum = np.ones(len(Rsum)) * dr
+
+    prod = 2 * np.pi * nu * C * Rsum
+    dprod = prod * np.sqrt((1.0 / nu)**2 + (dRsum/Rsum)**2)
+
+    phi = (x / x0) * np.pi
+    dphi = phi * np.sqrt((dx/x0)**2 + (dx/x)**2)
+
+    cot = 1 / np.tan(phi)
+    dcot = np.abs(1.0 / np.sin(phi)**2) * dphi
+
+    Rsum, dRsum = roundErr(Rsum, dRsum)
+    prod, dprod = roundErr(prod, dprod)
+    phi, dphi = roundErr(phi, dphi)
+    cot, dcot = roundErr(cot, dcot)
+
+    writeCSV('rc_phi.csv', ['Rsum', 'dRsum', 'phi', 'dphi'],
+        [transpose([Rsum, dRsum, phi, dphi])])
+    writeCSV('rc_cot.csv', ['prod', 'dprod', 'cot', 'dcot'],
+        [transpose([prod, dprod, cot, dcot])])
+    writeCSV('rc_phi_cot.csv', ['R', 'x0', 'x', 'Rsum', 'dRsum', 'prod', 'dprod', 'phi', 'dphi', 'cot', 'dcot'],
+        [transpose([R, x0, x, Rsum, dRsum, prod, dprod, phi, dphi, cot, dcot])])
+
+doRC()
+
+
+

# File Electricity&Magnetism/3.2.1/data/phase_rl.py

+from __future__ import absolute_import, division
+
+import numpy as np
+from tools import *
+
+params = [x[1] for x in readCSV('params.csv').values[0]]
+nu = params[0]
+C = params[1] / 1000.0**2
+L = params[2] / 1000.0
+r = params[3]
+RL = params[4]
+dr = params[7]
+dRL = params[8]
+dx = params[9]
+
+def doRL():
+    R, x0, x = tuple(transpose(readCSV('rc.csv').values[0]))
+    R, x0, x = np.array(R), np.array(x0), np.array(x)
+
+    Rsum = R + RL + r
+    dRsum = np.ones(len(Rsum)) * (dr + dRL)
+
+    prod =  Rsum / (2 * np.pi * nu * L)
+    dprod = prod * np.sqrt((1.0 / nu)**2 + (dRsum/Rsum)**2)
+
+    phi = (x / x0) * np.pi
+    dphi = phi * np.sqrt((dx/x0)**2 + (dx/x)**2)
+
+    cot = 1 / np.tan(phi)
+    dcot = np.abs(1.0 / np.sin(phi)**2) * dphi
+
+    Rsum, dRsum = roundErr(Rsum, dRsum)
+    prod, dprod = roundErr(prod, dprod)
+    phi, dphi = roundErr(phi, dphi)
+    cot, dcot = roundErr(cot, dcot)
+
+    writeCSV('rl_phi.csv', ['Rsum', 'dRsum', 'phi', 'dphi'],
+        [transpose([Rsum, dRsum, phi, dphi])])
+    writeCSV('rl_cot.csv', ['prod', 'dprod', 'cot', 'dcot'],
+        [transpose([prod, dprod, cot, dcot])])
+    writeCSV('rl_phi_cot.csv', ['R', 'x0', 'x', 'Rsum', 'dRsum', 'prod', 'dprod', 'phi', 'dphi', 'cot', 'dcot'],
+        [transpose([R, x0, x, Rsum, dRsum, prod, dprod, phi, dphi, cot, dcot])])
+
+doRL()
+
+
+

# File Electricity&Magnetism/3.2.1/data/rc.csv

+$R[\Omega]$ $x0$ $x$
+    0       5.0     2.5
+    100     5.0     2.0
+    200     5.0     1.6
+    300     5.0     1.3
+    400     5.0     1.1
+    500     5.0     0.9
+    600     5.0     0.8
+    700     5.0     0.7
+    800     5.0     0.6
+    1000    5.0     0.5

# File Electricity&Magnetism/3.2.1/data/rc_cot.csv

+prod     dprod     cot     dcot
+0.0386     0.0003     0.0     0.04
+0.3528     0.0005     0.32     0.04
+0.667     0.0007     0.63     0.05
+0.981     0.001     0.94     0.06
+1.295     0.001     1.21     0.08
+1.609     0.002     1.6     0.1
+1.924     0.002     1.8     0.1
+2.238     0.002     2.1     0.2
+2.552     0.003     2.5     0.2
+3.18     0.003     3.1     0.3
+

# File Electricity&Magnetism/3.2.1/data/rc_phi.csv

+Rsum     dRsum     phi     dphi
+12.3     0.1     1.57     0.04
+112.3     0.1     1.26     0.03
+212.3     0.1     1.01     0.03
+312.3     0.1     0.82     0.03
+412.3     0.1     0.69     0.03
+512.3     0.1     0.57     0.03
+612.3     0.1     0.5     0.03
+712.3     0.1     0.44     0.03
+812.3     0.1     0.38     0.03
+1012.3     0.1     0.31     0.03
+

# File Electricity&Magnetism/3.2.1/data/rc_phi_cot.csv

+R     x0     x     Rsum     dRsum     prod     dprod     phi     dphi     cot     dcot
+0.0     5.0     2.5     12.3     0.1     0.0386     0.0003     1.57     0.04     0.0     0.04
+100.0     5.0     2.0     112.3     0.1     0.3528     0.0005     1.26     0.03     0.32     0.04
+200.0     5.0     1.6     212.3     0.1     0.667     0.0007     1.01     0.03     0.63     0.05
+300.0     5.0     1.3     312.3     0.1     0.981     0.001     0.82     0.03     0.94     0.06
+400.0     5.0     1.1     412.3     0.1     1.295     0.001     0.69     0.03     1.21     0.08
+500.0     5.0     0.9     512.3     0.1     1.609     0.002     0.57     0.03     1.6     0.1
+600.0     5.0     0.8     612.3     0.1     1.924     0.002     0.5     0.03     1.8     0.1
+700.0     5.0     0.7     712.3     0.1     2.238     0.002     0.44     0.03     2.1     0.2
+800.0     5.0     0.6     812.3     0.1     2.552     0.003     0.38     0.03     2.5     0.2
+1000.0     5.0     0.5     1012.3     0.1     3.18     0.003     0.31     0.03     3.1     0.3
+

# File Electricity&Magnetism/3.2.1/data/rl.csv

+$R[\Omega]$ $x0$ $x$
+    0       5.0     2.3
+    100     5.0     1.8
+    200     5.0     1.4
+    300     5.0     1.15
+    400     5.0     0.95
+    500     5.0     0.80
+    600     5.0     0.70
+    700     5.0     0.60
+    800     5.0     0.55
+    900     5.0     0.50
+    1000    5.0     0.45
+    1100    5.0     0.40
+    1200    5.0     0.35
+    1500    5.0     0.30
+    1900    5.0     0.25

# File Electricity&Magnetism/3.2.1/data/rl_cot.csv

+prod     dprod     cot     dcot
+0.1426     0.0007     0.0     0.04
+0.4609     0.0008     0.32     0.04
+0.779     0.001     0.63     0.05
+1.098     0.001     0.94     0.06
+1.416     0.002     1.21     0.08
+1.734     0.002     1.6     0.1
+2.052     0.002     1.8     0.1
+2.371     0.002     2.1     0.2
+2.689     0.003     2.5     0.2
+3.326     0.003     3.1     0.3
+

# File Electricity&Magnetism/3.2.1/data/rl_phi.csv

+Rsum     dRsum     phi     dphi
+44.8     0.2     1.57     0.04
+144.8     0.2     1.26     0.03
+244.8     0.2     1.01     0.03
+344.8     0.2     0.82     0.03
+444.8     0.2     0.69     0.03
+544.8     0.2     0.57     0.03
+644.8     0.2     0.5     0.03
+744.8     0.2     0.44     0.03
+844.8     0.2     0.38     0.03
+1044.8     0.2     0.31     0.03
+