3

I'm trying to find the equation of a line that passes through some point $(x_1,y_1)$ and lies tangent to an ellipse. There are two solutions in most cases. My work starts with the equation of a line $y-y_1 = m(x-x_1)$. The slope of the line, $m$, will be $$\frac{y_1 - f(x)}{x_1-x} = f'(x)$$Normally I could substitute the equation of the curve in for $f(x)$ and $f'(x)$ and after some sweat, tears and algebra, solve for $x$, which can then easily be used to solve for all other information I need.

However, ellipses are a pain to work with, especially in $f(x)=$ form, which I would need to use for this method. Even using wolfram alpha, the general solution for x is so extremely long and complicated that it's basically useless to me.

Ellipses can be much more simply expressed in parametric form, so I tried the same approach using parametric equations $y(t)$ and $x(t)$, but I ended up with $t \sin t = \cdots$ which isn't solvable conventionally and ended up being equally as useless.

My final idea was set the equation of the line equal to the ellipse. $$m(x-x_1) + y_1 = \sqrt{b^2 \left( 1-\frac{(x-h)^2}{a^2} \right)}+k$$The tangent line touches the ellipse, not intersects it, in other words it only has one point of equality with the ellipse. So I would somehow need to find the two values of $m$ that gives one point of equality instead of two, also a potentially painful and time-consuming process which I don't know how to do. Is there a better way to solve this? If this last method is the most viable solution, how would I go about this?

Ryan
  • 1,200
  • Get the equation for the intersection point of line and ellipse and use the condition that there is only one solution. – Moti May 09 '17 at 20:12
  • Implicit differentiation gives you the equation of a tangent at each point of the ellipse. I.e. for ${x^2 \over a^2} + {y^2 \over b^2}=0$, the tangents have equation ${2xx_0 \over a^2}+ {2yy_0 \over b^2}=0$ – N74 May 09 '17 at 22:19
  • I’d start by not working with slopes. What are you going to do when one of the tangents is vertical? – amd May 09 '17 at 22:52
  • @N74 That equation for the tangent line doesn’t look quite right: $(0,0)$ satisfies it. – amd May 10 '17 at 00:33
  • @amd you're right, I misspell the equation of the ellipse. When the equation is $b^2x^2+a^2y^2=a^2b^2$, the equation of the tangent at a point of the ellipse is $b^2xx_0+a^2yy_0=a^2b^2$. – N74 May 10 '17 at 00:46

3 Answers3

2

Projective geometry to the rescue. Projective geometry uses homogeneous coordinates for points, lines and conic sections.

Theory

  • A point has coordinates ${\bf P}=(p_1,p_2,p_3)$ that indicate a cartesian location $(\frac{p_1}{p_3}, \frac{p_2}{p_3})$. Any scalar multiple of the coordinates describe the same location.

  • A line has coordinates ${\bf L} = (l_1,l_2,l_3)$ that describe the equation $l_1 x + l_2 y + l_3 = 0$. Any scalar multiple of the coordinates describe the same line.

  • A line passes through a point if ${\bf L} \cdot {\bf P} =0$, where $\cdot$ is the inner product.

  • The line between two points is ${\bf L} = {\bf P}_1 \times {\bf P}_2$, where $\times$ is the vector cross product

  • The point joining two lines is ${\bf P} = {\bf L}_1 \times {\bf L}_2$.

  • A conic section such as an ellipse has coordinates ${\rm C} = \begin{vmatrix} c_{11} & c_{12} & c_{13} \\ c_{12} & c_{22} & c_{23} \\ c_{13} & c_{23} & c_{33} \end{vmatrix}$ such that the equation of the curve is ${\bf P} \cdot {\rm C} {\bf P} = 0$.

  • The line ${\bf L} = {\rm C} {\bf P}$ is the line than connects the two tangents points of the point P to the curve C.

  • Any point ${\bf Q}$ that is on this line (${\bf Q} \cdot {\rm C} {\bf P}=0$) also defines another line ${\bf M} = {\rm C}{\bf Q}$ that is guaranteed to cross the original point ${\bf P} \cdot {\rm C}{\bf Q}=0$.

Strategy

  • Another way of saying the above is that ${\rm C}{\bf Q}$ and ${\bf Q} \times {\bf P}$ describe the same line ${\bf M}$. The the equation we need to solve to find the tangent points ${\bf Q} = (q_x,q_y,1)$ is $$ {\rm C}{\bf Q} = \lambda \left( {\bf Q} \times {\bf P} \right) $$

The above is 3 non-linear equations to be solved for the 3 unknowns $q_x$, $q_y$ and the scalar multiplier $\lambda$. The strategy I used was to solve the first two for $q_x$ and $q_y$ in terms of $\lambda$. Substitute these two values into the last equation to get an equation it terms of $\lambda$ only. The last equation is solved for two values of $\lambda$ which are $\pm$ of each other. Back substitute these two solutions into $(q_x,q_y)$ to get the coordinates of the tangent points.

Example

  • An ellipse with coordinates ${\rm C} = \begin{vmatrix} \frac{1}{4} & -\frac{1}{10} & \frac{1}{2} \\ -\frac{1}{10} & \frac{1}{6} & - \frac{1}{5} \\ \frac{1}{2} & -\frac{1}{5} & -\frac{2}{5} \end{vmatrix}$ looks like this wolfram

  • A point ${\bf P} = (6,4,1)$ is given and the tangent points are to be found.

  • Set ${\bf Q} = (q_x,q_y,1)$ for the unknown tangent points

  • Form the equation ${\rm C}{\bf Q} = \lambda \left( {\bf Q} \times {\bf P} \right)$. You will get

$$ \begin{align} \frac{q_x}{4} - \frac{q_y}{10} + \frac{1}{2} & = \lambda ( q_y-4) \\ -\frac{q_x}{10} + \frac{q_y}{6} - \frac{1}{5} & = \lambda (6-q_x) \\ \frac{q_x}{2} - \frac{q_y}{5} - \frac{2}{5} & = \lambda (4 q_x -6 q_y) \end{align} $$

  • The solution is ${\bf Q}_1$ and ${\bf Q}_2$

$$ \begin{cases} {\bf Q}_1 = \begin{pmatrix} q_x \\ q_y \end{pmatrix} = \begin{pmatrix} \frac{\sqrt{43358}}{874} - \frac{25}{23} \\ \frac{6 \sqrt{43358}}{437} + \frac{21}{46} \end{pmatrix} & \mbox{for} & \lambda = \frac{\sqrt{43358}}{3260} \\ {\bf Q}_2 = \begin{pmatrix} q_x \\ q_y \end{pmatrix} = \begin{pmatrix} -\frac{\sqrt{43358}}{874} - \frac{25}{23} \\ -\frac{6 \sqrt{43358}}{437} + \frac{21}{46} \end{pmatrix} & \mbox{for} & \lambda = -\frac{\sqrt{43358}}{3260} \end{cases} $$

I have confirmed the results graphically and numerically.

results

John Alexiou
  • 13,816
1

The equation of your ellipse appears to be $$ \frac{(x-h)^2}{a^2} + \frac{(y-k)^2}{k^2} = 1. $$ For now I will assume the center $(h,k)$ is $(0,0)$ and then later we can adjust the answer for other centers. Thus we have $$ \frac{x^2}{a^2} + \frac{y^2}{b^2} = 1. \tag 1 $$

Your point $(x_1,y_1)$ must lie outside the ellipse in order to be on a tangent line.

One way of solving this problem involves no derivatives: You need a straight line that passes through $(x_1,y_1)$ and touches the ellipse at just one point. Suppose the equation of the line is $$ y-y_1 = m(x-x_1). \tag 2 $$ You want a point $(x,y)$ that satisfies both $(1)$ and $(2),$ and you need to choose $m$ so that there is only one such point. Solving $(2)$ for $y$ gives $y=m(x-x_1)+y_1.$ Substituting this for $y$ in $(1),$ you get $$ \frac{x^2}{a^2} + \frac{(m(x-x_1)+y_1)^2}{b^2} = 1 $$ $$ \frac{x^2}{a^2} + \frac{m^2x^2 + m^2 x_1^2 + y_1^2 - 2m^2 x_1 x + 2my_1 x - 2mx_1 y_1}{b^2} = 1 $$ $$ \left( \frac 1 {a^2} + \frac{m^2}{b^2} \right) x^2 + \left( \frac{2m(y_1-mx_1)}{b^2} \right) x + \frac{m^2 x_1^2 + y_1^2 - 2mx_1 y_1}{b^2} = 1 $$ $$ A x^2 + Bx + C = 0 $$ (Capital $A$ and $B$ should not be confused with lower-case $a$ and $b$.)

Now the problem is to choose the value of $m$ so as to make $B^2-4AC=0$ so that this quadratic equation will have only one solution.

(You should of course get two such values of $m$, as you can see if you draw the picture. Unless the point $(x_1,y_1)$ is actually on the curve, in which case there will be just one.)

1

Michael Hardy’s answer gives you a way to find the tangents without derivatives. I’ll expand on N74’s comment as an alternative.

Your ellipse appears to be aligned with the coordinate axes. Wlog, let’s assume that it’s centered on the origin (you can simply translate the resulting lines) so that its equation is $f(x,y)={x^2\over a^2}+{y^2\over b^2}=1$. We have $\nabla f=\left({2x\over a^2},{2y\over b^2}\right)$, so the equation of the tangent line at $(x_0,y_0)$ is, in point-normal form, $$\nabla f(x_0,y_0)\cdot(x-x_0,y-y_0)={2xx_0\over a^2}+{2yy_0\over b^2}-\left({2x_0^2\over a^2}+{2y_0^2\over b^2}\right)={2xx_0\over a^2}+{2yy_0\over b^2}-2=0,$$ or $${xx_0\over a^2}+{yy_0\over b^2}=1.\tag{$*$}$$ Plug the given point into this equation to get a simple linear relationship between $x_0$ and $y_0$, then substitute into the equation of the ellipse to produce a quadratic equation in either $x_0$ or $y_0$.


Another way to find the tangents to any non-degenerate conic that doesn’t involve taking derivatives is to use the dual conic, which consists of all of the lines in the projective plane that are tangent to the conic.

The general equation $Ax^2+Bxy+Cy^2+Dx+Ey+F=0$ of a conic can be written in the form $$\begin{bmatrix}x&y&1\end{bmatrix}\begin{bmatrix}A&\frac B2&\frac D2\\\frac B2&C&\frac E2\\\frac D2&\frac E2&F\end{bmatrix}\begin{bmatrix}x\\y\\1\end{bmatrix}=0$$ or, more compactly, $\mathbf x^TA\mathbf x=0$. If we set $\mathbf x=[x,y,w]^T$, we have the projective equation of the conic. The tangent lines to this conic satisfy the dual equation $\mathscr lA^{-1}\mathscr l^T=0$ (here I’m using row vectors for covectors that represent lines). Since we’re assuming a non-degenerate conic, we know that $A$ is nonsingular. In practice, it’s often more convenient to work with the adjugate matrix $(\det A)A^{-1}$ or some other non-zero multiple of the inverse matrix instead. A point $\mathbf p$ lies on the line $\mathscr l$ if $\mathscr l\mathbf p=0$ (this is the projective equivalent of the point-normal equation of a line). So, finding the tangent lines to a conic that pass through a point $\mathbf p$ amounts to solving the system $$\mathscr lA^{-1}\mathscr l^T=0\\\mathscr l\mathbf p=0.$$ There will, of course be zero, one or two solutions to this system, and each solution will have a free variable, as one might expect when working in homogeneous coordinates.

You appear to be working with ellipses of the form ${(x-h)^2\over a^2}+{(y-k)^2\over b^2}=1$. Expanding this equation and rearranging eventually produces $$A=\begin{bmatrix}b^2&0&-b^2h\\0&a^2&-a^2k\\-b^2h&-a^2k&b^2h^2+a^2k^2-a^2b^2\end{bmatrix}$$ and with a little bit of work we can find a relatively simple expression for the dual conic matrix: $$A^{\tiny\triangle}=\begin{bmatrix}h^2-a^2&hk& h\\hk&k^2-b^2&k\\h&k&1\end{bmatrix}.$$ Letting $\mathbf p=[x_p,y_p,1]^T$ and $\mathscr l=[\lambda,\mu,\nu]$ we get the system of equations $$\mathscr lA^{\tiny\triangle}\mathscr l^T=(h^2-a^2)\lambda^2+(k^2-b^2)\mu^2+\nu^2+2hk\lambda\mu+2h\lambda\nu+2k\mu\nu=0 \\ \mathscr l\mathbf p=x_p\lambda+y_p\mu+\nu=0.$$ The general solution isn’t pretty, but the solutions for specific cases aren’t that hard to work through: since you’re going to be left with a free variable, anyway, you might be able to set one of $\lambda$, $\mu$, or $\nu$ to a convenient value that simplifies the computation.

Then again, if you’re working with the matrix form of the conic equation, you can find the points of tangency by computing the intersection of the polar line of $\mathbf p$ with the conic, i.e., by solving the system of equations $$\mathbf x^TA\mathbf x=0\\\mathbf p^TA\mathbf x=0.$$ The equations for the tangent lines can be found using the usual methods, or by taking advantage of the fact that the polar line of a point on the conic is the tangent at that point.


I’ll sketch out one other method that doesn’t require solving any equations. For the unit circle, it’s very easy to work out geometrically that the points at which lines through $(d,0)$, $d\gt1$ are tangent to it are $\left(\frac1d,\pm{\sqrt{d^2-1}\over d}\right)$. You can scale, rotate and translate the unit circle to produce any ellipse and because affine transformations maintain tangents to circles/ellipses, the same transformation applied to these points will give you the points at which lines through the image of $(d,0)$ are tangent to the ellipse. From there, you can generate the equations of the tangent lines from the pairs of points. Alternatively, you can work in homogeneous coordinates and transform the covectors $\left[-1,\pm\sqrt{d^2-1},d\right]$ of the tangent lines directly, but keep in mind that these are covariant vectors which transform differently than points.

If $P$ is the point through which you’re drawing these tangents, let $Q$ be the inverse image of $P$ under the above transformation. Set $d$ to the distance of $Q$ from the origin, then apply an additional rotation that maps this point to $Q$ before applying the unit-circle-to-ellipse transformation. Given that you’re working with an ellipse in standard position that’s been translated by some amount, this method might work well as the transformation and its inverse are very easy to compute.

amd
  • 53,693