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

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 upper 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$

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}$