aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jarrio/week09.bc (renamed from jarrio/week9practice.bc)1
-rw-r--r--jarrio/week10.bc245
-rw-r--r--jarrio/week10resistors.py66
-rw-r--r--li/hw6.tex14
4 files changed, 320 insertions, 6 deletions
diff --git a/jarrio/week9practice.bc b/jarrio/week09.bc
index 611dc8e..b0357f8 100644
--- a/jarrio/week9practice.bc
+++ b/jarrio/week09.bc
@@ -1,4 +1,3 @@
-########################################################################
print "Weekly Homework 9\n"
pi = 4*a(1)
epsilon = 8.85 * 10^(-12)
diff --git a/jarrio/week10.bc b/jarrio/week10.bc
new file mode 100644
index 0000000..80a8fee
--- /dev/null
+++ b/jarrio/week10.bc
@@ -0,0 +1,245 @@
+print "Daily Homework 10a\n"
+
+print "Question 4\n"
+#params
+vbattery = 3.05
+vchange = 2.9
+ammeter = 1.7
+
+bigr = vchange/ammeter
+"emf "
+vbattery
+"internal resistance "
+rtot = vbattery/ammeter
+rtot - bigr
+"circuit resistance "
+bigr
+
+print "\nDaily Homework 10b\n"
+
+print "Question 1\n"
+#params
+r1 = 2
+r2 = 5
+r3 = 1
+r4 = 7
+r5 = 3
+r6 = 3
+r7 = 3
+
+"RA "
+r4+r3+1/(1/r1+1/r2)
+"RB (open) "
+r5 + r4 + r3 + 1/(1/(r6+r1) + 1/r2)
+"RB (closed) "
+r5 + 1/(1/r4+1/r7) + r3 + 1/(1/(r6+r1) + 1/r2)
+
+print "Question 2\n"
+print "Rlong^2\n"
+
+print "Question 3\n"
+# params
+ratio = 10 # Ip = 10Is
+# Without loss of generality, let Is = 1, and R2 = 1, so r = R1.
+# IR = V
+# 1(1+r) = V
+# 10/(1/1 + 1/r) = V
+# 1 + r = 10/(1 + 1/r)
+# (1+r)(1+1/r) = 10
+# r^2 + 2r + 1 = 10r
+# r^2 - 8r + 1 = 0
+b = 2 - ratio
+(-b - sqrt(b^2 - 4*1*1))/2
+
+print "Question 4\n"
+#params
+ammeter = 9
+
+# clockwise loop rule on top loop
+# ammeter - 3*i1 + 2*ammeter = 0
+i1 = ammeter
+print "I1 (A)\n"
+i1
+
+# branch rule
+i2 = i1+ammeter
+print "I2 (A)\n"
+i2
+
+# clockwise loop rule on bottom loop
+# -2*ammeter + electromotive - 1*i2 = 0
+electromotive = 2*ammeter + i2
+print "Electromotive (V)\n"
+electromotive
+
+print "\nDaily Homework 10c\n"
+print "Question 2\n"
+print "C > A = E > B > D\n"
+
+print "Question 3\n"
+#params
+c = 10 # uF
+q = 30 # uC
+r = 1.8 # kOhm
+qtarget = 15 # uC
+
+# c = q(t)/v(t) --> v(t) = q(t)/c
+# dq(t)/dt = -I = -v(t)/r
+# dq(t)/dt = -q(t)/cr
+# q(t) = Ce^{-t/cr}
+# C = q
+# q(t) = qe^{-t/cr} = qtarget => -t/cr = ln(qtarget/q)
+
+r = r*1000 # Ohm
+qtarget = qtarget/10^6 # C
+c = c/10^6 # F
+q = q/10^6 # C
+
+t = -c*r*l(qtarget/q)
+print "Time (s)\n"
+t
+
+print "\nWeekly Homework 10\n"
+print "Question 1\n"
+#params
+r1 = 2.5 # kOhm
+r2 = 4.0 # kOhm
+r3 = 5.0 # kOhm
+v = 100 # V
+# v = ir
+# p = iv = v^2/r
+
+pparallel = v^2 / (1/(1/r1 + 1/r2 + 1/r3))
+pseries = v^2 / (r1 + r2 + r3)
+pparallel/pseries
+
+print "Question 2\n"
+# I = ef/(r+R)
+# P = I^2R = ef^2*R/(r+R)^2
+# dP/dR = 0 = d/dR (ef^2*R/(r+R)^2)
+# d/dR (R/(r+R)^2) = 0
+# (r+R)/(r+R)^3 - 2R/(r+R)^3 = (r-R)/(r+R)^3 = 0
+# r = R
+print "Part A: R = r\n"
+
+print "Part B\n"
+# params
+ef = 5 # V
+r = 1.8 # Ohm
+i = ef/(r+r)
+print "Power (W)\n"
+i^2*r
+
+print "Question 3\n"
+#params
+bulbr = 6 # Ohm
+r = .8 # Ohm
+v = 1.5 # V
+
+iopen = v/(r+bulbr)
+print "I_open (A)\n"
+iopen
+
+iclosed = v/(r+bulbr/2) / 2 # because current is even between a and b
+print "I_closed (A)\n"
+iclosed
+
+print "pct change\n"
+100*(iclosed-iopen)/iopen
+
+print "Question 4\n"
+v = 24 # V
+# No params. Effective resistance w/ open is 6Ohm and 6Ohm in parallel,
+# giving 3Ohm
+print "Part A - Ibat (A)\n"
+v/3
+
+print "Part B - dV (V)\n"
+v/3
+
+# the two pairs of parallel resistors = two effective resistors in
+# parallel
+print "Part C - Ibat (A)\n"
+v / (1/(1/3 + 1/5) + 1/(1/3 + 1))
+
+print "Part D - dV (V)\n"
+0
+
+print "Question 5\n"
+v = 24 # V
+i6 = v/10 # effective resistance calculation
+i5 = v/15 # same
+i10 = i5
+i4 = i6
+
+print "Currents (i6, i5, i10, i4)\n"
+i6
+i5
+i10
+i4
+
+v6 = i6*6 # V = IR
+v5 = i5*5
+v10 = i10*10
+v4 = i4*4
+print "Voltages (v6, v5, v10, v4)\n"
+v6
+v5
+v10
+v4
+
+print "Question 6\n"
+#params
+v = 150
+rtot = 2 + 1/(1/20 + 1/5) + 4
+itot = v/rtot
+vparallel = itot / (1/20 + 1/5) # v through the parallel resistors
+i20 = vparallel/20
+
+print "I20 (A)\n"
+i20
+
+print "Question 7\n"
+
+# 1/(1/4 + 1/12) = 3.
+# 3 + 5 = 8
+# 1/(1/8 + 1/24) = 6.
+# Assume current goes clockwise.
+# Loop: 12 - I*6 - 3 - I*3 = 0
+# 9 = I*9 => I = 1A.
+# Then, week10resistors.py has the solution
+print "See source\n"
+
+print "Question 8\n"
+#params
+tconstant = 7 # ms
+
+print "Charge reduced to half (ms)\n"
+-l(1/2)*tconstant
+
+print "Energy reduced to half (ms)\n"
+-l(1/sqrt(2))*tconstant
+
+print "Question 9\n"
+#params
+c = 40 # uF
+# The graph shows a reduction from 30V to 10V in 4ms, giving a time
+# constant of
+tconstant = 4/l(30/10) # ms
+# tconstant = cr => r = tconstant/c
+c = c/10^6 # F
+tconstant = tconstant/1000 # s
+r = tconstant/c
+print "Resistance\n"
+r
+
+print "Question 10\n"
+#params
+c = .25 # uF
+v = 70 # V
+r1 = 25 # Ohm (the one the question asks about)
+r2 = 150 # Ohm
+q = c*v # uC
+j = q*v/2
+print "Energy dissipated (uJ)\n"
+j*r1/(r1+r2)
diff --git a/jarrio/week10resistors.py b/jarrio/week10resistors.py
new file mode 100644
index 0000000..f7041c7
--- /dev/null
+++ b/jarrio/week10resistors.py
@@ -0,0 +1,66 @@
+class resistor:
+ def __init__(self, resistance: float):
+ self._resistance = resistance;
+ self.has_current(0)
+
+ def has_current(self, current: float):
+ self._current = current
+ self._voltage = current*self._resistance
+
+ def has_voltage(self, voltage: float):
+ self._voltage = voltage
+ self._current = voltage/self._resistance
+
+ def __repr__(self):
+ return f"Resistor with resistance {self._resistance}: current {self._current} through voltage {self._voltage}"
+
+class parallel(resistor):
+ def __init__(self, r1: resistor, r2: resistor):
+ self._r1 = r1
+ self._r2 = r2
+ self._resistance = 1/(1/r1._resistance + 1/r2._resistance)
+
+ def _update_children(self):
+ self._r1.has_voltage(self._voltage)
+ self._r2.has_voltage(self._voltage)
+
+ def has_current(self, current: float):
+ self._current = current
+ self._voltage = current*self._resistance
+ self._update_children()
+
+ def has_voltage(self, voltage: float):
+ self._voltage = voltage
+ self._current = voltage/self._resistance
+ self._update_children()
+
+class series(resistor):
+ def __init__(self, r1: resistor, r2: resistor):
+ self._r1 = r1
+ self._r2 = r2
+ self._resistance = r1._resistance + r2._resistance
+
+ def _update_children(self):
+ self._r1.has_current(self._current)
+ self._r2.has_current(self._current)
+
+ def has_current(self, current: float):
+ self._current = current
+ self._voltage = current*self._resistance
+ self._update_children()
+
+ def has_voltage(self, voltage: float):
+ self._voltage = voltage
+ self._current = voltage/self._resistance
+ self._update_children()
+
+r24 = resistor(24)
+r4 = resistor(4)
+r12 = resistor(12)
+r5 = resistor(5)
+rtot = parallel( r24, series( parallel(r4,r12), r5 ) )
+rtot.has_current(1)
+print(r24)
+print(r5)
+print(r4)
+print(r12)
diff --git a/li/hw6.tex b/li/hw6.tex
index e0ff219..7acccb6 100644
--- a/li/hw6.tex
+++ b/li/hw6.tex
@@ -12,8 +12,12 @@ $$P = A(A^TA)^{-1}A^T = \bmatrix{1&1\cr 1&-1\cr -2&4}
\fr1{22}\bmatrix{9&4\cr4&3}\bmatrix{1&1&-2\cr1&-1&4}
= \fr1{22}\bmatrix{20&6&2\cr 6&4&-6\cr2&-6&20}.$$
-$$Pb = \fr1{22}\bmatrix{20&6&2\cr 6&4&-6\cr2&-6&20}\bmatrix{1\cr2\cr7}
-= \fr1{22}\bmatrix{46\cr-28\cr130}$$
+$$p = Pb = \fr1{22}\bmatrix{20&6&2\cr
+6&4&-6\cr2&-6&20}\bmatrix{1\cr2\cr7} =
+\fr1{22}\bmatrix{46\cr-28\cr130}$$
+With $b = p + q,$ and $p$ known, $q = b-p,$ and $q$ is in the left null
+space of $A$ by the definition of orthogonality with the column space
+which contains $p.$
\noindent{\bf 7.}
@@ -47,12 +51,12 @@ longer distance.
\noindent{\bf 16.}
-A is a $3\times2$ matrix, $Q$ is also a $3\times2$ matrix, and $R$ is a
-$2\times2$ matrix.
-
$$A = \bmatrix{1&1\cr2&3\cr2&1} = \bmatrix{1/3&0\cr
2/3&1/\sqrt2\cr2/3&-1/\sqrt2}\bmatrix{3&3\cr0&\sqrt2} = QR.$$
+Generally, $A$ is an $m\times n$ matrix, $Q$ is an $m\times r$ (where
+$r$ is the rank of $A$) matrix, and $R$ is an $r\times r$ matrix.
+
\noindent{\bf 17.}
$$Pb = QQ^Tb = \bmatrix{1/9&2/9&2/9\cr 2/9&17/18&-1/18\cr