# Equation of a circle that touches a line and both x and y-axes

As shown in the graph below, a circle touches the $x$-axis, the $y$-axis and a line that has equation $y = x/2 +2$.

How to find the equation of the circle?

Thanks very much!

-
Are you sure that's the line $y=\frac{x}{2}$? – icurays1 Nov 13 '12 at 2:39
If I'm reading this correctly, and $y = \frac{1}{2}x$, then the line must pass through the origin. – amWhy Nov 13 '12 at 2:40
Oh sorry, I'll edit it – John Lee Nov 13 '12 at 2:40
Hint: the center of the circle is equidistant from both axis and from the line. – Sigur Nov 13 '12 at 2:45
yea, what should I do next? – John Lee Nov 13 '12 at 2:49

Just to throw out another method.

Let $(a,b)$ be the point of tangency between $y=\frac{1}{2}x+2$ and the circle. Since the radius from $(a,b)$ to $(r,r)$ is perpendicular to the line, we have $$\mbox{slope of the radius}=\frac{b-r}{a-r}=-2.$$ Together with $$b=\frac{1}{2}a+2$$ and $$(a-r)^2+(b-r)^2=r^2$$ we have three equations in three unknowns, so now it's all algebra. One approach is to get $a$ and $b$ in terms of $r$ from the first two equations, then plug in to the last (the circle) equation. You end up with a quadratic equation in $r$ which you can solve by completing the square or the quadratic formula.

-

Hint following on icurays1: Let $r$ be the radius of the circle. The equation of the circle is then $(x-r)^2+(y-r)^2=r^2$. The point of tangency on the $x$ axis is $(r,0)$. So the length of the tangent from the point on the $x$ axis where the line passes through is what? The other tangent is the same length, so you should be able to find its coordinates. Then plug those into the equation of the circle to find $r$.

-
Isn't the equation of the circle $(x \pm r)^2+(y \pm r)^2=r^2$? – Jacob Nov 13 '12 at 4:15
@Jacob: but if you want it in the first quadrant, you need the minus signs. You could also find a solution in the second quadrant, but that is not as shown in the graph. – Ross Millikan Nov 13 '12 at 4:17

Another approach can be based on getting the equation of the bisector of the angle at $(0,2)$ with one side going down the $y$ axis and the other along $y=2+x/2$.

One way to get this equation is to find the point $(p,q)$ on the line which is 2 units away from $(0,2)$ (and in the first quadrant), and then use that the angle bisector is the set of points equidistant from the two points $(0,0)$ and $(p,q)$.

The center of the circle then lies on the line $y=x$ and on the bisector, and can be found from these equations.

I found that $$(p,q)=(\frac{4 \sqrt{5}}{5},\frac{10+2 \sqrt{5}}{5}).$$

Then after doing the algebra (hopefully correctly) the radius came out $$\frac{8 \sqrt{5}+40}{12 \sqrt{5}+20}.$$ Can anyone confirm this value by other approaches?

EDIT: As Matthew Conroy pointed out, this answer simplifies to $-1+\sqrt{5}.$

-
I get the same value with a quite different method. Note your expression simplifies to $-1+\sqrt{5}$. – Matthew Conroy Nov 13 '12 at 7:18
Thanks! I didn't think of trying to simplify it, and I should have, via "multiply top, bottom by conjugate". – coffeemath Nov 13 '12 at 7:21

If you happen to know that the formula for the distance from a point $(p,q)$ to line $Ax+By+C=0$ is $|Ap+Bq+C|/\sqrt{A^2+B^2}$, then --writing your line equation as $x-2y+4=0$ and noting @Ross's observation that the center is $(r,r)$--- you just need to solve

$$r = \frac{|r-2r+4|}{\sqrt{1+4}} \qquad \text{that is,} \qquad r \sqrt{5} = |4-r|$$

Because the circle's point of tangency with the $y$ axis lies below the $y$-intercept of the line, we clearly have $r<2$, so that we can drop the absolute value on the right hand side; therefore,

$$r = \frac{4}{\sqrt{5}+1} = \frac{4(\sqrt{5}-1)}{5-1}=\sqrt{5}-1$$

But if you don't know the distance formula, here's yet another way to proceed: consider the point(s!) of intersection of the line with circles having the equation @Ross mentions, and then determine the magic value of $r$ that causes there to be just one point of intersection.

To do this, use the equation $x=2y-4$ to eliminate $x$ from @Ross's circle equation:

$$(2y-4-r)^2 + ( y - r)^2 = r^2 \qquad \implies \qquad 5 y^2 - 2y(8+3r) + 16 + 8 r + r^2=0$$

The quadratic equation in $y$ yields solutions of the form

$$y = \frac{2(8+3r)\pm \sqrt{D}}{2\cdot5}$$

where $D$ is the discriminant

$$D := 4(8+3r)^2-4\cdot5(16+8r+r^2)= 16\left(r^2+2r-4\right)$$

For $D>0$, there are two solutions; for $D<0$, there are (for our purposes) none. However, for $D=0$ there's precisely one solution, which corresponds to our point of tangency. So, all we have to do is make the discriminant disappear ... which means solving another quadratic

$$r^2+2r-4=0 \qquad \implies \qquad r = -1 \pm \sqrt{5}$$

and choosing the positive value for $r$.

-