#### Exercise 6.5

Solution: If $a=0$, for any $\e >0$ and any $x_0\in\ R$, and any $\delta >0$, we have\[|f(x)-f(x_0)|=|b-b|=0 < \e\] for all $|x-x_0|<\delta$. Hence $f$ is continuous at $x_0$. Thus $f$ is continuous.

If $a\ne 0$, for any $\e >0$ and any $x_0\in\ R$, let $\delta =\frac{\e}{|a|}$, then for all $|x-x_0|<\delta$ we have\[|f(x)-f(x_0)|=|(ax+b)-(ax_0+b)|=|a||x-x_0| < |a| \frac{\e}{|a|} =\e.\]Hence $f$ is continuous at $x_0$. Thus $f$ is continuous.

#### Exercise 6.6

Solution: We have $$a\in f^{-1}(\cup_{\alpha} B_\alpha) \iff f(a)\in \cup_{\alpha} B_\alpha$$ $$\iff f(a)\in B_{\alpha_0}\text{ for some }\alpha_0$$ $$\iff a\in f^{-1}(B_{\alpha_0}) \iff a\in \cup_{\alpha} f^{-1}(B_\alpha).$$

#### Exercise 6.7

Solution: Consider the sequence $(a_n)$ given by $a_n=-\frac{1}{n}$, then $(a_n)\to 0$ and $$(f(a_n))\to -1 \ne 1=f(0).$$ Hence by Note 6.17, $f$ is not continuous at $c=0$.

#### Exercise 6.8

Solution:

(a) If $x\in \mathbb Q$, we require that $1\leqslant x$. If $x\not\in \mathbb Q$, then we require that $0\leqslant x$. Hence the answer is $$\{x\in \mathbb Q: x\geqslant 1\}\cup \{x\not\in\mathbb Q:x > 0\}.$$(b) If $x\in\mathbb Q$, then we require that $1\leqslant x^2$, hence $x \leqslant -1$ or $x\geqslant 1$. If $x\not\in \mathbb Q$, then we require that $0 \leqslant x^2$, hence $x\not\in\mathbb Q$. The result is $$\{x\in \mathbb Q: x\geqslant 1\}\cup \{x\in \mathbb Q: x\leqslant -1\}\cup \{x\not\in\mathbb Q\}.$$(c) If $x\in\mathbb Q$, then $g(f(x))=g(1)=1$ and $f(x)=1$. Hence $g(f(x))-f(x)=0$; if $x\not\in\mathbb Q$, then $g(f(x))=g(0)=0$ and $f(0)=0$. Hence $g(f(x))-f(x)=0$ as well. Therefore, the result is always zero.

#### Exercise 6.9

Solution: Note that $|k(x)|=|x|$, $\lim\limits_{x\to 0}k(x)$ exists by Exercise 6.13 below. We then show that for any $a\ne 0$, $\lim\limits_{x\to a}k(x)$ does not exist.

For any $n\in\mathbb N$, since $\mathbb Q$ is dense in $\R$. Hence we can find a rational number $a_n$ such that $ a < a_n < a+\frac{1}{n}$. Then $(a_n)\to a$, and $(k(a_n))=(a_n)\to a$. Similarly, we can find a sequence $(b_n)$ consisting of irrational numbers which converges to $a$, but $(k(b_n))=(-b_n)\to -a$. Since $a\ne0$, we have $a\ne -a$. By Note 6.17, we conclude that $\lim\limits_{x\to a}k(x)$ does not exist.

#### Exercise 6.12

Solution: Let $x_0\in \R$ and denote $\alpha:=f(x_0)$. We show that $\alpha=0$.

Since $f(x)$ is continuous at $x_0$, for any $\e >0$, there exists $\delta>0$ such that $|f(x)-\alpha| < \e$ for all $|x-x_0| < \delta$. Since $\mathbb Q$ is dense in $\R$, we find a rational number $x’$ in the $\delta$-neighborhood of $x_0$. Then we have $$|f(x’)-\alpha|<\e\Longrightarrow |0-\alpha|<\e.$$Hence we have $|\alpha| < \e$ for all $\e >0$.

By Exercise 1.9 (b), we conclude that $\alpha=0$. Hence $f(x)=0$ for all $x\in \R$.

#### Exercise 6.13

Solution: Clearly we have $|f(0)|\leqslant 0$ and hence $f(0)=0$. To show $f$ is continuous at $0$. We show for any $\e$, there exists $\delta >0$ such that provided $|x|<\delta$ we have $|f(x)| < \e$.

To this purpose, we let $\delta =\e$. Then since $|f(x)|\leqslant |x|$ for all $x\in \R$, we have\[|f(x)|\leqslant |x| < \e.\]Hence we are done.

#### Exercise 6.14

Solution: Clearly we have $|f(0)|\leqslant |g(0)|=0$ and hence $f(0)=0$. To show $f$ is continuous at $0$. We show for any $\e >0$, there exists $\delta >0$ such that provided $|x|<\delta$ we have $|f(x)| < \e$.

Since $g$ is continuous at $0$ and $g(0)=0$, there exists $\delta >0$ such that provided $|x|<\delta$ we have $|g(x)| < \e$. Hence we also have $$|f(x)|\leqslant |g(x)| < \e.$$This completes the proof.

#### Exercise 6.15

Solution:

(a) Consider the function $f:\R\to \R$ defined by\[f(x)=\begin{cases}x,&\text{if }x=1,\frac{1}{2},\frac{1}{3},\cdots\\ 0, &\text{otherwise}.\end{cases}\](b) Consider the function $f:\R\to \R$ defined by\[f(x)=\begin{cases}1,&\text{if }x=1,\frac{1}{2},\frac{1}{3},\cdots\\ 0, &\text{otherwise}.\end{cases}\]

#### Exercise 6.16

Solution: Define $f:[0,1]\to \R$ by\[f(x)=\begin{cases}\frac{1}{x}, &\text{if }x\ne 0\\ 0, &\text{if }x=0.\end{cases}\]It is clear that $\sup_{x\in [0,1]}f(x)=\infty$.

#### Exercise 6.17

Solution:

(a) Suppose $f$ is continuous at $x_0$, then for any $\e >0$, there exists $\delta >0$ such that $|f(x)-f(x_0)| < \e$ provided that $|x-x_0| < \delta$. By the triangle inequality, we have\[||f(x)|-|f(x_0)||\leqslant |f(x)-f(x_0)|<\e,\]for all $x \in (x_0-\delta,x_0+\delta)$. Hence $|f|$ is continuous at $x_0$. Since $x_0$ is chosen arbitrarily, we conclude that $|f|$ is continuous.

(b) Let $f(x)$ be defined by\[f(x)=\begin{cases}1,&\text{if $x$ is rational}, \\ -1, &\text{otherwise}.\end{cases}\]Then $f$ is nowhere continuous but $|f|$ is a constant function and hence continuous.

#### Exercise 6.18

Solution: For any function $f(x)$, we set\[E(x)=\frac{f(x)+f(-x)}{2},\quad O(x)=\frac{f(x)-f(-x)}{2}.\]Then\[E(-x)=\frac{f(-x)+f(-(-x))}{2}=\frac{f(-x)+f(x)}{2}=E(x),\]\[O(-x)=\frac{f(-x)-f(-(-x))}{2}=\frac{f(-x)-f(x)}{2}=-O(x).\]Hence $E(x)$ is even and $O(x)$ is odd. In particular, we see that the continuity of $f$ is not necessary.

#### Exercise 6.19

Solution: Let $\alpha(x)$, $\beta(x)$ be two continuous functions, we show that $\max\{\alpha(x),\beta(x)\}$ is continuous too. Note that $\alpha(x)-\beta(x)$ is also continuous and so is $|\alpha(x)-\beta(x)|$ by Exercise 6.17 (a). Therefore by Exercise 1.7 we have\[\max\{\alpha(x),\beta(x)\}=\frac{\alpha(x)+\beta(x)+|\alpha(x)-\beta(x)|}{2}\]is continuous as well.

Let $g(x)=\max\{f(x),0\}$ and $h(x)=\max\{-f(x),0\}$. Then by the previous paragraph, $g$ and $h$ are continuous. Clearly, $g$ and $h$ are nonnegative. Hence it suffices to show that $f(x)=g(x)-h(x)$.

If $f(x)\geqslant 0$, then $g(x)=f(x)$, $h(x)=0$, and $$g(x)-h(x)=f(x)-0=f(x).$$If $f(x)< 0$, then $g(x)=0$, $h(x)=-f(x)$, and $$g(x)-h(x)=0-(-f(x))=f(x).$$Hence we always have $f(x)=g(x)-h(x)$.

#### Exercise 6.21

Solution:

(a) It is possible. Let $A=(0,4\pi)$, $B=[-1,1]$, and $f(x)=\sin x$.

(b) Impossible. If $A$ is finite closed, then $A$ is compact. Hence by Theorem 6.29 that $f(A)$ is also compact. But $B$ is finite open, not compact. Therefore $f(A)\ne B$. This shows $f(A)=B$ is impossible for finite closed $A$ and finite open $B$.

#### Exercise 6.22

Solution: Define the function $g:[0,\frac12]\to \R$ by $g(x)=f(x+\frac{1}{2})-f(x)$, then $g$ is continuous on $[0,\frac{1}{2}]$. Then it suffices to show that $g(x)=0$ for some $x\in [0,\frac12]$.

Since $f(0)=f(1)$ we have\[g(0)g(1/2)=(f(1/2)-f(0))(f(1)-f(1/2))=-(f(1/2)-f(0))^2 \leqslant 0.\]If $g(0)=0$ or $g(\frac12)=0$, then we are done. If $g(0)\ne 0$ and $g(\frac12)\ne 0$, then they have different signs. Hence by Theorem 6.37 (Intermediate value theorem), there exists $\alpha \in (0,\frac12)$ such that $g(\alpha)=0$. Namely $f(\alpha)-f(\alpha+\frac12)=0$. Let $x=\alpha$ and $y=\alpha+\frac12$. We are done.

#### Exercise 6.23

Solution: Recall that $\mathbb Q$ is dense in $\R$. This exercise is basically the same as Exercise 6.12.

#### Exercise 6.24

Solution:

(a) Suppose $f(A)$ is not bounded, then for any $M>0$ there exists $a\in A$ such that $|f(a)|>M$. Let $M=1$, we find $a_1\in A$ such that $|f(a_1)|> 1$. Let $M=|f(a_1)|+1$, we find $a_2\in A$ such that $|f(a_2)| > f(a_1)+1$. Continuing in this way, we define inductively a sequence $(a_n)$ such that $$|f(a_{n+1})| > |f(a_n)|+1$$ for all $n\in\mathbb N$. Since $A$ is bounded, the sequence $(a_n)$ has a convergent subsequence $(a_{n_k})$. By abuse of notation, we denote this subsequence by $(a_n)$ again. It is easy to see that we still have $|f(a_{n+1})| > |f(a_n)|+1$ for all $n\in\mathbb N$. But $(a_{n+1}-a_{n})\to 0$ as $n\to infty$ while $|f(a_{n+1})-f(a_n)| > 1$. Hence $f$ is not uniformly continuous. Thus we obtain a contradiction. This shows the assumption $f(A)$ is not bounded is impossible, completing the proof.

(b) $f(x)=1/x$ for $x\in (0,1)$.

(c) $f(x)=\sin (1/x)$ since $(\frac{2}{n\pi})$ is Cauchy but $(f(\frac{2}{n\pi}))$ is not.

#### Exercise 6.25

Solution: For any $\e >0$, let $\delta =1/2$. For any $x,y\in\Z$ such that $|x-y| < 1/2$, we must have $x=y$. Hence $|f(x)-f(y)|=0 < \e$ for all $|x-y| < 1/2$. Therefore $f$ is uniformly continuous.

#### Exercise 6.26

Solution: Note that $[a,b]$ is compact. Since $f$ is continuous and $[a,b]$ is compact, $f$ can attain its minimum $L=f(x_0)$ for some $x_0\in [a,b]$. By assumption, $L=f(x_0)> 0$. Since $L=f(x_0)$ is a minimum, we have $f(x)\geqslant f(x_0)=L$ for all $x\in [a,b]$.

#### Exercise 6.27

Solution: Let $f$ be continuous. Note that $[0,1]$ is closed and bounded, hence by Heine-Borel Theorem $[0,1]$ is compact. By Theorem 6.29 $f([0,1])$ is compact. But $(0,1)$ is not compact (not closed). Hence $f([0,1])=(0,1)$ is impossible.

#### Exercise 6.28

Solution:

(a) Let $f:(0,1)\to \R$ be given by $f(x)=1/x$. Let $a_n=\frac{1}{n}$, then $(a_n)$ is clearly a Cauchy sequence since it converges to zero. But $f(a_n)=n$ and hence $(f(a_n))$ diverges to infinity. Hence $(f(a_n))$ is not Cauchy.

(b) Let $\e >0$. Since $f$ is uniformly continuous, there exists $\delta > 0$ such that $|f(x)-f(y)| < \e$ provided $|x-y| < \delta$. Since $(a_n)$ is Cauchy, there exists $N$ such that $|a_n-a_m| < \delta$ for all $n,m > N$. Hence for $n, m > N$, we have $ |f(a_n)-f(a_m)| < \e$ since $|a_n-a_m| < \delta$. Therefore, it shows that $(f(a_n))$ is also Cauchy.

#### Exercise 6.29

Solution: By assumption, we have $f(a)-g(a) < 0$ and $f(b) – g(b) >0$. Hence $$ 0\in (f(a)-g(a),f(b)-g(b)).$$ Since $f(x)-g(x)$ is continuous on $[a,b]$, by Theorem 6.37, there exists $x\in [a,b]$ such that $f(x) -g(x)=0$, namely $f(x)=g(x)$.

#### Exercise 6.30

Solution:If $f(0)=0$, then we are done. Since $f(0)\in [0,1]$, we can assume that $f(0) > 0$.

If $f(1)=1$, then we are done. Since $f(1)\in [0,1]$, we can assume further that $f(1) < 1$.

Then let $g(x)=x$ in Exercise 6.29. The exercise follows.

#### Exercise 6.31

Solution:

(a) It is clear that $1+x^4+\sin ^2(x)$ is continuous and always greater than 1. Hence $\dfrac{242}{1+x^4+\sin^2(x)}$ is continuous as well, so is\[g(x):=x^{83}+x^{17}+\dfrac{242}{1+x^4+\sin^2(x)}.\]We have $g(0)=242 > 201$ and $$g(1) < 1+1+\frac{242}{2} < 201.$$Hence by setting $f(x)=201$, $a=0$, and $b=1$ in Exercise 29, we conclude that there exists $x\in (0,1)$ such that $g(x)=f(x)=201$.

(b) It is clear that $\cos x$ and $x$ are continuous. Note that\[\cos 0=1 > 0,\quad \cos\frac{\pi}{2}=0 < \frac{\pi}{2}.\]Hence by setting $f(x)=x$, $g(x)=\cos x$, $a=0$, and $b=\frac{\pi}{2}$, we conclude that there exists $x\in (0,\frac{\pi}{2})$ such that $\cos x =g(x)=f(x)=x$.