  We completely characterize the validity of the inequality
$\|u\|_{Y(\mathbb{R}^n)}\leq C \|\nabla^m u\|_{X(\mathbb{R}^n)}$, where $X$ and
$Y$ are rearrangement-invariant spaces, by reducing it to a considerably
simpler one-dimensional inequality. Furthermore, we fully describe the optimal
rearrangement-invariant space on either side of the inequality when the space
on the other side is fixed. We also solve the same problem within the
environment in which the competing spaces are Orlicz spaces. A variety of
examples involving customary function spaces suitable for applications is also
provided.
