Show pointwise and uniform convergence on an example I wrote down my proof, however it may not be formal. Can you please suggest improvements?
Let ${g_n}(x) = \begin{cases}
0,  & \text{if x in [-n,n]} \\
f(x), & \text{if otherwise}
\end{cases}$

*

*Show that ${g_n}(x)$ converges pointwise to the $g(x) = 0$.

*Show that ${g_n}(x)$ converges uniformly to $g(x)$ if and only if  $\lim_{x\to \infty} f(x) = 0$.

Attempt: Pointwise convergence is easy to show. When you fix a number x, then no matter what that x is, as n goes to $\infty$, the interval actually become the real line, then x is included in.
For the second part of the question, assume that ${g_n}(x)$ converges uniformly to $g(x)$. Then $\lvert {g_n}(x)\rvert \lt \epsilon$, as ${n} \rightarrow \infty$. Since it is a piecewise function, assume that $x \in [-n,n]$. Then, the interval forms the real line as ${n}\rightarrow \infty$, so for any ${x} \in \mathbb R$, function takes zero value, which is less than epsilon.
Assume that ${x} \rightarrow \infty$, simultaneously with n (I am not sure if you can assume that, if you cannot, then fix x > n+$\epsilon$). Then function ${g}$ becomes ${f(x)}$, $\lvert {f}(x)\rvert \lt \epsilon$ must be hold since g is uniformly convergent to the 0. Then it forces ${f(x)} = 0,{x} \rightarrow \infty$. Reverse is simple.
 A: The first part of your answer, on pointwise convergence, has the right idea. That is, for any $x \in \mathbb{R}$, we we have that $g_n(x) = 0$ for all $n \geq \lvert x \rvert$. (And of course for any $x \in \mathbb{R}$, there is an integer $N > \lvert x \rvert$). Thus $g_n(x) \to 0$ pointwise.
The second part of your answer is a bit confused. For the second part, there are two things to prove.

*

*If $g_n \to g$ uniformly, then $\lim_{\lvert x \rvert \to \infty} f(x) = 0$.

*If $\lim_{\lvert x \rvert \to \infty} f(x) = 0$, then $g_n \to g$ uniformly.

I note that I've slightly changed the condition on the limit of $f$. The original formulation, where $\lim_{x \to \infty} f(x)$, is actually false. That is, $\lim_{x \to \infty} f(x) = 0$ is not enough to force $g_n \to g$ uniformly. (Explicit counterexample: let $f$ be identically $1$ for $x < 0$ and identically $0$ for $x \geq 0$).

For the second part of the question, assume that ${g_n}(x)$ converges uniformly to $g(x)$. Then $\lvert {g_n}(x)\rvert \lt \epsilon$, as ${n} \rightarrow \infty$. Since it is a piecewise function, assume that $x \in [-n,n]$. Then, the interval forms the real line as ${n}\rightarrow \infty$, so for any ${x} \in \mathbb R$, function takes zero value, which is less than epsilon.

I'm not sure what you're trying to prove here. I notice that $f$ isn't mentioned anywhere here. It's also unclear what you consider for $x \not \in [-n, n]$.

Assume that ${x} \rightarrow \infty$, simultaneously with n (I am not sure if you can assume that, if you cannot, then fix x > n+$\epsilon$). Then function ${g}$ becomes ${f(x)}$, $\lvert {f}(x)\rvert \lt \epsilon$ must be hold since g is uniformly convergent to the 0. Then it forces ${f(x)} = 0,{x} \rightarrow \infty$. Reverse is simple.

You can't assume $x \to \infty$ simultaneously with $n$. The reason is that uniform convergence concerns all $x$ for sufficiently large $n$.
I'm also not sure what "Reverse is simple" means, or what reverse is being considered.

But this is a good start. I'll write how I might say one of the two directions.
Let's prove that if $g_n \to g$ uniformly, then $\lim_{\lvert x \rvert \to \infty} f(x) = 0$.
To do this, we need to show that for any $\epsilon > 0$, there exists some $x_0$ (possibly depending on $\epsilon$) such that for all $\lvert x \rvert > x_0$, we have that $\lvert f(x) \rvert < \epsilon$.
As $g_n \to g$ uniformly, we know that for there exists an $N$ (possibly depending on $\epsilon$) such that for all $n > N$, we have that $\lvert g_n - g \rvert < \epsilon$. Here, $g$ is the identically $0$ function, to this last inequality is equivalent to $\lvert g_n \rvert < \epsilon$.
(Thus far, I've only written definitions. Now I'll use particular information.).
As $\lvert g_n \rvert < \epsilon$ for all $n > N$, we have for example that $\lvert g_{N + 1}(x) \rvert < \epsilon$. By the definition of $g_n$, this shows that $\lvert f(x) \rvert < \epsilon$ for all $x$ with $\lvert x \rvert \geq N + 1$. As such an $N$ can be found for any $\epsilon > 0$, we see that $f(x) \to 0$ as $\lvert x \rvert \to \infty$.

When first working with new topics, I think that explicitly writing down the relevant definitions and then inserting the relevant details is a good way to work. I leave the converse direction to you. Good luck!
