1

I have an application where I work with conic sections in the form

$$A x^{2} + B x y + C y^{2} + D x + E y + F = 0$$

In case a hyperbola, a straightforward way calculate its center, as I understand is

$$x_c = \frac{B E-2 C D}{4 A C -B^2}$$ $$y_c = \frac{B D-2 A E}{4 A C -B^2}$$

It had been working fine until recently, when I came across the following situation where the coefficients of the above curve are

A = -0.3309241482403108
B = -0.39325536339874551
C = -0.11618424089196536
D = 0.98578834911406965
E = -0.5076292198791521
F = 8.264829655812191

This is a hyperbola where the center, as calculated by the above equation, is at (-500.1698135428269, 844.291924015812)

Curve(red) and calculated center(black)

As can be seen from the graph, this center is clearly wrong. More specifically, the $y$ coordinate of the center is way off and I don't really understand why. As far as I know, there are no conditions in the use of above equation for ellipses and hyperbolas. Can someone please explain to me what I am missing here?

Gaurav
  • 45
  • @JeanMarie Can you elaborate a little on that? Or do you have a link to the derivation of that? – Gaurav Sep 16 '21 at 11:18
  • Sorry, I had made an error: Your formulas (that can be obtained by annihilating the partial derivatives) are exact. – Jean Marie Sep 16 '21 at 11:19

1 Answers1

1

The hyperbola with center at $(h,k)$ is given by $$ \frac{(x - h)^2}{a^2} + \frac{(x - h) (y - k)}{c^2} + \frac{(y - k)^2}{b^2} = 1 $$

which can be re-written as

$$c^2b^2(x^2-2xh+h^2)+a^2b^2(xy-xk-hy+kh)+a^2c^2(y^2-2yk+k^2)-a^2b^2c^2=0$$

$$\implies c^2b^2x^2+a^2b^2xy+a^2c^2y^2+(-2hc^2b^2-ka^2b^2)x+(-ha^2b^2-2ka^2c^2)y+\left(h^2c^2b^2+kha^2b^2+k^2a^2c^2-a^2b^2c^2\right)=0$$

Then comparing with $$A x^{2} + B x y + C y^{2} + D x + E y + F = 0$$

gives $$D=-2hA-kB$$ $$E=-hB-2kC$$

and solving gives the center of the hyperbola to be

$$h = \frac{B E-2 C D}{4 A C -B^2}$$ $$k = \frac{B D-2 A E}{4 A C -B^2}$$


Your plot is not correct. Firstly you obtained the center to be $(500.1698135428269, 844.291924015812)$, but in the plot it looks like it's $(\color{red}{-}500.1698135428269, 844.291924015812)$, which is the correct center. Substituting the given values of $A,B,C,D,E$ and $F$ and plotting on Desmos, with centre $(h,k)\approx (-500.17,844.29)$, gives

enter image description here

Alessio K
  • 10,599
  • That was a typo. Sorry about that. The center I calculated was also (−500.1698135428269,844.291924015812). But I definitly do not get your plot. I did mine on python, but I doubt that would make any difference. I'll check my code again and see if I missed something. – Gaurav Sep 16 '21 at 12:09
  • Ok, it seemed like a typo. Try to plot it for two decimal places for instance. – Alessio K Sep 16 '21 at 12:10
  • Ah, yes. You are correct! I had 2 completely separate bugs in my code. One that made the plot incorrect. And the second one in calculation of the priniciple axis slope. And due to an insane coincidence, the incorrect slope (about 30 degree angle) is really close to the incorrectly plot hyperbola. This was making me question my math! Sorry for the trouble and thank you for the help. I needed to know if some edgecase was missing in my calculation. – Gaurav Sep 16 '21 at 12:54
  • You're very welcome! :-) – Alessio K Sep 16 '21 at 12:55
  • 2
    @Äres The coordinates of the center of the hyperbola can be obtained in a more direct way by solving the system $\partial f/\partial x=0, \partial f/\partial y=0$, where $f(x,y)=A x^{2} + B x y + C y^{2} + D x + E y + F $ – Jean Marie Sep 16 '21 at 19:07
  • @Jean Marie Thanks for the comment, yes indeed. Provided the determinant is non-zero then we can find a unique solution. I started from the equation of the hyperbola. – Alessio K Sep 16 '21 at 19:16
  • Whatever the method, it is "provided $4AC-B^2 \ne 0$... – Jean Marie Sep 16 '21 at 19:20