# Finding an equation of circle which passes through three points

How to find the equation of a circle which passes through these points $(5,10), (-5,0),(9,-6)$ using the formula $(x-q)^2 + (y-p)^2 = r^2$.

I know i need to use that formula but have no idea how to start, I have tried to start but don't think my answer is right.

• Can you share what you've tried, and explain what you're having trouble with? You have three data points, and three variables to solve for. – user61527 Jun 8 '14 at 17:48
• So far i have the following but it just doesn't seem to sit right with me as being correct Sqareroot[(9-5-5)^2 + (-6-0-10)^2] and that would be the radius – help Jun 8 '14 at 18:14

I know i need to use that formula but have no idea how to start

\begin{equation*} \left( x-q\right) ^{2}+\left( y-p\right) ^{2}=r^{2}\tag{0} \end{equation*}

A possible very elementary way is to use this formula thrice, one for each point. Since the circle passes through the point $(5,10)$, it satisfies $(0)$, i.e.

$$\left( 5-q\right) ^{2}+\left( 10-p\right) ^{2}=r^{2}\tag{1}$$

Similarly for the second point $(-5,0)$:

$$\left( -5-q\right) ^{2}+\left( 0-p\right) ^{2}=r^{2},\tag{2}$$

and for $(9,-6)$:

$$\left( 9-q\right) ^{2}+\left( -6-p\right) ^{2}=r^{2}.\tag{3}$$

We thus have the following system of three simultaneous equations and in the three unknowns $p,q,r$:

$$\begin{cases} \left( 5-q\right) ^{2}+\left( 10-p\right) ^{2}=r^{2} \\ \left( -5-q\right) ^{2}+p^{2}=r^{2} \\ \left( 9-q\right) ^{2}+\left( 6+p\right) ^{2}=r^{2} \end{cases}\tag{4}$$

To solve it, we can start by subtracting the second equation from the first

$$\begin{cases} \left( 5-q\right) ^{2}+\left( 10-p\right) ^{2}-\left( 5+q\right) ^{2}-p^{2}=0 \\ \left( 5+q\right) ^{2}+p^{2}=r^{2} \\ \left( 9-q\right) ^{2}+\left( 6+p\right) ^{2}=r^{2} \end{cases}$$

Expanding now the left hand side of the first equation we get a linear equation

$$\begin{cases} 100-20q-20p=0 \\ \left( 5+q\right) ^{2}+p^{2}=r^{2} \\ \left( 9-q\right) ^{2}+\left( 6+p\right) ^{2}=r^{2} \end{cases}$$

Solving the first equation for $q$ and substituting in the other equations, we get

$$\begin{cases} q=5-p \\ \left( 10-p\right) ^{2}+p^{2}-\left( 4+p\right) ^{2}-\left( 6+p\right) ^{2}=0 \\ \left( 4+p\right) ^{2}+\left( 6+p\right) ^{2}=r^{2} \end{cases}$$

If we simplify the second equation, it becomes a linear equation in $p$ only

$$\begin{cases} q=5-p \\ 48-40p=0 \\ \left( 4+p\right) ^{2}+\left( 6+p\right) ^{2}=r^{2} \end{cases}$$

We have reduced our quadratic system $(4)$ to two linear equations plus the equation for $r^2$. From the second equation we find $p=6/5$, which we substitute in the first and in the third equations to find $q=19/5$ and $r^2=1972/25$, i.e

$$\begin{cases} q=5-\frac{6}{5}=\frac{19}{5} \\ p=\frac{6}{5} \\ r^{2}=\left( 4+\frac{6}{5}\right) ^{2}+\left( 6+\frac{6}{5}\right) ^{2}= \frac{1972}{25}. \end{cases}\tag{5}$$

So the equation of the circle is

\begin{equation*} \left( x-\frac{19}{5}\right) ^{2}+\left( y-\frac{6}{5}\right) ^{2}=\frac{1972}{25}. \end{equation*}

Suppose the points are $A,B,C$. Then intersect the equations of perpendicular bisectors of $AB$ and $BC$. This is the center of the desired circle. (with your notation $(p,q)$)

Now calculate the distance between $(p,q)$ and $A$. Now $r$ is also found. $\begin{vmatrix} x^2+y^2&x&y&1\\ 5^2+10^2&5&10&1\\ (-5)^2+0^2&-5&0&1\\ 9^2+(-6)^2&9&-6&1\\ \end{vmatrix}= \begin{vmatrix} x^2+y^2&x&y&1\\ 125&5&10&1\\ 25&-5&0&1\\ 117&9&-6&1\\ \end{vmatrix} = 0$

• The simplest answer. – Paracosmiste Jun 8 '14 at 20:12
• what does it say ? – Fardad Pouran Jun 8 '14 at 21:00
• I don't get it? – Vrisk Oct 26 '17 at 13:59

This method that I wrote creates a circle object which has a radius and a centre point. (written in Objective-C but can be port to many other languages)

- (Circle*)findCirclePassingThroughPoint1:(CGPoint)point1 point2:(CGPoint)point2 point3:(CGPoint)point3{

double x1 = point1.x;  double x2 = point2.x;  double x3 = point3.x;
double y1 = point1.y;  double y2 = point2.y;  double y3 = point3.y;

double mr = (y2-y1) / (x2-x1);
double mt = (y3-y2) / (x3-x2);

if (mr == mt) {
return nil;
}

double x = (mr*mt*(y3-y1) + mr*(x2+x3) - mt*(x1+x2)) / (2*(mr-mt));
double y = (y1+y2)/2 - (x - (x1+x2)/2) / mr;

double radius = pow((pow((x2-x), 2) +  pow((y2-y), 2)), 0.5);
CGPoint center = CGPointMake(x, y);

Circle *circle = [[Circle alloc] initWithRadius:radius andCenter:center];
return circle;

}

• Are you sure that your solution covers all degenerate cases ? – ogerard May 5 '15 at 14:54
• Yes I am sure. If you encounter any, please let me know. – Erk Ekin Feb 9 '17 at 8:16
• If y2 = y1, then mr will be 0, and y will fail with division by 0. You need more checks to see if the points sit on one line, and to avoid false positives. The solution (if there is in the case of 3 given points) is to rotate them. – Andris Apr 14 '18 at 22:49
• Nice example! Works just fine. Aditional test are easy to include. In Java, you can use vecmath lib (javax.vecmath). – Alex Byrth May 2 '18 at 18:41

if the problem has a solution (the three points are on a circle) then you only need to calculate the equations of the two mediators and the intersection should be the center and the distance between one of the points and this center gives you r.

• Perhaps you could show how? At least show some guidelines. – user88595 Jun 8 '14 at 18:19
• This describes the Erk Ekin above implementation. – Alex Byrth May 2 '18 at 18:43