3

I want Mathematica to put the circle given by $x^2+y^2+a x+b y+c=0$ into the standard form $(x-A)^2+(y-B)^2+C=0$, but I haven't been able to.

I tried:

Solve[
  CoefficientList[x^2 + y^2 + a x + b y + c = 0, x] == 
  CoefficientList[(x - A)^2 + (y - B)^2 + C = 0, 
  {x, y}]]

but it's wrong and I don't understand why.

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
Victoria
  • 45
  • 3

3 Answers3

2

Updated

sol = Solve[
  Thread[CoefficientList[x^2 + y^2 + a x + b y + c, {x, y}] == 
    CoefficientList[(x - A)^2 + (y - B)^2 + C, {x, y}]], {A, B, C}]

(* {{A -> -(a/2), B -> -(b/2), C -> 1/4 (-a^2 - b^2 + 4 c)}} *)

HoldForm[(x - A)^2 + (y - B)^2 + C==0] /. First@sol % // ReleaseHold

Original

Solve[Thread[
  CoefficientList[x^2 + y^2 + a x + b y + c, {x, y}] == 
   CoefficientList[(x - A)^2 + (y - B)^2 + C, {x, y}]], {a, b, c}]

{{a -> -2 A, b -> -2 B, c -> A^2 + B^2 + C}}

cvgmt
  • 72,231
  • 4
  • 75
  • 133
1

You have the right idea, but go wrong on the details.

rules =
  Solve[
    CoefficientList[x^2 + y^2 + a x + b y + c, {x, y}] == 
    CoefficientList[(x - A)^2 + (y - B)^2 + C, {x, y}], 
    {A, B, C}]
{{A -> -(a/2), B -> -(b/2), C -> 1/4 (-a^2 - b^2 + 4 c)}}

To show that this is correct transformation:

((x - A)^2 + (y - B)^2 + C == 0 /. rules)[[1]]// Simplify

c + a x + x^2 + b y + y^2 == 0

which is the original equation except that the terms are reordered in the way Mathematica prefers them.

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
1

This is a job for SolveAlways, but it does not choose from the desired parameters and the extra parameters just the ones desired. So we use the equivalent Solve[!Eliminate[!eqns,vars]] form, but with the Solve variables specified.

std = r2 + (x - x1)^2 + (y - y1)^2;
Solve[! Eliminate[! (c + a x + x^2 + b y + y^2 == std), {x, y}], {x1, y1, r2}]
std == 0 /. First[%]
(*
  {{x1 -> -(a/2), y1 -> -(b/2), r2 -> 1/4 (-a^2 - b^2 + 4 c)}}
  1/4 (-a^2 - b^2 + 4 c) + (a/2 + x)^2 + (b/2 + y)^2 == 0
*)
Michael E2
  • 235,386
  • 17
  • 334
  • 747