# How to make a semicircle graph?

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

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.

• Sorry for the repeated extensive editing. I'm bumbling with the pieces, trying to get the shift and scale right. I think it's finally correct. – MPW Feb 11 '16 at 11:03
• And I edited it again. Gawd. This time I actually wrote it out on paper, so I know it's correct. – MPW Feb 11 '16 at 12:26
• Would the tangent be vertical when the semi circle touches the x-axis – Allan Henriques Apr 23 '19 at 21:24
• @AllanHenriques Yes it would – MPW Apr 24 '19 at 0:08

$f(x)=\sqrt{1-x^2}$ is a semicircle for $x\in [-1,1]$. Then simply shift this semicircle by $2$ to the right, and flip it over to get a second one, i.e.

$$f(x)=\begin{cases}\sqrt{1-x^2} & -1\leq x \leq 1\\ -\sqrt{1-(x-2)^2} & 1\leq x \leq 3\end{cases}$$

You can try something like $$f(x) = \begin{cases} \sqrt{1-(x-4t)^2} &\text{if 4t-1\le x\le 4t+1} \\ -\sqrt{1-(x-(4t+2))^2} &\text{if 4t+1\le x\le 4t+3} \\ \end{cases}$$ where $t\in\mathbb{Z}$.

• Would the tangent be vertical when the semi circle touches the x-axis – Allan Henriques Apr 23 '19 at 21:25
• The function is not differentiable in these points, so we cannot talk about a tangent line. – Marc Apr 30 '19 at 10:16
• Whether or not there is a vertical tangent is contingent on whether or not the derivative is permitted to take the value $\infty$. If $f$ is not permitted to take that value then the question is moot since we cannot talk about the derivative where it is not defined. If however $f$ can take that value, e.g. if we are using the projectively extended real line, $\mathbb{R}\cup\{\infty\}$ then indeed, $f$ would have a vertical tangent. – Jam Dec 6 '19 at 14:35