I'm just going through an example of uniform convergence and there's an example and exercise in my course notes which has me rather confused:
Let $f_n(x) = \begin{cases}\frac{n}{2}x^2+\frac{1}{2n}\quad 0 \leq |x| < \frac{1}{n} \\ |x| \quad \frac{1}{n}\leq |x|\leq 1 \end{cases}$
Then $f_n \rightarrow f$ uniformly since $d_u(f_n,f)\leq \frac{1}{n}$.
(The metric $d_u(f,g)=\sup_{x\in S}\{d(f(x),g(x)\}$, $d$ is the regular Euclidean metric.)
I don't quite understand where that upper bound for the supremum comes form. Would appreciate any insight.
I don't immediately see $\frac1n$ as a bound, but I do see $\frac2n$.
Note that $f_n$ and $f$ agree for $\frac1n\leq |x|\leq 1$, and for $|x|<\frac1n$ we have (where the ambiguous sign is the opposite of the sign of $x$) $$f_n(x)-f(x) = \tfrac n2x^2+\tfrac1{2n} \mp x = \tfrac n2(x\mp\tfrac1n)^2$$ For $|x|<\tfrac1n$ we then have $$f_n(x)-f(x)\leq \tfrac n2(\overbrace{\tfrac 1{n^2} + \tfrac2{n^2}+\tfrac1{n^2}}^{(\tfrac1n+\tfrac1n)^2}) = \tfrac2n$$