# 4-ellipse with distance R from four foci

I'm trying to find the equation for the generalization of an ellipse called a $n$-ellipse which has a constant distance R from four foci located at $(0,0),(0,1),(1,0),(1,1)$

Edit: As an algebraic curve without Square roots

Will reward bounty to anyone who gives me the equation asked for above as well as a generalized equation for foci at $(0,0),(0,n),(n,0),(n,n)$ with distance R

Does Anyone know?

• I tried the slightly more symmetric version with foci $(\pm1,\pm1)$ in Maxima: eliminate([a^2=(x+1)^2+(y+1)^2,b^2=(x+1)^2+(y-1)^2,c^2=(x-1)^2+(y+1)^2,d^2=(x-1)^2+(y-1)^2,a+b+c+d=R],[a,b,c,d]); returns a polynomial $f(x,y,R)$ raised to some irrelevant power that I stripped off. The remaining $f(x,y,R)$ (implicitly set to zero) is an irreducible polynomial of degrees $(10,10,16)$ in $(x,y,R)$. Quite a huge expression; you wouldn't like it. – ccorn May 16 '16 at 0:35
• The version with foci $(0,\pm1)$ and $(\pm1,0)$ is still a screenfull. – ccorn May 16 '16 at 0:56
• Yeah I get that it's not pretty,if it were I wouldn't have asked for help, it has important implications in finding a rational distance from a square. – shai horowitz May 16 '16 at 14:15
• @shaihorowitz: You might get better results with $$d(x,y) = \left(\left\lvert x-\frac{1}{2}\right\rvert^n + \left\lvert y-\frac{1}{2}\right\rvert^n\right)^\frac{1}{n}$$with either a fixed $n$ (say, $n = 4$), or an $n$ depending on the distance from the center of the square (relative to the square edge length). – Nominal Animal May 17 '16 at 7:16
• Just to know, once you get such horrible homogeneous polynomial with degree $10$, what do you plan to do with it? – Jack D'Aurizio May 19 '16 at 14:02

The equation is obviously $$\sqrt{x^2+y^2}+\sqrt{x^2+(y-1)^2}+\sqrt{(x-1)^2+y^2}+\sqrt{(x-1)^2+(y-1)^2} = R$$ (for $R\geq 2\sqrt{2}$) that is the equation of an algebraic curve of degree $10$. For large values of $R$, such curve is closer and closer to the circle centered at $\left(\frac{1}{2},\frac{1}{2}\right)$ with radius $\frac{R}{4}$.

• Your right I forgot to mention that i'm looking for the square-root free form. – shai horowitz May 15 '16 at 4:18
• I've seen this paper but can't follow it well enough to construct the function for 4 foci. – shai horowitz May 15 '16 at 4:28
• @shai, if you have Mathematica: GroebnerBasis[Sqrt[x^2 + y^2] + Sqrt[x^2 + (y - 1)^2] + Sqrt[(x - 1)^2 + y^2] + Sqrt[(x - 1)^2 + (y - 1)^2] == r, {x, y}][[1]] // FullSimplify – J. M. is a poor mathematician May 23 '16 at 19:02

As a start, let us first derive the formula when the unit square is centered at origin.

Let $a = x^2+y^2+\frac12$, the distance to vertex $v$ is:

$$\begin{cases} r_{++} &= \sqrt{a - x - y}, & v = (+\frac12,+\frac12)\\ r_{+-} &= \sqrt{a - x + y}, & v = (+\frac12,-\frac12)\\ r_{-+} &= \sqrt{a + x - y}, & v = (-\frac12,+\frac12)\\ r_{--} &= \sqrt{a + x + y}, & v = (-\frac12,-\frac12) \end{cases}$$

If the sum of these 4 distances is $R = \sqrt{z}$, the equation for the $4$-ellipse will be given by $$r_{++} + r_{+-} + r_{-+} + r_{--} - R = 0\tag{*1}$$

To construct a polynomial curve that contains this $4$-ellipse, the standard trick is apply all the symmetry operations in the associated Galois group to this expression and then take the product. For the case at hand, this becomes

$$\prod_{(\epsilon_{++},\epsilon_{+-},\epsilon_{-+},\epsilon_{--}) \in \{\pm 1\}^4} \left( \epsilon_{++}r_{++} + \epsilon_{+-} r_{+-} + \epsilon_{-+} r_{-+} + \epsilon_{--} r_{--} - \sqrt{z}\right) = 0$$ If one throw this to an CAS, the product is equal to

$$\begin{array}{rrl} & z^8\\ -32 & az^7\\ +32 & z^6 & (y^2+x^2+11a^2)\\ -256 & az^5 & (y^2+x^2+7a^2)\\ -256 & z^4 & (7y^4-20x^2y^2-6a^2y^2+7x^4-6a^2x^2-17a^4)\\ +4096 & az^3 & (3y^4-4x^2y^2-2a^2y^2+3x^4-2a^2x^2-a^4)\\ +8192 & z^2 & (2y^6-x^2y^4-4a^2y^4-x^4y^2+3a^2x^2y^2+2a^4y^2+2x^6-4a^2x^4+2a^4x^2)\\ +65536 & az\; & x^2y^2(y^2+x^2-a^2)\\ +65536 & & x^4y^4 \end{array} \tag{*2}$$ This is a a big mess even before we substitute $a$ by $x^2+y^2+\frac12$, $z$ by $R^2$ and fully expand it.

To obtain a more manageable formula, consider following two products,

\begin{align} P_{+}(\lambda) &= \prod_{(\epsilon_{++},\epsilon_{--}) \in \{\pm 1\}^2} \left( \epsilon_{++}r_{++} + \epsilon_{--} r_{--} - \lambda\right) = \lambda^4 - 4a\lambda^2 + 4(x + y)^2 \\ P_{-}(\lambda) &= \prod_{(\epsilon_{+-},\epsilon_{-+}) \in \{\pm 1\}^2} \left( \epsilon_{+-}r_{+-} + \epsilon_{-+} r_{-+} - \lambda\right) = \lambda^4 - 4a\lambda^2 + 4(x - y)^2 \end{align} Notice

• $P_{+}(\lambda)$ contains a factor $r_{++} + r_{--} - \lambda$.
• $P_{-}(\lambda)$ contains a factor $r_{+-} + r_{-+} - \lambda$.

If one compute the resultant of $P_{+}(\lambda)$ and $P_{-}(\sqrt{z} - \lambda)$ and eliminate $\lambda$, the resulting polynomial in $\sqrt{z}$ will contain the desire factor $r_{++} + r_{--} + r_{+-} + r_{-+} - \sqrt{z}$ appeared in LHS of $(*1)$. With help of a CAS again, up to a scaling factor, the resultant equals to

\begin{align} g(z,A,B) \stackrel{def}{=} & \;\; z^2 (z^2-4Az+16A-32)(z^2-2Az+A^2-4A+8)^2\\ & + 2Bz (17z^3-20Az^2+11A^2z-28Az+56z-2A^3+8A^2-16A)\\ & + B^2 \end{align} where $\displaystyle\;\begin{cases} A &= 4x^2+4y^2 + 2\\ B &= 256x^2y^2 \end{cases}$.

If you fully expand $g(z,A,B) = 0$ and $(*2)$, you can verify they return the same polynomial.

To obtain the polynomial curve when the vertices are $(0,0)$, $(1,0)$, $(1,0)$ and $(1,1)$, one can replace $x$ by $x - \frac12$ and $y$ by $y - \frac12$ in above definition of $A,B$ above. The polynomial curve is

$$g(R^2, 4(x^2+y^2-x-y+1), 16(2x-1)^2(2y-1)^2) = 0\tag{*3}$$

If I count correctly, when you expand this out, you will obtain a polynomial in $R,x,y$ with $289$ terms! This is way too big to include it directly in this answer.

If you really want the coefficients, I will recommend you either input $(*3)$ into an CAS and ask the CAS to expand for you or even better, reproduce the derivations here by an CAS.

For the case where the vertices are located at $(0,0), (n,0), (0,n), (n,n)$, the formula can be obtained from $(*3)$ by substituting $(x,y,R)$ with $(\frac{x}{n},\frac{y}{n},\frac{R}{n})$.

Here, I just cover the key part: Expressing $$a+b+c+d=R$$ as a polynomial equation in $R$ and $(A,B,C,D)=(a^2,b^2,c^2,d^2)$. Then you can plug in the distance squares $A=x^2+y^2$ etc and do all the messy expansions.

Let $S_k = a^k+b^k+c^k+d^k$. We note \begin{align} S_1 &= R & S_{2k} &= A^k+B^k+C^k+D^k \end{align} And for every $k\in\mathbb{N}$, $S_k$ can be expressed as a polynomial in $S_1,S_2,S_3,S_4$. In particular, \begin{align} 24 S_6 &= -R^6 + 9 S_2 R^4 - 16 S_3 R^3 + 18 S_4 R^2 - 9 S_2^2 R^2 + 18 S_2 S_4 - 3 S_2^3 + 8 S_3^2 \tag{1} \\ 144 S_8 &= -R^8 + 4 S_2 R^6 - 16 S_3 R^5 + 12 S_4 R^4 + 30 S_2^2 R^4 - 32 S_2 S_3 R^3 \\&\quad{} + 72 S_2 S_4 R^2 - 64 S_3^2 R^2 - 36 S_2^3 R^2 + 96 S_3 S_4 R - 48 S_2^2 S_3 R \\&\quad{} + 36 S_4^2 + 36 S_2^2 S_4 + 64 S_2 S_3^2 - 9 S_2^4 \tag{2} \end{align} The only variable that disturbs us is $S_3$. We will eliminate it. To that end, we rewrite $(1)$ and $(2)$ as polynomials in $S_3$: \begin{align} f_6(S_3) &= 0 & f_6(X) &= 8 X^2 - 16 R^3 X - U_6 \\ f_8(S_3) &= 0 & f_8(X) &= 64 U_2 X^2 + 16 R U_4 X + U_8 \end{align} where \begin{align} U_2 &= R^2 - S_2 \\ U_4 &= R^4 + 2 S_2 R^2 - 6 S_4 + 3 S_2^2 \\ U_6 &= R^6 - 9 S_2 R^4 - 18 S_4 R^2 + 9 S_2^2 R^2 - 18 S_2 S_4 + 3 S_2^3 + 24 S_6 \\ U_8 &= R^8 - 4 S_2 R^6 - 12 S_4 R^4 - 30 S_2^2 R^4 - 72 S_2 S_4 R^2 \\&\quad{} + 36 S_2^3 R^2 - 36 S_4^2 - 36 S_2^2 S_4 + 9 S_2^4 + 144 S_8 \end{align} $f_6$ and $f_8$ have a common zero (at $X=S_3$), so their resultant must vanish: $$\operatorname{Res}_X(f_6,f_8) = \begin{vmatrix} 8 & -16 R^3 & -U_6 & 0 \\ 0 & 8 & -16 R^3 & -U_6 \\ 64 U_2 & 16 R U_4 & U_8 & 0 \\ 0 & 64 U_2 & 16 R U_4 & U_8 \end{vmatrix} = 0$$ Removing a common factor $8$ from each of the first two columns and expanding yields \begin{align} U_8^2 + 16\,U_2\,U_6\,U_8 + 32\,R^4\,U_4\,U_8 + 256\,R^6\,U_2\,U_8\quad \\{} + 64\,U_2^2\,U_6^2 - 32\,R^2\,U_4^2\,U_6 - 256\,R^4\,U_2\,U_4\,U_6 &= 0 \tag{3} \end{align} To get your desired polynomial equation:

1. Write $A,B,C,D$ as the four distance squares, using $x,y$ and the focus coordinates.
2. Plug those into the expressions for $S_2,S_4,S_6,S_8$.
3. Plug those into the expressions for $U_2,U_4,U_6,U_8$.
4. Plug those into $(3)$ and cancel yet another common factor $9$.

This is a huge expansion, but merely that, and I will not flood the page with the results. Better use a computer algebra system (CAS) for such things. However, with a CAS, you can skip all the preparations and just do e.g. in Maxima:

factor(part(eliminate([a^2=A,b^2=B,c^2=C,d^2=D,a+b+c+d=R],[a,b,c,d]),1))


(or your distance squares instead of $A,B,C,D$) which yields an expression of the form $\pm c\cdot F^m$ with $c,m$ constant positive integers and $F$ a huge polynomial expression. Your equation is then $F=0$.

• I used Maxima commands similar to the following for deriving $(1)$ and $(2)$: Express Vieta invariants in terms of the $S_k$, then build the companion matrix whose eigenvalues are $a,b,c,d$ and compute power traces: (R2: (R^2 - S2)/2, R3: (R^3 - 3*R*S2 + 2*S3)/6, R4: (R^4 - 6*S2*R^2 + 8*S3*R - 6*S4 + 3*S2^2)/24, M: polytocompanion(x^4-R*x^3+R2*x^2-R3*x+R4,x), for k:1 thru 8 do print(k, " ", xthru(expand(mat_trace(M^^k))))); The output for $k\leq4$ serves for verification. – ccorn May 25 '16 at 2:39