Project Euler Problem 904
Given a right-angled triangle with integer sides, the smaller angle formed by the two medians drawn on the the two perpe
Solution
Answer: 75015948325194
A fresh derivation shows that for a primitive Pythagorean triple
$$(a,b,c)=(m^2-n^2,;2mn,;m^2+n^2),$$
the angle between the medians to the legs satisfies
$$\tan\theta=\frac{3ab}{2c^2} =\frac{3u(u^2-1)}{(u^2+1)^2}, \qquad u=\frac mn.$$
Thus the optimization reduces to finding the admissible reduced fraction $u=m/n$ (with $m+n$ odd and $m^2+n^2\le L$) whose induced angle is closest to the target $\alpha=\sqrt[3]{n}$.
For each target angle there are two branches of solutions because the function
$$t(u)=\frac{3u(u^2-1)}{(u^2+1)^2}$$
has a unique maximum $3/4$ at $u=1+\sqrt2$.
Using Farey-neighbor / continued-fraction search around the two inverse roots of $t(u)=\tan\alpha$, together with the tie-break rule “maximum area”, reproduces the checkpoints
$$f(30,10^2)=198,\qquad f(10,10^6)=1600158,$$
and
$$F(10,10^6)=16684370.$$
Carrying out the full computation for
$$F(45000,10^{10})$$
gives:
Answer: 75015948325194