I have the functions: $f,g \in \mathbb{F}(\mathbb{Z},\mathbb{Z}):$
$f(n) = \begin{cases} \frac{n}{2}, & \text{if }n \text{ is even}\\ n+1, & \text{if }n\text{ is odd} \\ \end{cases}$
$g(n) = \begin{cases} n-1, & \text{if }n \text{ is even}\\ 2n, & \text{if }n\text{ is odd} \\ \end{cases}$
I am asked to find $fg$ and $gf$, the notation that my textbook uses for the compositions $f(g(n))$ and $g(f(n))$ respectively. My professor gave me the hint that I will have three cases for at least one of the compositions.
--update--
For the compositions I got these answers:
$fg(n) = \begin{cases} n, & \text{if }n \text{ is even}\\ n, & \text{if }n\text{ is odd} \\ \end{cases} = n$
$gf(n) = \begin{cases} n, & \text{if } n\neq4t, t \in \mathbb{Z}\\ \frac{n}{2}-1, & \text{if }n = 4t, t \in \mathbb{Z} \\ n, & \text{if }n \text{ is odd} \end{cases}$
Do these appear to be the correct answers?
I will do it for $f(g(n))$. The other composition is left to you ;)
If $n$ is even, $g(n) = n-1$ is odd. Then,
$$f(g(n))=f(n-1)=n-1+1=n\,.$$
On the other hand if $n$ is odd, $g(n)=2n$ is even. Then,
$$f(g(n))=f(2n)=\frac{2n}{2}=n\,.$$
It follows that $f(g)$ is the identity.
You should apply an analogous reasoning to compute $g(f(n))$, paying now some extra care when $n$ is even (hint: there is a difference on whether $4$ divides it or not). Can you take it from here?