So I came across this picture on Google+ and I wanted to understand further. I created an equation for the second wave, the one with the square. Here it is: $$y=\frac{\sin x}{\cos(\min(x \mod \pi/2, \pi/2- (x \mod \pi/2)))}$$
(The equation plotted on Wolfram Alpha.)
It's fine, but I feel like using mod and min is kind of nasty. Can anyone offer improvement to my equation and/or general insight towards further polygons?