A4 Python for engineers · Practice
Lab: numerical methods for circuits
Problems dealt one at a time, with new numbers every time. The kinds you miss come back more often, and you can keep going as long as you like.
Check
A resistor R = 220 Ω and a diode ( A, = 0.02585 V) are in series across Vs = 5 V. Write newton_v(v0, limit=None) from the first example, returning (v, steps). Set plain = newton_v(0.6), limited = newton_v(0.6, 2 * VT), and I to the diode current from the limited answer.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
A C = 10 µF capacitor charged to V0 = 5 V discharges through 1 kΩ. Integrate the power from 0 to with the trapezoid rule on n = 160 intervals, and set E_trap, E_exact (the exact integral over the same interval, ) and rel to the relative error.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Integrate from to with RK4 (tau = 1), starting with 5 steps and doubling the number until two successive answers differ by less than tol = 1 × 10⁻⁶. Set n to the final number of steps, v_end to that answer, and err to its true error against .
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
An RC ladder has R1 = 1000 Ω from a 1 V source to node 1, C1 = 47 nF from node 1 to ground, R2 = 1000 Ω from node 1 to node 2 and C2 = 22 nF from node 2 to ground. At f = 300 Hz, build the 2 × 2 complex nodal matrix (the source through R1 as a Norton current into node 1) and set v2 to the complex voltage at node 2. Then set formula to to compare.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
A square wave switching between 0 and V = 5 V with period T = 1 ms and 50% duty drives an RC with tau = 1 ms. Step it exactly, with the input, using 1000 steps per period, for 40 periods from 0 V. Over the last period, set vpp to the capacitor voltage's peak-to-peak, and exact to .
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
An RK4 simulation has an error of 5 × 10⁻⁶ with some step. What error should it have with the step 2 times smaller?
A kind of problem counts as solid once you've got it right on the first try twice in a row. Back to the lesson · Practice every topic in A4