Consider two Groups $\left(G,\cdot\right)$ and $\left(H,\times\right)$
And let $f$ be a function $f:G\rightarrow H$
Then $f$ is a Group Homomorphism if $\forall g_{1}, g_{2} \in G$ we have
$f\left(g_{1} \cdot g_{2}\right) = f\left(g_{1}\right) \times f\left(g_{2}\right)$
and that the inverse of $G$ is preserved, i.e.
$f\left(g_{1}^{-1}\right) = f\left(g_{1}\right)^{-1}$
In the textbook I'm reading this is essential so that the identity for $G$ here $1_{G}$ maps onto the identity of $H$ here $1_{H}$ .
This is illustrated simply with
$f\left(g_{1} \cdot g_{1}^{-1}\right) = f\left(1_{G}\right) = f\left(g_{1}\right) \times f\left(g_{1}^{-1}\right) = f\left(g_{1}\right) \times f\left(g_{1}\right)^{-1} = 1_{H}$
And so,
$f\left(1_{G}\right) = 1_{H}$
I however went about it differently (I'm sure I'm missing something) though and I was wondering if people could have a look over and see if what I've done is valid and if not where I went wrong.
So my method was
$f\left(1_{G}\cdot 1_{G}\right) = f\left(1_{G}\right) = f\left(1_{G}\right) \times f\left(1_{G}\right)$
And so
$f\left(1_{G}\right)^{-1} \times f\left(1_{G}\right) = f\left(1_{G}\right)^{-1} \times f\left(1_{G}\right) \times f\left(1_{G}\right)$
$1_{H} = 1_{H} \times f\left(1_{G}\right) = f\left(1_{G}\right)$
And so
$1_{H} = f\left(1_{G}\right)$
Is this valid? as in can we show that the identity of $G$ maps to the identity of $H$ without having to impose the inverse requirement as before?
Thanks
Your method looks correct. It's a fact that a group homomorphism preserves the identity element.