Application and usage of representation of integers as sum of powers? We know that there are many articles and manuscripts from the ancient to date talking about representation of integers as sum of squares, cubes etc. I would like to know what is it the usage and application of doing this? Is it just curiosity and challenge solving of mathematicians or there are something very deep application of this?
Thanks in advance!
 A: An application is Euler's factorization algorithm. 
If you manage to find a representation of a positive integer $n$ in
two different ways as a sum of two squares like $n=a^2+b^2$ (with $a\geqslant b$) and
$n=c^2+d^2$ (with $c\leqslant d$ ), then put $k=\gcd(a-c,d-b)$  and $h=\gcd(a+c,d+b)$
and $l=(a-c)/k$ and $m=(d-b)/k$.
It is easy to see that either $k$ and $h$, or $l$ and $m$ are both
even.
If $k$ and $h$ are even you get the factorization
$$n=((k/2)^2+(h/2)^2)(l^2+m^2).$$
For example consider two decompositions $221=11^2+10^2=5^2+14^2$.
We have $k=\gcd(11-5,14-10)=2$, $h=\gcd(11+5,14+10)=8$,
$l=(11-5)/2=3$ and $k=(14-10)/2=2$.
Hence you obtain the factorization
$221=((2/2)^2+(8/2)^2)(3^2+2^2)=17\times13$.
More details are on https://en.wikipedia.org/wiki/Euler%27s_factorization_method
A: In work on the Tate conjecture for abelian varieties over function fields, Zarhin introduced a trick that shows that for any abelian variety $A$, the product $(A\times A^{\vee})^4$ is principally polarized, using the fact that any integer is the sum of four squares (Lagrange's theorem).
Reference:
http://iopscience.iop.org/0025-5726/8/3/N02/
(section 2.3) or Faltings's paper on the Mordell conjecture.
A: Here are a couple other applications, though they put the cart before the horse:
An elementary one, also related to factorization, is that a representation $n=a^2+db^2$ gives you a factorization $n=(a+b\sqrt{-d})(a-b\sqrt{-d})$ of $n$ in the integer ring $\mathcal O_{-d}$ of $\mathbb Q(\sqrt{-d})$.  Now $\mathcal O_{-d}$ does not have unique factorization in general, but at least if the class group is an elementary 2-group, I showed in this paper how you can use representations of integers by $a^2+db^2$ to construct all irreducible factorizations of $n$ in $\mathcal O_{-d}$.
A more sophisticated type of application is as follows.  One can often express Fourier coefficients of modular forms in terms of representation numbers.  Fourier coefficients of modular forms are of interest for a lot of reasons, and here's a specific one I like.  The nonvanishing of the central $L$-value $L(1, E_{-d})$ of quadratic twists of elliptic curves $E_{-d}$ tell you you have only finitely many rational points on $E_{-d}$, and $L(1,E_{-d})$ can be expressed in terms of Fourier coefficients of a weight 3/2 modular form, which can often be expressed in terms of representations numbers for ternary quadratic forms (e.g., this works for quadratic twists of a conductor 11 elliptic curve).  So you can use representation of numbers by ternary quadratic forms to compute $L(1,E_{-d})$ and conclude that $E_{-d}$ has finitely many rational points when this value is nonzero.
A: Lagrange's four-square theorem has been used to reduce Hilbert's tenth problem 

Decide whether a given polynomial Diophantine equation with integer
  coefficients has a solution in integers

to the similar problem with solutions in natural numbers:

Decide whether a given polynomial Diophantine equation with integer
  coefficients has a solution in natural numbers.

