A Jupyter notebook cell is Python — but it doesn't have to look like Python. With an import hook you can rewrite the source of every cell before the interpreter sees it, which means the notation you use on paper can become real, executable code.
I've been building this out as Engineering DSL, a package that turns a notebook into something close to an engineer's worksheet. One import activates it:
from utils.Engineer import *
From then on, cells accept units, := assignment,
· multiplication, ‖ for parallel resistors,
√, superscript powers, and subscript indexing:
V_in := 12.0 V
R_top := 4.7 kΩ
R_bot := 10. kΩ
V_out := V_in · R_bot/(R_top + R_bot) # 8.2 V
R_eq := 100. Ω ‖ 220. Ω ‖ 470. Ω # parallel resistors
τ := 10. kΩ · 100. nF # → 1.0 ms, units simplify
hyp := √(30.cm² + 40.cm²) # → 50 cm
The trick is a source-transform hook (via
ideas)
that rewrites each cell before Python compiles it — no string parsing,
no magic cells. Units ride on
forallpeople,
so 12 V / 3 A really is 4 Ω and results
auto-scale their SI prefix. Numeric literals carry their significant
figures through arithmetic, matrices are live sympy objects with LaTeX
rendering, and plot() reads the units off the data to
label its own axes.
The repo includes notebook manuals and a gallery of one-cell examples —
electrical, mechanical, fluids, symbolic solving, radix and Roman-numeral
literals, even DKK currency conversion with live rates. If you write
calculations for a living, the difference between
V_out = V_in * R_bot / (R_top + R_bot) and the version
above is the difference between transcribing your work and just
writing it.
Code and notebooks: github.com/RichardThulstrup/engineering-dsl