A4 · Problem set 12
Problem set 12: longer labs
Longer labs that combine the whole course: functions and data structures, arrays, complex numbers, root finding, simulation, statistics and the FFT. Each uses your own values. Plan each one on paper before you write code.
Check
Find the RC low-pass filter's −3 dB frequency numerically: write the magnitude in dB as a function of f, and use bisection between 1 Hz and 10 MHz to find where it equals −3.0103 dB. Set f3. (Check it against .)
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
An inductor current builds up as . Simulate it with Euler's method from 0 A, with a step of for 500 steps, store the currents in i (501 values), and set err to the largest difference from the exact .
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
A capacitor discharges through an unknown resistor. The arrays t (s) and v (V) are noisy readings, and C is known. Fit the time constant from against , then set R_fit to the resistance.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
For a series RLC with R = 1000 Ω, C = 10 nF and L = 47 mH, compute the voltage across the capacitor for a 1 V input as a complex transfer function over 400 log-spaced frequencies from 100 Hz to 1 MHz. Set f_peak to the frequency of the largest gain on that grid, gain_peak to the gain there, and Q to the theoretical .
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
A mains current is a fundamental at f1 = 50 Hz (amplitude 1 A) plus a harmonic h = 3 times higher with amplitude a = 0.2 A, sampled at 12 kHz for exactly 10 cycles of the fundamental. From the FFT, set I1 and Ih to the two amplitudes, thd to the total harmonic distortion , and irms to the RMS current computed from the samples.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
The starter's netlist is a list of (name, a, b, ohms) resistors with a 1 A current source into node "1" (returning through ground "0"). Build the nodal conductance matrix for the non-ground nodes (sorted by name) and set v to a dictionary from node to voltage, using np.linalg.solve.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
A diode with A and = 0.02585 V is driven from V = 5 V through a resistor; sweep the resistor over 100 log-spaced values from 100 Ω to 100 kΩ. For each, find the diode voltage by bisection (to 1e-12 V) and set vd to the array of diode voltages. Then fit against with np.polyfit and set VT_fit from the slope. (Rs = 1 is not used; it's there to vary your numbers.)
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Have paper and a calculator ready. Work each problem out by hand, then enter the answer. Your first try on each one counts toward your score.
Practice
Keep practicing
7 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.