**Problem.** Consider four mutually tangent circles in $\mathbb{R}^2$ of radii $r_1,r_2,r_3,r_4$. If three circles are inside the fourth, then take the radius of the largest circle to be negative. All other radii in this and other cases are taken positive. Show that $$2\sum_{i=1}^4 r_i^{-2}=\left(\sum_{i=1}^4 r_i^{-1}\right)^2.$$

**Solution:** *(Note: This was a response to the solution 2 below when there was a mistake.)* I have worked on this exercise also. So here is my Macaulay code that solved the exercise:

```
R = QQ[a_1 .. a_4,b_1 .. b_4,r_1 .. r_4];
L = for i from 1 to 4 list
for j from 1 to 4 list if i!=j then ((a_i-a_j)^2+(b_i-b_j)^2-(r_i+r_j)^2) else 0;
I = ideal flatten L;
J = eliminate(toList(a_1 .. a_4 | b_1 .. b_4),I)
K = frac R
f = 2 * sum apply(toList(1..4),i -> 1/((r_i)^2)) - (sum apply(toList(1..4),i -> 1/((r_i))))^2
numerator f - J_0
```

So let's go through it slowly. I did also set up the very same equations as above. I chose a_1 up to a_4 and b_1 up to b_4 to be the coordinates of the centers of the circles and r_1 up to r_4 to be their respective radii. Indeed the fact that they only touch in one point is modeled by the equation that the (euclidean) distance of their centers is equal to the sum of their radii. Squaring this equations gives(1)

for all i,j with i different from j. So in the above code, the second and third line generates these equations and writes them in a list of lists. So I generate an ideal and eliminate the variables of the centers (the a-s and b-s). The rest of the code checks, whether this polynomial generated by Macaulay2 is actually the same as the rational function given on the exercise sheet: So I enter the rational function f into Macaulay2 (computation in the fraction field of the polynomial ring R) and find that the numerator of it is actually the same as the computed generator of the ideal

(2)So here is the generator of this ideal as Macaulay2 computed it on my computer:

```
r_1^2*r_2^2*r_3^2-2*r_1^2*r_2^2*r_3*r_4-2*r_1^2*r_2*r_3^2*r_4-2*r_1*r_2^2*r_3^2*r_4+
r_1^2*r_2^2*r_4^2-2*r_1^2*r_2*r_3*r_4^2-2*r_1*r_2^2*r_3*r_4^2+
r_1^2*r_3^2*r_4^2-2*r_1*r_2*r_3^2*r_4^2+r_2^2*r_3^2*r_4^2
```

—This polynomial is different from the one below. In fact the reason seems to be, that there is a typo in the definition of the ideal upstairs, namely

`(x2-x3)^2+(y2-y3)^2-(r1+r3)^2`

I assume, it will all work out fine, if this is fixed.—

**Solution 2** Call the center of the circles $(x_i,y_i)$ for $i=1,\ldots,4$. For each pair $i,j$ one has from the distance formula and the fact that the circles are tangent that $$(x_i-x_j)^2+(y_i-y_j)^2=(r_i+r_j)^2.$$ (This assumes the radii are positive.) Using this information, we can turn to Macaulay and try to eliminate the x and y variables:

```
R=QQ[x1,x2,x3,x4,y1,y2,y3,y4,r1,r2,r3,r4]
I=ideal((x1-x2)^2+(y1-y2)^2-(r1+r2)^2,(x1-x3)^2+(y1-y3)^2-(r1+r3)^2,(x1-x4)^2+(y1-y4)^2-(r1+r4)^2,(x2-x3)^2+(y2-y3)^2-(r2+r3)^2,(x2-x4)^2+(y2-y4)^2-(r2+r4)^2,(x3-x4)^2+(y3-y4)^2-(r3+r4)^2)
J=eliminate({x1,x2,x3,x4,y1,y2,y3,y4},I)
```

Then you get a principal ideal

`ideal(r1^2*r2^2*r3^2-2*r1^2*r2^2*r3*r4-2*r1^2*r2*r3^2*r4-2*r1*r2^2*r3^2*r4+r1^2*r2^2*r4^2-2*r1^2*r2*r3*r4^2-2*r1*r2^2*r3*r4^2+r1^2*r3^2*r4^2-2*r1*r2*r3^2*r4^2+r2^2*r3^2*r4^2)`

Now we have to check that it's the right thing.

```
l=flatten entries gens J --get the generator of J, albeit as a list
ts=terms l#0 --get a list of terms of the generator of J
pos=for t in ts list (if leadCoefficient t > 0 then t) --pull out the positive terms
neg=for t in ts list (if leadCoefficient t < 0 then t) --and the negative terms
pos=delete(null,pos) --delete the empty elements of those lists
neg=delete(null,neg) --(there should have been continue statements in the loops above, I think)
p=fold(plus,pos) --now sum the positive terms together
n=fold(plus,neg) --and the negative terms together
```

Once we've done that

```
p=r1^2*r2^2*r3^2+r1^2*r2^2*r4^2+r1^2*r3^2*r4^2+r2^2*r3^2*r4^2
n=-2*r1^2*r2^2*r3*r4-2*r1^2*r2*r3^2*r4-2*r1*r2^2*r3^2*r4-2*r1^2*r2*r3*r4^2-
2*r1*r2^2*r3*r4^2-2*r1*r2*r3^2*r4^2
```

[[/code]]