For the following two sequences of functions $f_n:[0,1]\to \mathbb{R}$, find $f(x)=\lim_{n\to\infty}f_n(x)$, and compare $\lim_{n\to\infty}\int_{0}^{1}f_n$ (if it exists) to $\int_{0}^{1}f$ (if it exists).
(a) $f_n(x)=\begin{cases} n^2x, \quad & 0\leq x \leq\frac{1}{2n} \\ n-n^2x, \quad &\frac{1}{2n}\leq x \leq\frac{1}{n} \\ 0, \quad &\frac{1}{n}\leq x \leq 1 \\ \end{cases}$
(b) $f_n(x)=\begin{cases} 1, \quad &\text{if} \, x=\frac{a}{b} \in \mathbb{Q} \text{ with b}\leq n, \\ 0, \quad &\text{otherwise.} \\ \end{cases}$
For (a), I tried to take limits of $f_n$ piecewise. In the first interval, limits of $f_n(x)=+\infty$. In the second one, I'm not sure whether limits of $f_n(x)=-\infty$. Since I graphed several $f_n$ on the second interval, their function value are always positive. But if I simply calculate $n-n^2x$ as $n\to\infty$, it would be $-\infty$. Besides, I'm also stuck on how to get $\lim_{n\to\infty}\int_{0}^{1}f_n$ and $\int_{0}^{1}f$ . If it's infinity, can I get its integral on piecewise interval?
For(b), I think $f_n(x)$ is always jumping back and forth between 1 and 0, so its integral would be zero and the limit of its integral would be 1 on rational numbers and 0 on irrational numbers. But I'm not sure about $f(x)$ here, and get stuck again on how to get $\lim_{n\to\infty}\int_{0}^{1}f_n$ and $\int_{0}^{1}f$ .
(a): For any $x>0$ the sequence $(f_n(x))$ is $0$ after some stage: $f_n(x)=0$ if $x > \frac 1 n$ or $n >\frac 1x$. Hence the limit of this sequence is $0$ and $f(x)=0$ for all $x$. (Note that $f_n(0)=0$ for all $n$). I will let you compute the integral of $f_n$ to see that $\int f_n$ does not tend to $0=\int f$.
(b): For any rational number $x=\frac p q$ we have $f_n(x)=1$ whenever $ n >q $ so $f(x)=\lim f_n(x)=1$. For $x$ irrational $f(x)=\lim f_n(x)=0$. $\int f(x) dx$ does not exist as a Riemann integral but its Lebesgue integral is $0$.
$\int f_n(x)dx=0$ for all $n$: If $x=\frac a b$ is a rational number(where $a$ and $b$ are integers) with $b \leq n$ and $0 \leq x\leq 1$ then there are only $n$ possible values for $b$ and only $b+1$ values of $a$ for a given $b$. Hence $f_n(x)=0$ except for a finite number of points $x$.