Find all functions $f : \mathbb{Z} \to \mathbb{Z}$ such that $(f(x + y))^2 = f(x^2) + f(y^2)$ for all $x, y \in \mathbb{Z}$.
Source: 2018 Pan-African Mathematics Olympiad
Tags: functional equation, algebra, function
Find all functions $f : \mathbb{Z} \to \mathbb{Z}$ such that $(f(x + y))^2 = f(x^2) + f(y^2)$ for all $x, y \in \mathbb{Z}$.