Homomorphisms of a Finite Group & Perfect Squares I'm working on a textbook problem:
Come up with a finite group $G$ and homomorphism: $f: G \rightarrow G$ such that $3$% of the elements of in $G$ satisfy $f(x) = x^2$ (where $x$ is an element in $G$).
So far, I've tried a lot of different ideas. When I made the binary operator for $G$ additive, I had a tough time since the homomorphism must follow a lot of conditions such as $f(2) = 2f(1)$, not leaving a lot of space for me to try and come up with a way to get $f(x) = x^2.$
I tried making the group a power group and multiplicative. In both scenarios, I didn't really get anything too useful – every idea that I tried ultimately failed.
Does anyone know how to do this?
 A: Here is a solution where I explain all the "false starts" I tried along the way. Let's start by looking at a very simple example, namely the multiplication-by-$m$ map $f(x) = mx$ on the cyclic group $C_n \cong \mathbb{Z}/n$ (written additively). The subset of elements satisfying $f(x) = mx = 2x$ is the subset of elements satisfying $(m-2) x = 0$, which has size $\gcd(m-2, n)$ (exercise). So the density of this subset is $\frac{\gcd(m-2, n)}{n}$, which unfortunately as a fraction in lowest terms always has numerator $1$ and so cannot be equal to $\frac{3}{100}$. So no example of this form can work.
The next group I tried was $\mathbb{Z}/n \times \mathbb{Z}/n$, but I ran into the following problem generalizing the previous observation: if $A$ is any abelian group and $f : A \to A$ is a homomorphism then the subset of elements satisfying $f(a) = 2a$ is $\text{ker}(f - 2)$ which is a subgroup, so its density always has numerator $1$ when written as a fraction in lowest terms (with denominator the index). This means an example must be nonabelian.
However, abelian examples do help us for the following reason: if $f_1 : G_1 \to G_1$ is an endomorphism of a group and $f_2 : G_2 \to G_2$ is an endomorphism of another group, we can take their direct product to get an endomorphism $f_1 \times f_2 : G_1 \times G_2 \to G_1 \times G_2$. If we write $d(G, f)$ for the density of elements satisfying $f(g) = g^2$, then
$$d(G_1 \times G_2, f_1 \times f_2) = d(G_1, f_1) d(G_2, f_2).$$
So when we're looking for nonabelian examples it suffices to find a nonabelian group with density of the form $\frac{3}{n}$ where $n \mid 100$, and then we can take the direct product with a suitable abelian group to get density $\frac{3}{100}$.
If $f : G \to G$ is a complicated endomorphism of a complicated nonabelian group then it could be quite hard to count the number of elements satisfying $f(g) = g^2$, so for starters let's see what happens if we just set $f(g) = e$ to be the zero endomorphism. Then we're counting the elements satisfying $g^2 = e$, which when $G$ is nonabelian need not be a subgroup. For example, $G = S_3$ has $4$ such elements, with density $\frac{4}{6} = \frac{2}{3}$, which does not have numerator $1$, so this is promising.
Let's see if we can get density $\frac{3}{4}$. The smallest possible example with this property would be a group of order $8$, so let's consider the dihedral group $D_4$. The dihedral group consists of a copy of $C_4$, of which $2$ elements square to the identity, plus $4$ reflections, all of which square to the identity, so the density is $\frac{6}{8} = \frac{3}{4}$ as desired.
So we're done. We can take our final group $G$ to be $\boxed{ D_4 \times C_{25} }$ and our final endomorphism to be $\boxed{ f(g, h) = (e, h) }$.
