Sharedbatman-curve.ipynbOpen in CoCalc
Authors: Hal Snyder, ℏal Snyder
Views : 70
License: MIT License
Description: 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

In [1]:
# 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];
In [2]:
# the first time in a project, it can take over a minute to precompile PyPlot using PyPlot
In [3]:
# plot symmetrically across y-axis o(x,f) = plot(-x,f(x), color="black") , plot(x,f(x), color="black") p(x,f) = o(x,t->f.(t)) # broadcast must be explicit 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 o([0,.5,.8,1],c); # cowl is piecewise linear
In [ ]: