TITLE: pythagorean theorem extensions
QUESTION [5 upvotes]: are there for a given integer N solutions to the equations
$$ \sum_{n=1}^{N}x_{i} ^{2}=z^{2} $$
for integers $ x_i $ and $ z$
an easier equation given an integer number 'a' can be there solutions to the equation
$$ \sum_{n=1}^{N}x_{i} ^{2}=a^2 $$
for N=2 this is pythagorean theorem

REPLY [2 votes]: Just to avoid notation bloat, let's let $N=4$ and let the implied generalization take care of the rest of the question. The question can be restated as asking whether there are rational points on the $4$-sphere $\mathbb S_4:x_1^2 + x_2^2 +x_3^2+x_4^2=1$. We know that $(1,0,0,0)$ is a (trivial) rational point on 
$\mathbb S_4$. From that point, we pick a rational direction, 
$(\xi_1, \xi_2, \xi_3, \xi_4)$ where $\xi_1, \xi_2, \xi_3, \xi_4$ are rational numbers, and see if the line $(1,0,0,0)+t(\xi_1, \xi_2, \xi_3, \xi_4)$ intersects
$\mathbb S_4$ at another rational point.
\begin{align}
   (1+t\xi_1)^2 + t^2 \xi_2^2 + t^2 \xi_3^2 + t^2 \xi_4^1 &= 1 \\
   2t\xi_1 + t^2(\xi_1^2 + \xi_2^2 + \xi_3^2 + \xi_4^2) &= 0 \\
   t &= -\dfrac{2\xi_1}{\xi_1^2 + \xi_2^2 + \xi_3^2 + \xi_4^2} 
\end{align} 
So, for any four rational numbers $\xi_1, \xi_2, \xi_3, \xi_4$
$$\left(
   \dfrac{-\xi_1^2 + \xi_2^2 + \xi_3^2 + \xi_4^2}
      {\xi_1^2 + \xi_2^2 + \xi_3^2 + \xi_4^2}, 
   -\dfrac{2\xi_1 \xi_2}{\xi_1^2 + \xi_2^2 + \xi_3^2 + \xi_4^2},
   -\dfrac{2\xi_1 \xi_3}{\xi_1^2 + \xi_2^2 + \xi_3^2 + \xi_4^2},
   -\dfrac{2\xi_1 \xi_4}{\xi_1^2 + \xi_2^2 + \xi_3^2 + \xi_4^2},
\right)$$
is a rational point on $\mathbb S_4$