For AC analysis of circuits the following is handy:
using Plots
ZL(L) = f -> im*2π*f*L
ZC(C) = f -> 1/(im*2π*f*C)
ZR(R) = f -> R
series(a,b,c...) = f -> sum([x(f) for x in [[a,b]; [c...]]])
parallel(a,b,c...) = f -> 1/(sum([1/x(f) for x in [[a,b]; [c...]]]))
voltage_divider(top,bottom) = f -> bottom(f)/(top(f)+bottom(f))
# textbook example from p 157 of https://web.stanford.edu/class/archive/engr/engr40m.1178/reader/chapter7.pdf
G = voltage_divider(series(ZR(4.7e3),ZC(47e-9)), parallel(ZC(1e-9),ZR(2.2e3)))
plot([10^x for x in 1.9:0.001:7.1],f->20*log(abs(G(f))),leg=false,xscale=:log10)
This lets me write simple expressions for complicated circuit structures and avoid tons of algebra (see the referenced book for an example).
I’m curious if there is a name for this type of manipulation of functions with a common argument.
Thanks.