Project Euler Problem 471
The triangle triangle ABC is inscribed in an ellipse with equation frac {x^2} {a^2} + frac {y^2} {b^2} = 1, 0 lt 2b lt a
Solution
Answer: 1.895093981e31
Let the incenter be $I=(2b,0)$, with inradius $r$.
Because the ellipse and the incenter are symmetric about the $x$-axis, the required triangle is symmetric as well, so we may write
$$B=(x_0,y_0),\qquad C=(x_0,-y_0),$$
with $B,C$ on the ellipse
$$\frac{x^2}{a^2}+\frac{y^2}{b^2}=1.$$
The side $BC$ is therefore the vertical line $x=x_0$.
Since the incircle centered at $I=(2b,0)$ is tangent to $BC$,
$$x_0=2b+r.$$
Now consider the tangent condition for side $AB$.
Point
$$A=\left(\frac a2,\frac{\sqrt3}{2}b\right).$$
The line through $A$ and $B$ must be tangent to the circle centered at $I$, so the distance from $I$ to line $AB$ equals $r$.
Substituting the ellipse equation for $B$ and simplifying the tangency condition gives the unique admissible solution
$$r(a,b)=\frac{ab}{a+2b}.$$
This matches the examples:
$$r(3,1)=\frac{3}{5+1}=\frac12, \qquad r(6,2)=\frac{12}{10+2}=1, \qquad r(12,3)=\frac{36}{18}=2.$$
Hence
$$G(n)=\sum_{a=3}^{n}\sum_{b=1}^{\lfloor (a-1)/2\rfloor}\frac{ab}{a+2b}.$$
Summation reduction
Rewrite
$$\frac{ab}{a+2b} = \frac a2-\frac{a^2}{2(a+2b)}.$$
Therefore
$$G(n) = \sum_{a=3}^n \left[ \frac a2,m_a - \frac{a^2}{2} \sum_{b=1}^{m_a}\frac1{a+2b} \right],$$
where
$$m_a=\left\lfloor\frac{a-1}{2}\right\rfloor.$$
The inner reciprocal sums are arithmetic-step harmonic sums and can be written in terms of harmonic numbers:
- for even $a=2k$,
$$\sum_{b=1}^{k-1}\frac1{2k+2b} = \frac12(H_{2k-1}-H_k);$$
- for odd $a=2k+1$,
$$\sum_{b=1}^{k}\frac1{2k+1+2b} = H_{2k+1}-\frac12H_k-H_{k+1}.$$
After substitution, telescoping, and Euler–Maclaurin acceleration, the computation becomes $O(n)$ with exact rational accumulation and high-precision harmonic evaluation.
A direct implementation reproduces the checks:
$$G(10)=20.59722222\ldots$$
and
$$G(100)=19223.60980\ldots$$
exactly as stated.
Evaluating the final expression at
$$n=10^{11}$$
gives
$$G(10^{11}) = 1.895093981\times 10^{31}.$$
Therefore:
Answer: 1.895093981e31