Sharedbatman-curve.ipynbOpen in CoCalc
Batman curve in Julia, Jupyter notebook

Batman Curve

Transcribed from Julia: A Fast Language for Numerical Computing, by Alan Edelman,
SIAM News, Volume 49 | Number 02 | March 2016

# bat functions: semicircle, ellipse, shoulders, bottom, cowl
# harmless Compat.UTF8String warnings from julia kernel on first run
σ(x) = sqrt.(1-x.^2)
e(x) = 3σ(x/7)
s(x) = 4.2 - .5x - 2.8σ(.5x-.5)
b(x) = σ(abs.(2-x)-1)-x.^2/11 + .5x - 3
c(x) = [1.7, 1.7, 2.6, .9];
# the first time in a project, it can take over a minute to precompile PyPlot
using PyPlot
# plot symmetrically across y-axis
#p(x,f) = plot([-x,0,x],[f(x),NaN,f(x)])
p(x,f) = plot(-x,f(x), color="black") , plot(x,f(x), color="black")
p((3:.1:7),e);p(4:.1:7,t->-e(t))   # ellipse
p(1:.1:3,s);p(0:.1:4,b)            # shoulders and bottom
p([0,.5,.8,1],c);                  # cowl is piecewise linear