# How to draw a circle centered at the origin using a function?

To draw a curve, We use the function $$f(x) = x^2$$

But how do we draw a circle using a function and a parameter of r where r is the radius?

• Research polar coordinates ;) – gen-z ready to perish May 21 '18 at 21:27
• Traditionally function graphing is being taught using the x-value. You are ready to the next step where the "counter" is not present on the graph already. – Thorbjørn Ravn Andersen May 22 '18 at 8:16

The points on a circle with center at $(x_0, y_0)$ and radius $r$ fulfill the equation: $$(x - x_0)^2 + (y - y_0)^2 = r^2$$ If you solve this for $y$, you get $$y = y_0 \pm \sqrt{r^2 - (x - x_0)^2}$$ for the points in $(x_0 - r, x_0 + r)$ you have two candidates, on the uper or lower semi-circle, as expressed by the $\pm$ sign.

These are two different functions, as a function is not allowed to map an argument to more than one value.

Another option is a parametric plot \begin{align} x(t) = x_0 + r \cos t \\ y(t) = y_0 + r \sin t \end{align} for $t \in [0, 2\pi)$.

You can try this out here: link

The graph of a function in Cartesian (standard) coordinates, must pass the "vertical line test." Which a circle does not pass.

So you can say...

$x^2 + y^2 = r^2$ which is not a function because for every $x\in (-r,r)$ there are two $y$ values, which satisfy the equation.

Or you can create a function for a semi-circle.

$y = \sqrt {r^2-x^2}$ with the domain $-r\le x \le r$

and $y = -\sqrt {r^2-x^2}$ would be the other half of the semi-circle.

Another alternative is to define a parametric function.

$(x,y) =f(t) = (r\cos t, r\sin t)$

or even

$f(t) = (\frac {r^2 - t^2}{r^2 + t^2}, \frac {2rt}{r^2 + t^2})$

And the really cheap way out it to convert to polar coorinates.

$r(\theta) = R$

• Actually, for nearly every x, there are no values which satisfy the equation, unless you specify the domain of x. But yes, there are two values where y would be singular in value, and would have two values between those endpoints... – twalberg May 21 '18 at 20:48

For a circle centered at the origin, we can use the following

• implicit form $x^2+y^2=r^2$ (it's not a function)

• explicit form, by the functions $y=\sqrt{r^2-x^2}$ and $y=-\sqrt{r^2-x^2}$

For a circle centred at a point $(a,b)$ with radius of $r$, we use: $$(x-a)^2+(y-b)^2=r^2$$

Use this graph to see this more clearly - try changing $a,b,r$ yourself and see what happens to the circle.

At the origin, you can simply use $a=0,b=0$

Often people say that the plot of Dirichlet function $D(x)$ looks like two parallel lines. If you agree with that, you could use a function $$f(x) = (2D(x)-1)\sqrt{r^2 - x^2}$$ $D(x)$ is a function that equals $1$ when $x$ is rational and $0$ otherwise. Alternative way to write the same function: $$f(x) = \begin{cases} \sqrt{r^2-x^2}, & x \in \mathbb{Q} \\ -\sqrt{r^2-x^2}, & x \notin \mathbb{Q} \end{cases}$$ The plot of the $f$ therefore will consist of upper semicircle with rational horizontal coordinate and lower semicircle with irrational one. Since both rational and irrational numbers are dense in real line, you either say that this plot cannot be drawn at all or you draw it as a circle. At least my teacher at school used to draw $D(x)$ as a pair of lines, and that's the way it's usually represented in my experience.