Formula for ellipse with two tangents intersecting with two points Assume that I have four points $P_1, P_2, P_3, P_4$.  These points lie on the 2d plane and take the form $P_i = (x_i, y_i)$
Assume that I define line $L_{ij}$ as the line passing through $P_i$ and $P_j$.
How do I find the coefficients $a$ and $b$ in the equation for an ellipse $\frac{x^2}{a^2}+\frac{y^2}{b^2}=1$ such that the ellipse passes through points $P_2$ and $P_3$ AND has both tangent lines $L_{12}$ and $L_{34}$?
EDIT: I am using this formula to smooth a graph I'm drawing in python's matplotlib.pyplot.  I have two line segments $L_{12}$ and $L_{34}$ that I need to draw a smooth connection through, and an ellipse seems like a good shape for this.

Here's a geometric construction for an ellipse tangent to lines $P_1P_2$, $P_3P_4$ at tangency points $P_2$, $P_3$. There is some freedom left in the construction, so you can fix another point on the ellipse, as explained below.
Let $T$ be the point where lines $P_1P_2$ and $P_3P_4$ meet. If $M$ is the midpoint of $P_2P_3$, ray $TM$ passes through the center of the ellipse and you can choose at will on it another point $P$ of the ellipse (provided $M$ lies between $T$ and $P$): every choice of $P$ will lead to a different ellipse satisfying your request. If you need, in particular, an ellipse of minimum eccentricity, you can choose $P$ as explained here.
To find other two points on the ellipse, take any point $H$ on $PP_2$ and draw through it a line parallel to $P_2P_3$, meeting line $P_1P_2$ at $A$ and line $P_3P_4$ at $B$. Construct then on segment $AB$ two points $N$ and $O$ such that $AN\cdot BN=AH^2$ and $BO=AN$ (a possible geometric construction is hinted in the diagram below). These two points also belong to the ellipse, 
which is then fully specified as the conic section passing through $P_2P_3OPN$.

In case lines $P_1P_2$ and $P_3P_4$ are parallel, construct line $MT$ through $M$ and parallel to them, then go on as explained above.
You should have no problems in working out the coordinates of $P$, $N$ and $O$. Once you have the five points, you can find the ellipse equation by substituting their coordinates in the generic equation $x^2+ay^2+bxy+cx+dy+e=0$ to find the unknown coefficients $a$, $b$, $c$, $d$, $e$.
