Example of a function $u \in W^{1,p}(\Omega)$ whose extension $\hat{u}$ to be $0$ outside $\Omega$ $\hat{u} \notin W^{1,p}(\mathbb{R}^n)$ Let's consider a function $u \in W^{1,p}(\Omega)$, where $W^{1,p}(\Omega)$ is the Sobolev Space and $\Omega$ is an open set. When we extend $u$ to $\hat{u}$ like this:
$$\hat{u}(x)=\left\{\begin{matrix}
u(x) & in \ \Omega\\ 
0 & \quad  \quad \ in \ \mathbb{R}^n\setminus\Omega
\end{matrix}\right. $$
I know that this extension does not need to be in $W^{1,p}(\mathbb{R}^n)$, but I would like to have some counterexample. Certainly there is no problem in $\hat{u}$ to be in $L^p(\mathbb{R}^n)$ and the (weak) derivative isn't it $\hat{u'}$?

If $\Omega$ is bounded, it suffices to take $u(x)\equiv 1$. Then $\hat u$ cannot be in $W^{1,p}(\mathbb R^n)$ for $p>n$ since it is discontinuous. (Sobolev embedding)
