Function Repository Resource:

FociPointEllipse

Source Notebook

Find the equation for an ellipse given two foci and a point

Contributed by: Ed Pegg Jr and Jan Mangaldan

ResourceFunction["FociPointEllipse"][{f1,f2,p},{x,y}]

returns the ellipse A x2+B x y+C y2+D x+E y+F in the variables x and y, given the foci f1,f2 and a point p through which the ellipse passes.

ResourceFunction["FociPointEllipse"][{f1,f2,p},t]

returns a parametric equation in the variable t.

ResourceFunction["FociPointEllipse"][{f1,f2,p}]

returns an Ellipsoid object representing the ellipse.

Examples

Basic Examples (2) 

Find the Cartesian equation of an ellipse with foci (3,3) and ) that goes through point ):

In[1]:=
{F, G, H} = {{3, 3}, {7/3, 11/3}, {5/2, 5/2}};
eq = ResourceFunction["FociPointEllipse"][{F, G, H}, {x, y}]
Out[2]=

Show the ellipse:

In[3]:=
ContourPlot[eq == 0, {x, 1, 4}, {y, 2, 5}, Epilog -> {Inset["F", F], Inset["G", G], Inset["H", H]}]
Out[3]=

Scope (4) 

Generate the parametric equations of an ellipse with foci (3,3) and ) that goes through point ):

In[4]:=
{F, G, H} = {{3, 3}, {7/3, 11/3}, {5/2, 5/2}};
ell = ResourceFunction["FociPointEllipse"][{F, G, H}, t]
Out[5]=

Show the ellipse:

In[6]:=
ParametricPlot[ell, {t, 0, 2 \[Pi]}, Axes -> None, Epilog -> {Inset["F", F], Inset["G", G], Inset["H", H]}, Frame -> True]
Out[6]=

Generate the corresponding Ellipsoid object:

In[7]:=
ellG = ResourceFunction["FociPointEllipse"][{F, G, H}]
Out[7]=

Show the ellipse:

In[8]:=
Graphics[{{Directive[
FaceForm[], 
EdgeForm[
Directive[
RGBColor[0.368417, 0.506779, 0.709798], 
AbsoluteThickness[1.6]]]], ellG}, {Inset["F", F], Inset["G", G], Inset["H", H]}}, Frame -> True]
Out[8]=

Properties and Relations (4) 

Use a different set of variables:

In[9]:=
ResourceFunction[
 "FociPointEllipse"][{{0, 0}, {5, 7}, {2, 1}}, {a, b }]
Out[9]=

Use formal variables:

In[10]:=
ResourceFunction[
 "FociPointEllipse"][{{0, 0}, {5, 7}, {2, 1}}, {\[FormalX], \[FormalY] }]
Out[10]=

Use FociPointEllipse to generate the implicit Cartesian equation of an ellipse:

In[11]:=
{F, G, H} = {{2, 2}, {3, 5}, {1, 3}};
ResourceFunction["FociPointEllipse"][{F, G, H}, {x, y}]
Out[12]=

Use GroebnerBasis to get an equivalent result:

In[13]:=
First[GroebnerBasis[
  Sqrt[# . # &[{x, y} - F]] + Sqrt[# . # &[{x, y} - G]] == Sqrt[# . # &[H - F]] + Sqrt[# . # &[H - G]], {x, y}]]
Out[13]=

Generate an equivalent parametric equation:

In[14]:=
ResourceFunction["FociPointEllipse"][{F, G, H}, t]
Out[14]=

Use GroebnerBasis to derive the implicit Cartesian equation from the parametric equation:

In[15]:=
First[GroebnerBasis[
  Append[Thread[{x, y} == %], Cos[t]^2 + Sin[t]^2 == 1], {x, y}, {Cos[t], Sin[t]}]]
Out[15]=

Use the resource function EllipseProperties to generate properties of the ellipse:

In[16]:=
ResourceFunction["EllipseProperties"][
 ResourceFunction[
   "FociPointEllipse"][{{0, 0}, {5, 7}, {2, 1}}, {x, y}] == 0, {x, y}]
Out[16]=

Get an ellipse equation:

In[17]:=
ell = ResourceFunction[
  "FociPointEllipse"][{{0, 0}, {5, 7}, {2, 1}}, {x, y}]
Out[17]=

Show positions for coefficients in A x2+B x y+C y2+D x+E y+F=0:

In[18]:=
pos = CoefficientList[\[FormalCapitalA] x^2 + \[FormalCapitalB] x y + \[FormalCapitalC] y^2 + \[FormalCapitalD] x + \[FormalCapitalE] y + \[FormalCapitalF], {x, y}]
Out[18]=

Get the coefficients:

In[19]:=
coeff = CoefficientList[ell, {x, y}]
Out[19]=

See the coefficients in the standard order:

In[20]:=
Transpose[
 Sort[Select[Transpose[Flatten /@ {pos, coeff}], Not[First[#] === 0] &]]]
Out[20]=

Neat Examples (4) 

Construct an ellipse from given foci and a point:

In[21]:=
{F, G, H} = {{3, 3}, {7/3, 11/3}, {5/2, 5/2}};
ell = ResourceFunction["FociPointEllipse"][{F, G, H}]
Out[22]=

Use three mysterious points to create a complex cubic, take the derivative and solve the quadratic to find foci that happen to be F and G:

In[23]:=
{P, Q, R} = {{4, 2}, {3, 5}, {1, 3}};
ReIm[w /. Solve[D[Times @@ ((w - # . {1, I}) & /@ {P, Q, R}), w] == 0, w]]
Out[24]=

In Marden's theorem, the above step finds the foci of an inellipse that is tangent to the midpoints of the sides of the triangle generated by vertices PQR:

In[25]:=
Graphics[{{Directive[EdgeForm[Black], White], Polygon[{P, Q, R}]}, {Directive[
FaceForm[], 
EdgeForm[
Directive[
RGBColor[0.368417, 0.506779, 0.709798], 
AbsoluteThickness[1.6]]]], ell}, {Blue, Style[Text[#[[1]], #[[2]]], 18] & /@ Transpose[{Characters["FGHPQR"], {F, G, H, P, Q, R}}]}}]
Out[25]=

The resulting inellipse is a scaled version of the Steiner circumellipse, with a scaling factor of 1/2. Use the resource function SteinerCircumellipse to produce an equivalent figure:

In[26]:=
ell2 = ResourceFunction["SteinerCircumellipse"][{P, Q, R}];
Graphics[{{Directive[EdgeForm[Black], White], Polygon[{P, Q, R}]}, {Directive[
FaceForm[], 
EdgeForm[
Directive[
RGBColor[0.368417, 0.506779, 0.709798], 
AbsoluteThickness[1.6]]]], Scale[ell2, {1/2, 1/2}, First[ell2]]}, {Blue, Style[Text[#[[1]], #[[2]]], 18] & /@ Transpose[{Characters["FGHPQR"], {F, G, H, P, Q, R}}]}}]
Out[27]=

Version History

  • 1.0.0 – 18 July 2022

Related Resources

License Information