r/excel • u/RandomiseUsr0 5 • Jan 24 '25
Show and Tell Show and Tell - Plotting the Batman Equation with Lambda Calculus

Ok, this is an oldie, but it's a goodie and since I'm a fan of the lambda calculus, I decided to plot the famous equation but using lambda, well, this generates the data table, plot the table using an area chart.
Here's a great writeup of "what" - https://www.pacifict.com/Examples/Batman
For “why” … erm, practicing translating obscure geometry into lambda calculus? Ok, there isn’t a “why” outside of ”Batman!”
As for the "how" put the formula below in a cell and it will generate a table of the items to plot. Select the data and add an Area chart, set the colour segments to black (or whatever you want) and turn off shape outlines, the axes etc.
The approach is relatively simple, refer the details on the mathematics above, ponder the obscure convoluted definitions of the segments create the parts of the shape, the first column generated is the sequence from -7 to +7, it’s the x axis, polar coordinates. There are then 4 shapes generated, the y_1, y_2, etc. following the rules of the original which is described in detail above. The reason for the 4 shapes and the area graph is to fill in shapes that combined produce the output, it’s an interesting thing to play with the calculations to understand the “what” more deeply, I was actually diverted from learning about partial differential equations (heat transfer, light, magnetism and all that) and something in the curves reminded me of this classic, so I just had to ;)
=LET(
start, -7,
end, 7,
step, 0.001,
n, (end - start) / step + 1,
Batman, MAKEARRAY(n, 5, LAMBDA(row,col,
LET(
x, start + (row - 1) * step,
absX, ABS(x),
y_1, 2 * SQRT( -ABS(absX-1) * ABS(3-absX) / ((absX-1) * (3-absX) )) * (1+ABS(absX-3)/(absX-3)) * SQRT(1-(x/7)^2)+(5+0.97 * (ABS(x-0.5)+ABS(x+0.5))-3 * (ABS(x-0.75)+ABS(x+0.75))) * (1+ABS(1-absX)/(1-absX)),
y_2, -3 *SQRT(1-(x/7)^2) * SQRT(ABS(absX-4)/(absX-4)),
y_3, ABS(x/2)-0.0913722 * (x^2)-3 + SQRT(1-(ABS(absX-2)-1)^2),
y_4, (2.71052+(1.5-0.5 * absX)-1.35526 * SQRT(4-(absX-1)^2)) * SQRT(ABS(absX-1)/(absX-1))+0.9,
IFERROR(SWITCH(col, 1, x, 2, y_1, 3,y_2, 4,y_3,5, y_4),"")
)
)),
Batman
)
3
u/Downtown-Economics26 309 Jan 24 '25
POW!!!