CoCalc Public FilesPublic / batman-curve.sagews
Author: Hal Snyder
Views : 107
Compute Environment: Ubuntu 18.04 (Deprecated)
%md

# Batman Curve in a Sage worksheet

Math from Figure 2 in SIAM News: [Julia: A Fast Language for Numerical Computing](https://sinews.siam.org/Details-Page/julia-a-fast-language-for-numerical-computing-1)

- @AlgebraFact: [Drawing Batman with parabolas](https://twitter.com/AlgebraFact/status/923232882822348801)



# Batman Curve in a Sage worksheet

Math from Figure 2 in SIAM News: Julia: A Fast Language for Numerical Computing

sf(x) = sqrt(1-x^2)                           # semicircle
ef(x) = 3*sf(x/7)                             # ellipse
sh(x) = 4.2 - .5*x -2.8*sf(.5*x -.5)          # shoulders
bf(x) = sf(abs(2 - x) - 1) - x^2/11 + .5*x -3 # bottom
cl    = [(0,1.7), (.5,1.7), (.8,2.6), (1,.9)] # cowl right
cl2   = [(-x,y) for (x,y) in cl]              # cowl left

def p(f,xmin,xmax):
"symmetric plot across y-axis"
p1 = plot(f,xmin,xmax)
p2 = plot(lambda x:f(-x),-xmax,-xmin)
return p1 + p2

p(ef,3,7) + p(-ef,4,7) + p(sh,1,3) + p(bf,0,4) + line(cl) +line(cl2)