# 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. – llllllllllllllllllllllllllllll 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 Swift but can be port to many other languages.)


func circle(p1: (x: Float,y: Float), p2: (x: Float,y: Float), p3: (x: Float,y: Float)) -> (r: Float, c: (x: Float,y: Float)) {
let x1 = p1.x
let x2 = p2.x
let x3 = p3.x
let y1 = p1.y
let y2 = p2.y
let y3 = p3.y

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

if mr == mt { return nil }

let x12 = x1 - x2;
let x13 = x1 - x3;

let y12 = y1 - y2;
let y13 = y1 - y3;

let y31 = y3 - y1;
let y21 = y2 - y1;

let x31 = x3 - x1;
let x21 = x2 - x1;

// x1^2 - x3^2
let sx13 = pow(x1, 2) -
pow(x3, 2);

// y1^2 - y3^2
let sy13 = pow(y1, 2) -
pow(y3, 2)

let sx21 = pow(x2, 2) -
pow(x1, 2)

let sy21 = pow(y2, 2) -
pow(y1, 2)

let f = ((sx13) * (x12)
+ (sy13) * (x12)
+ (sx21) * (x13)
+ (sy21) * (x13))
/ (2 * ((y31) * (x12) - (y21) * (x13)))
let g = ((sx13) * (y12)
+ (sy13) * (y12)
+ (sx21) * (y13)
+ (sy21) * (y13))
/ (2 * ((x31) * (y12) - (x21) * (y13)))

let c = -pow(x1, 2) - pow(y1, 2) -
2 * g * x1 - 2 * f * y1;

let h = -g;
let k = -f;
let sqr_of_r = h * h + k * k - c;

let r = sqrt(sqr_of_r)

return (r: r, center: (x: h, y: k))
}


• 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
• I noticed @Andris' point and fixed it. I didn't rotate but applied matrix solution instead. – Erk Ekin Jan 11 at 17:29

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