The distance from a moving point in the plane to (0,0) is lambda times the distance from (a, 0). And lambda is not equal to 1. Find the equation
Clear["Global`*"]
expr = EuclideanDistance[{0, 0}, {x,
y}] == \[Lambda] EuclideanDistance[{a, 0}, {x, y}]
eqn = Assuming[Element[{x, y, a, \[Lambda]}, Reals], Simplify[expr]]
ApplySides[#^2 &, eqn]
eq = ApplySides[#^2 &, eqn] // Simplify
CompleteTheSquare::notquad =
"The expression is not quadratic in the variables `1`";
CompleteTheSquare[expr_] := CompleteTheSquare[expr, Variables[expr]]
CompleteTheSquare[expr_, Vars_Symbol] :=
CompleteTheSquare[expr, {Vars}]
CompleteTheSquare[expr_, Vars : {__Symbol}] :=
Module[{array, A, B, C, s, vars, sVars},
vars = Intersection[Vars, Variables[expr]];
Check[array = CoefficientArrays[expr, vars], Return[expr],
CoefficientArrays::poly];
If[Length[array] != 3, Message[CompleteTheSquare::notquad, vars];
Return[expr]];
{C, B, A} = array; A = Symmetrize[A];
s = Simplify[1/2 Inverse[A] . B, Trig -> False];
sVars = Hold /@ (vars + s); A = Map[Hold, A, {2}];
Expand[A . sVars . sVars] + Simplify[C - s . A . s, Trig -> False] //
ReleaseHold]
eq /. Equal -> Subtract
CompleteTheSquare[eq /. Equal -> Subtract, {x, y}]
ApplySides[#/Coefficient[%, y^2] &, % == 0]
Assuming[Element[{x, y, a, \[Lambda]}, Reals], Simplify[%]]
CompleteTheSquare[% /. Equal -> Subtract, {x, y}]
% == 0
get the result:
y^2 - (a^2 \[Lambda]^2)/(-1 + \[Lambda]^2)^2 + (x - (
a \[Lambda]^2)/(-1 + \[Lambda]^2))^2 == 0
How to optimize the code and finally get this result?
y^2 + (x - (a \[Lambda]^2)/(-1 + \[Lambda]^2))^2 == (
a^2 \[Lambda]^2)/(-1 + \[Lambda]^2)^2