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

2.5k Views Asked by At

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

a Curved Shape

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

5

There are 5 best solutions below

0
On BEST ANSWER

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.

enter image description here

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

0
On

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

1
On

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$

0
On

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$

0
On

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.