# Function for concatenated semicircles

I am looking for a closed-form formula for something like this:

Can anybody help - Thank you!

-
And I'm assuming you don't want the closed form in terms of a piecewise definition. – jspecter Jun 9 '11 at 14:51
Have you tried to use the Fourier transform? Or would you object to the resulting infinite sums? – t.b. Jun 9 '11 at 14:59
@jspecter: No, please no piecewise def. @Theo: Infinite sums are ok, I think even necessary for the nearly perpendicular inflection points (=infinite slope). – vonjd Jun 9 '11 at 15:04
Almost: $\sqrt{1 - \bigg(\frac{2}{\pi}\sin^{-1}\Big(\cos\big(\frac{\pi}{2}x\big)\Big)\bigg)^2}$, WolframAlpha plot – Rahul Jun 9 '11 at 15:12
Just curious: Why do you want to avoid a piecewise definition? – Jonas Teuwen Aug 7 '11 at 13:43

This works (for circles of radius $r$):

$$f(x)=(-1)^{\displaystyle\left\lfloor \frac{x}{2r}+\frac{1}{2}\right\rfloor}\sqrt{r^2-\left(x-2r\left\lfloor\frac{x}{2r}+\frac{1}{2}\right\rfloor\right)^2}$$

Image for $r=1$:

Mathematica code:

r = 1; Plot[(-1)^Floor[x/(2r) + 0.5] Sqrt[r^2 - (x - (2r)Floor[x/(2r) + 0.5])^2],
{x, -3, 3}, AspectRatio -> 1/3]

-
@Zev: I don't know how to fix this, but I think it goes into the right direction. Floor func is ok. – vonjd Jun 9 '11 at 15:15
WA-plot: wolframalpha.com/input/?i=Plot+%28-1%29^%28Floor%5B%28x%2F2+%2B+0.5%2‌​9%5D%29+Sqrt%5B1+-+%28x+-+2+Floor%5Bx%2F2+%2B+0.5%5D%29^2%5D - How did you find it? – vonjd Jun 9 '11 at 15:24
@vonjd: I figured we needed a $(-1)^{\text{something}}$ to get the flipping about the $x$-axis, figured out what the something was based on the period we needed, and then used the subtracting-the-floor-function trick to shift each segment $[r(2n-1),r(2n+1)]$ of the $x$-axis down to the $[-r,r]$ segment, then used the formula for the (upper half of a) circle on the segment $[-r,r]$. – Zev Chonoles Jun 9 '11 at 15:28
(in general, $a\lfloor\frac{b}{a}\rfloor$ is the largest multiple of $a$ less than $b$, so subtracting it from $b$ gives the "remainder") – Zev Chonoles Jun 9 '11 at 15:30
Zev: If you use four blank spaces as indentation instead of the > then you get a code block, which makes your code a bit easier to read because a monospace font is used. (you need to do the line breaks manually to avoid a scroll bar) – t.b. Jun 9 '11 at 15:32