TITLE: Solve Euler Project #9 only mathematically - Pythagorean triplet
QUESTION [5 upvotes]: The "Euler Project" problem 9 (https://projecteuler.net/problem=9) asks to solve:
$a^2$ + $b^2$ = $c^2$
a + b + c = 1000
I find answers solving it with brute-force and programmatically, but is there a way to solve the problem ONLY mathematically? Can someone help, please?
Problem as explained in Project Euler website:

A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,

a^2 + b^2 = c^2
For example, 3^2 + 4^2 = 9 + 16 = 25 = 52.

There exists exactly one Pythagorean triplet for which a + b + c = 1000.

Find the product abc.

REPLY [3 votes]: If the Pythagorean parameterization is a little advanced, be rest assured that it is unnecessary.  One can simply rewrite the condition as:
$$c = 1000 - a - b$$
And simply substitute into the Pythagorean Theorem as:
$$a^2+b^2=(1000-a-b)^2 = 1,000,000 + a^2+b^2 - 2000a-2000b+2ab$$
We can easily rewrite this as:
$$ab - 1000a-1000b + 500,000 = 0$$
Now we employ Simon's Favorite Factoring Trick to "factor" this as:
$$(a-1000)(b-1000) = 500,000$$
Now both $a$ and $b$ are less than $1000$, so perhaps it would be better to have this written in the form:
$$(1000-a)(1000-b) = 500,000$$
In other words, we are seeking two factors, both less than a thousand, that multiply to $500,000$.  
There are many ways to finish, including some simple guess-and-checking.  Fortunately, there is a relatively clean finish.  One could potentially now observe that $500,000 \approx 490,000 = 700^2$, so perhaps our factors are around $700$.  This is a decent ballpark to start with.  Now, one could observe that our factors perhaps could have been $500$ and $1000$, but unfortunately one of these is not less than $1000$.  We could instead say that our factors must be between $500$ and $1000$.  If our factors were to be $F_1,F_2$, we can write:
$$500 < F_1,F_2 < 1000$$
We now try to tighten this bound, keeping in mind that both factors must satisfy it.  Firstly, we note that $500,000 = 2^5 \cdot 5^6$.  It would be quite ridiculous if, say, $F_1$ were to have no factors of $5$, for then the maximum value it could have be would be $32$, which is for sure outside of these bounds.  So for each of our factors, we can say that they contain a factor of 5.  Donating our two factors of 5, we're left with $2^5 \cdot 5^4$, and they satisfy some new bounds:
$$100 < \frac{F_1}{5},\frac{F_2}{5} < 200$$
Continuing, it would be equally ridiculous if $\frac{F_1}{5}$ had no factors of 5 either, since $32$ is still outside of these bounds.  Donating an additional two factors of 5, we're left with $2^5 \cdot 5^2$ to work with, and the following bounds:
$$20 < \frac{F_1}{5^2},\frac{F_2}{5^2} < 40$$
At this point, we can stop with the reduction, and see that by inspection, we have both $32$ and $25$ satisfying this inequality, and so $32*25 = 800$ and $25*25 = 625$ would be our factors.  Some simple thought can tell us that really, this is the only solution that can satisfy these bounds.  Namely, if within the last obtained inequality, we somehow found another two numbers that satisfied it that multiplied to $2^5 \cdot 5^2$, then surely one of these numbers would be a $10$.  But $10$ does not satisfy the bounds, and multiplying it by either some 2s or 5s will jump over the whole interval $(20,40)$, so no such alternate solution can exist.  Now, the rest of the problem is routine.  We write:
$$1000 - a = 800$$
$$1000 - b = 625$$
And so $a = 200$ and $b = 375$.