I am looking for a closed-form formula for something like this:
Can anybody help - Thank you!
I am looking for a closed-form formula for something like this:
Can anybody help - Thank you!
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]
>
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 09 '11 at 15:32
I have come up with an equation, which can be found at this desmos calculator I made. I derived this equation from $\arcsin(\sin(x))$ giving a zig-zag, and $\sqrt{-x^2+1}$ giving semicircles, then multiplied by the sign of cosine wave to invert every other semicircle. $n$ is the horizontal shift, $r$ is the radius.
the full form of the equation is as follows, with $n$ being the horizontal shift, and $r$ being the radius: $$f\left(x\right)=r\sqrt{-\left(\frac{2\arcsin\left(\sin\left(\frac{\pi x}{2r}+n\pi\right)\right)}{\pi}\right)^{2}+1}\cdot\operatorname{sign}\left(\cos\left(\frac{\pi x}{2r}+n\pi\right)\right)$$
a good approximation is
y = |sin x|^(sin x) + 11/7 sin x
here is my research. I took a sine wave and circles and plotted the difference in their y values then made an equation that roughly matched it, then added sin x to that.