3
$\begingroup$

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.

$\endgroup$
4
  • $\begingroup$ Related: how-do-i-get-my-equation-to-have-the-form-x-a2-y-b2-z-c2-d-0 $\endgroup$
    – chyanog
    Commented Oct 30, 2020 at 2:14
  • 2
    $\begingroup$ Solve[CoefficientList[x^2+y^2+a x+b y+c-((x-A)^2+(y-B)^2+C),{x,y}]==0,{a,b,c}] $\endgroup$
    – chyanog
    Commented Oct 30, 2020 at 2:22
  • $\begingroup$ sol = Solve[ First@SolveAlways[(x - A)^2 + (y - B)^2 + C == x^2 + y^2 + a x + b y + c, {y, x}] /. Rule -> Equal, {A, B, C}] and then (x - A)^2 + (y - B)^2 + C /. First@sol $\endgroup$
    – Akku14
    Commented Oct 30, 2020 at 7:26
  • $\begingroup$ The simplest solution may be: Solve[ForAll[{x, y}, x^2 + y^2 + a x + b y + c == (x - A)^2 + (y - B)^2 + C], {A, B, C}] $\endgroup$ Commented Oct 31, 2020 at 9:24

3 Answers 3

2
$\begingroup$

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}}

$\endgroup$
1
  • $\begingroup$ @BobHanlon Thanks! $\endgroup$
    – cvgmt
    Commented Oct 30, 2020 at 2:12
1
$\begingroup$

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.

$\endgroup$
1
$\begingroup$

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
*)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.