Bounded operator that does not attain its norm

For an example in $L^2[0,1]$, consider the operator of multiplication by $x$, i.e. $(Tf)(x) = x f(x)$.


In finite dimensional spaces all operator is norm attaining: we use the fact that the unit ball is compact. Then $\{Tx,\lVert x\rVert=1\}$ is bounded because it's the image of a compact set by a continuous map.

Otherwise, it's not true. Consider $H:=\ell^2(\Bbb N)$. Define $Tx:=\sum_{n\geq 1}\left(1-\frac 1n\right)\langle x,e_n\rangle e_n$ where $e_n$ is the sequence whose $n$-th term is $1$, the others $0$. The norm of $T$ is $1$, but for $x\neq 0$, $$\lVert Tx\rVert^2=\sum_{n\geq 1}\left(1-\frac 1n\right)^2|\langle x,e_n\rangle|^2\leq \sum_{n\geq 1}|\langle x,e_n\rangle|^2=\lVert x\rVert^2.$$ The last inequality isn't an equality, since $\langle x,e_n\rangle\neq 0$ for some $n$.


On $\ell^2(\mathbb{N})$, take $T\in B(\ell^2(\mathbb{N}))$ to be the map $$ (a_n)_{n\in\mathbb{N}}\mapsto \left((1-\frac1n)a_n\right)_{n\in\mathbb{N}} $$

Since every coefficient is multiplied by scalar less than $1$, $T$ is contractive (i.e. $\|T\|\leq1$). Also, $\|Te_n\|=(1-\frac1n)$, where $e_n$ are the elements in the canonical basis, so $\|T\|=1$. And $$ \|T(a_n)\|^2=\sum_n|(1-\frac1n)a_n|^2<\sum_n|a_n|^2=\|(a_n)\|_2^2, $$ so the norm is never attained.

Edit: another easy example is as follows. Let $H=L^2[0,1]$, and let $T$ be the operator such that $$ (Tf)(t)=tf(t). $$ Then it is easy to see that $\|T\|=1$ (using functions supported near $1$). And, given any $f\in L^2[0,1]$, if $f\ne0$ then $$ \|Tf\|_2^2=\int_0^1t^2|f(t)|^2<\int_0^1|f(t)|^2=\|f\|_2^2 $$ (the inequality has to be strict: otherwise we get $\int_0^1(1-t^2)|f(t)|^2=0$, which implies $f=0$).