A440 of 56
0 XP
  1. Hook
  2. Problems

A4 · Problem set 9

Problem set 9: complex numbers, equations and calculus in code

These labs use lessons 36 to 39: complex numbers in code, solving equations numerically, building circuit equations, and numerical derivatives and integrals. Each one checks a numerical answer against one you can work out by hand, which is the habit that catches most bugs. When a check fails, the hidden test's message says which case went wrong.

Check

For a series RLC with R = 50 Ω, L = 10 mH and C = 0.1 µF, set f to 20,001 frequencies spaced evenly in log⁡f from 10 Hz to 1 MHz (np.logspace), Z to the complex impedances there, f_min to the frequency where |Z| is smallest, and f0 to 1/(2πLC).

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

An RC low-pass (R = 1 kΩ, C = 10 nF) shifts the phase by −arctan⁡(2πfRC). Write bisect(g, a, b) (60 halvings), use it to set f to the frequency where the phase is −80°, and set f_formula to the exact answer from tan⁡.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

A sine v=sin⁡(2πft) with f = 200 Hz is sampled with step h. Write central(v, h) returning the central-difference derivative at the interior samples, (v[2:] - v[:-2]) / (2*h). Set err1 and err2 to the largest error against the exact derivative with 100 and 200 samples per cycle, and ratio = err1 / err2.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

A half-wave rectified sine is v=max⁡(Vpsin⁡θ,0). Over one cycle, sampled at 10,001 points from 0 to 2π, set rms_num to its RMS by the trapezoid rule (written with slices), rms_exact to Vp/2, and avg to its average value by the same rule.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

A series RLC circuit with R = 100 Ω, L = 10 mH and C = 1 µF has the characteristic polynomial s2+(R/L)s+1/(LC). Set roots to its roots with np.roots, kind to "under", "critical" or "over" (underdamped if the roots are complex), and zeta to R2C/L.

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

8 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.