Solution to Abstract Algebra by Dummit & Foote 3rd edition Chapter 1.1 Exercise 1.1.24
Let $G$ be a group and let $a,b \in G$ such that $ab = ba$. Prove that $(ab)^n = a^n b^n$ for all $n \in \mathbb{Z}$.
Solution: First we prove two technical lemmas.
Lemma 1. If $a,b \in G$ with $ab = ba$, then $a b^n = b^n a$ for all $n \in \mathbb{Z}^+$.
We proceed by induction on $n$. The statement is clear for the base case $n = 1$. Now suppose the statement holds for some integer $n \geq 1$; then $$ab^{n+1} = a b^n b = b^n a b = b^n b a = b^{n+1} a.$$ Thus by induction the conclusion holds for all positive integers $n$. $\blacksquare$
Lemma 2. If $a,b \in G$ with $ab = ba$, then $a^m b^n = b^n a^m$ for all positive integers $n$ and $m$. (Not needed)
We proceed by induction on $n$. The statement holds for the base case $n = 1$ by the previous lemma. Now suppose that for some $n \geq 1$, we have $a^m b^n = b^n a^m$ for all $m$. Then $$a^m b^{n+1} = a^m b^n b = b^n a^m b = b^n b a^m = b^{n+1} a^m,$$ using Lemma 1. Thus, by induction, the statement holds for all integers $n$ and $m$. $\blacksquare$
We now move to the main result.
The statement is trivial if $n = 0$. We will prove the statement for $n > 0$ by induction. For the base case $n = 1$, we have $(ab)^1 = ab = a^1 b^1$. For the inductive step, suppose that for some positive integer $n$, we have $(ab)^n = a^n b^n$ for all such $a$ and $b$. Then by Lemma 1 $$(ab)^{n+1} = ab(ab)^n = ab a^n b^n = a a^n b b^n = a^{n+1} b^{n+1}.$$ Thus by induction, we have $(ab)^n = a^n b^n$ for all positive integers $n$. Suppose finally that $n < 0$. Then $$(ab)^n = ((ab)^{-n})^{-1} = (a^{-n} b^{-n})^{-1} = (b^{-n} a^{-n})^{-1} = a^n b^n.$$