Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

Batman curve in Julia, Jupyter notebook

Project: BATMAN CURVE
Views: 346
License: MIT
Kernel: Julia 1.1

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 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
Image in a Jupyter notebook