Skip to content

Instantly share code, notes, and snippets.

@tk3369
Created November 17, 2019 09:25
Show Gist options
  • Save tk3369/cadce6423d2103438ae84414aeb1b95d to your computer and use it in GitHub Desktop.
Save tk3369/cadce6423d2103438ae84414aeb1b95d to your computer and use it in GitHub Desktop.
plotting the batman equation
using Plots
function batman(; lw = 4)
let sqrt = x -> x > 0 ? Base.sqrt(x) : NaN
v1(x) = 2*sqrt(-abs(abs(x)-1)*abs(3-abs(x))/((abs(x)-1)*(3-abs(x)))) * (1+abs(abs(x)-3)/(abs(x)-3)) * sqrt(1-(x/7)^2)+(5+0.97(abs(x-.5)+abs(x+.5))-3(abs(x-.75)+abs(x+.75))) * (1+abs(1-abs(x))/(1-abs(x)))
v2(x) = (2.71052 + 1.5 - 0.5 * abs(x) - 1.35526 * sqrt(4-(abs(x)-1)^2)) * sqrt(abs(abs(x)-1)/(abs(x)-1)) + 0.9
v3(x) = (-3)*sqrt(1-(x/7)^2)*sqrt(abs(abs(x)-4)/(abs(x)-4))
v4(x) = abs(x/2)-0.0913722*x^2-3+sqrt(1-(abs(abs(x)-2)-1)^2)
x = -8:0.0005:8
c = :blue
plot(x, v1.(x), linewidth = lw, color = c,
aspect_ratio = 9/10, legend = false, title = "Batman!",
#showaxis = false,
#lims = (-4, 4), # x-axis limits only
gridalpha = 0.0)
plot!(x, v2.(x), linewidth = lw, color = c)
plot!(x, v3.(x), linewidth = lw, color = c)
plot!(x, v4.(x), linewidth = lw, color = c)
end
end
batman()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment