[Math] How to make a semicircle graph

circlesgraphing-functionstrigonometry

What is the formula to make a semicircle graph that is continuous? By continuous I mean like a sine or cos graph but shaped like semicircles one after the other. Thanks

Best Answer

I believe the function $f:\mathbb R\to\mathbb R$ with

$$f(x)=(-1)^{\lfloor x/2\rfloor} \sqrt{1-(x-2\lfloor x/2\rfloor -1)^2}$$

will do the trick. Here $\lfloor x\rfloor$ denotes the greatest integer less than or equal to $x$.

Explanation:

(1) The semicircle: An equation for the circle of radius $r$ centered at $(a,b)$ is $(x-a)^2+(y-b)^2=r^2$, so the graph of the function $s:[0,2]\to\mathbb R$ with $$s(x) = \sqrt{1-(x-1)^2}$$ is the upper semicircle of radius $1$ centered at $(1,0)$ (to see this, solve the first equation for $y$ with $y\geq 0$ and put $a=1,b=0,r=1$).

(2) The periodicity: If $\lfloor x\rfloor$ denotes the greatest integer less than or equal to $x$, then $\lfloor x\rfloor \leq x <\lfloor x\rfloor + 1 $, so $0\leq x- \lfloor x\rfloor <1$ (the expression $x- \lfloor x\rfloor$ is often called the fractional part of $x$). The graph of the function $p:\mathbb R\to\mathbb R$ with $p(x) = x- \lfloor x\rfloor$ looks like a sawtooth wave. It coincides with the graph of $y=x$ on $[0,1)$ and is periodic with period $1$. So the graph of the equation $y/2 = p(x/2)$, which can be written $y=2p(x/2)$ looks similar but is scaled out by a factor of $2$ both horizontally and vertically; it coincides with the line $y=x$ on $[0,2)$ and is periodic with period $2$. Note that $$2p(x/2)=2(x/2-\lfloor x/2\rfloor) = x-2\lfloor x/2\rfloor$$

(3) Combining them: Now $2p(x/2)$ has the effect of mapping each interval $[2n, 2n+2)$ monotonically onto $[0,2)$, so we see that plugging this into $s$ gives a function $g:\mathbb R\to\mathbb R$ whose graph is a collection of semicircles over each interval $[2n,2n+2)$; we have

$$g(x) = s(2p(x/2)) = \sqrt{1-(2p(x/2)-1)^2}=\sqrt{1-(x-2\lfloor x/2\rfloor-1)^2}$$

(4) Flipping: Finally, note that the expression $(-1)^{\lfloor x/2\rfloor}$ alternates between $1$ and $-1$ on successive intervals $[2n,2n+2)$, so the function $f(x) = (-1)^{\lfloor x/2\rfloor}g(x)$ is what you want: $$f(x)=(-1)^{\lfloor x/2\rfloor}\sqrt{1-(x-2\lfloor x/2\rfloor-1)^2}$$

The factor $(-1)^{\lfloor x/2\rfloor}$ has the effect of flipping every other upper semicircle on the graph of $g$ to a "lower" semicircle for the graph of $f$, as desired.

Related Question