0
$\begingroup$

Suppose a conic is given.I need to transform it to standard form.So i tried like this:

ClearAll[a, h, b, g, f, c]; a = Input[]; h = Input[]; b = Input[];
g = Input[]; f = Input[]; c = Input[]; 
conic[x_, y_] := 
 a*x^2 + 2*h*x*y + b*y^2 + 2*g*x + 2*f*y + c; \[CapitalDelta] = 
 a b c + 2 f g h - a f^2 - b g^2 - c h^2; 
nwconic[x_, y_, i_, j_] := a*x^2 + 2*h*x*y + b*y^2 + g*i + f*j + c;
nwconic[x, y, i, j] /. 
  Flatten[Solve[{D[conic[x, y], x] == 0, D[conic[x, y], y] == 0}, {x, 
     y}]];
\[Theta] = 1/2 ArcTan[(2 h)/(a - b)]; x1 = 
 x*Cos[\[Theta]] - y Sin[\[Theta]]; y1 = 
 x Sin[\[Theta]] + y Cos[\[Theta]];
Expand[nwconic[x, y] /. {x -> x2, y -> y2}]; If[\[CapitalDelta] == 0, 
 Print["The conic represent a pair of straight line"], 
 If[a b - h^2 == 0, Print["The conic represent a parabola"], 
  If[a b - h^2 < 0, Print["The conic represent a hyperbola"],
   If[a b - h^2 > 0, Print["The conic represent a ellipse"]]]]]

But i got error after a several update.But it seem my code is not correct.Can Anyone help me to figure out this. Any hints or solution will be appreciated.If possible then can anyone give hints to find focus and eccentricity.
Thanks in Advanced.

$\endgroup$
  • 2
    $\begingroup$ Please provide actual input values that allow us to reproduce the issues - I typed in some values, and no errors were generated. $\endgroup$ – Lukas Lang Jan 1 at 20:21
  • $\begingroup$ @Lukas Lang Sir when i input $a=8,h=2,b=5,g=-12,f=-12,c=0$ then it represent ellipse.That's fine but i need the standard form of $8x^2+4xy+5y^2-24x-24y=0$ to it's reduced standard form $4x^2+9y^2-36=0$.I use first degree and second degree term remove method.Although the code is showing error. $\endgroup$ – raihan hossain Jan 2 at 6:19
  • $\begingroup$ Even if I enter those numbers, I only get "The conic represents an ellipse" as output, without any errors. $\endgroup$ – Lukas Lang Jan 2 at 13:25
1
$\begingroup$

Here is one approach to get the desired transformation:

ClearAll[a, h, b, g, f, c];
conic[x_, y_] := a*x^2 + 2*h*x*y + b*y^2 + 2*g*x + 2*f*y + c;
sol = Solve[
     CoefficientList[
       conic @@ ({x0, y0} + RotationMatrix[θ].{x, y}),
       {x, y}
     ] == CoefficientList[
       a2 x^2 + b2 y^2 + c2,
       {x, y}
     ],
     {x0, y0, θ, a2, b2, c2}
   ] /. C[1] -> 0 // First // FullSimplify
(* <Long expressions...> *)

Inserting numbers then gives e.g.

sol /. {a -> 8, h -> 2, b -> 5, g -> -12, f -> -12, c -> 0}
(* {x0 -> 1, y0 -> 2, a2 -> 9, b2 -> 4, c2 -> -36, θ -> -π + ArcTan[1/2]} *)

The idea is that we demand the coefficients of our standard form to be equal to our rotated/translated conic via CoefficientList[…]==CoefficientList[…].

We then insert C[1]->0 into the solutions and select the first, since we don't care about rotations by multiples of $\frac\pi2$ (which is what the other solutions represent).

$\endgroup$
  • $\begingroup$ Thanks @Lukas Lang Sir..it need sometime for me to understand the code :) Is there any command that help me to find focus/eccentricity.Any hints will be appreciated.Thanks again SIr :) $\endgroup$ – raihan hossain Jan 2 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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