# Is there a better way to find the equation for finding the coordinates of the three vertices of a known triangle and its circumscribed circle?

Given the coordinates p1, p2, and p3 of the three vertices of a triangle, find the standard equation for the circumscribed circle of the triangle

ClearAll["*"]
p1 = {3, 5}
p2 = {6, 7}
p3 = {8, 9}
Cir = CircleThrough[{p1, p2, p3}]
(x - Cir[[1]][[1]])^2 + (y - Cir[[1]][[2]])^2 == (Cir[[-1]])^2


to kglr:

running you code I get the different result：

ClearAll["*"]
p1 = {3, 5}
p2 = {6, 7}
p3 = {8, 9}
Cir = Insphere[{p1, p2, p3}]
Apply[Total[({x, y} - #)^2] == #2^2 &]@Cir


Update: We can process Cir to get the desired equation:

Apply[Total[({x, y} - #)^2] == #2^2 &] @ Cir


RegionMember[Cir][{x, y}] /. _Element -> True


TeXForm @ %


$$\left(x+\frac{9}{2}\right)^2+\left(y-\frac{39}{2}\right)^2=\frac{533}{2}$$

\$Version


"13.1.0 for Linux x86 (64-bit) (June 16, 2022)"

• ClearAll["*"] p1 = {3, 5} p2 = {6, 7} p3 = {8, 9} Cir = CircleThrough[{p1, p2, p3}] eq1 = SubtractSides[ Simplify[RegionMember[Cir][{x, y}], {x, y} \[Element] Reals]] Solve[ForAll[{x, y}, Apply[Subtract, eq1] == (x - a)^2 + (y - b)^2 - r^2], {a, b, r}, Assumptions -> r > 0] (x - a)^2 + (y - b)^2 == r^2 /. % Commented Apr 24, 2023 at 10:33
• The results displayed after running are not the ones you mentioned above Commented Apr 24, 2023 at 11:02
• @csn899, can you post what result you get?
– kglr
Commented Apr 24, 2023 at 11:15
• could be version/os difference. I am using v13.1.0 in Linux
– kglr
Commented Apr 24, 2023 at 11:18
• @csn899, (1) the expression Cir has the form Circle[center, radius]. The region function for a circle is (x- center[[1]])^2 + (y - center[[2]])^2 == radius^2 which can be written as Total[(({x,y}-center)^2] == radius^2. (2) Apply[FOO]@BAR[x,y] replaces the head (BAR) of BAR[x,y] with FOO to give FOO[x,y].
– kglr
Commented Apr 25, 2023 at 21:15

You could use RegionConvert to do the work of finding the equation for you:

p1 = {3, 5}
p2 = {6, 7}
p3 = {8, 9}
Cir = CircleThrough[{p1, p2, p3}]
RegionConvert[Cir, "Implicit"]
(* ImplicitRegion[134+9x+x^2+y^2==39y,{x,y}] *)

• One can also use RegionMember[Cir, {x, y}] or such if RegionConvert is not available or fails (on current release it doesn't support non-constant regions). Commented Apr 24, 2023 at 13:07

Looks ok to me. But you can make it little more clear

ClearAll["Global*"]
p1 = {3, 5}
p2 = {6, 7}
p3 = {8, 9}
pts = {p1, p2, p3};
pol = Polygon[pts];
cir = CircleThrough[pts]
x0 = cir[[1, 1]];
y0 = cir[[1, 2]];
r = cir[[2]];
c = (x - x0)^2 + (y - y0)^2 == r^2
g1 = Graphics[{pol, Red, Point[pts]}, ImageSize -> 200];
g2 = Graphics[{{Thick, Dashed, Blue, cir},
{pol},
{Red, Point[pts]},
{Blue, PointSize[.03], Point[{x0, y0}]},
{Text[c, {x0, y0}, {.4, 2}]}
}, Axes -> True, ImageSize -> 300];
Grid[{{g1, g2}}, Frame -> All]

ClearAll["*"]
p1 = {3, 5};
p2 = {6, 7};
p3 = {8, 9};
sol = Solve[
r > 0 && (x - a)^2 + (y - b)^2 == r^2 /.
Thread[{x, y} -> #] & /@ {p1, p2, p3}, {a, b, r}];
eqn = (x - a)^2 + (y - b)^2 == r^2 /. sol[[1]]
eqn // Simplify


• ClearAll["*"] p1 = {3, 5} p2 = {6, 7} p3 = {8, 9} Cir = CircleThrough[{p1, p2, p3}] RegionConvert[Cir, "Implicit"] sol = Solve[ r > 0 && (x - a)^2 + (y - b)^2 == r^2 /. Thread[{x, y} -> #] & /@ {p1, p2, p3}, {a, b, r}] (x - a)^2 + (y - b)^2 == r^2 /. sol Commented Apr 24, 2023 at 10:23

It very much depends on what you mean by "better". Here's a version that uses a template, which is useful if you want fine-grained control, especially for presentation. I demonstrate this with HoldForm, which suppresses evaluation so you can see all three squared sub-parts).

CircleEquation[pts : {{_, _} ..}] :=
TemplateApply[
TemplateExpression[HoldForm[(\[FormalX] - TemplateSlot[1])^2 + (\[FormalY] - TemplateSlot[2])^2 == TemplateSlot[3]^2]],
FlattenAt[List @@ CircleThrough[pts], 1]];
CircleEquation[{p1, p2, p3}]


circle = (x - xc)^2 + (y - yc)^2 == r^2;
problem = Append[
(circle /. {x -> #1[[1]],
y -> #1[[2]]} & ) /@ {{3, 5}, {6, 7},
{8, 9}}, r >= 0];
circle /. Solve[problem]

{(9/2 + x)^2 + (-(39/2) + y)^2 == 533/2}
`