A question on optimal Sobolev inequality.  Let us consider the Sobolev inequality $||u||_{L^p} \le C||u||_{H^1}$ for $2 <p< 2^*$, where the constant $C$ depends on $p$ and the domain. My question is, how can one see that the optimal Sobolev constant is attained at a positive function $f>0$? 
By taking the absolute value, it is easy to see that we may take $f\ge 0$. Also when the domain is bounded, we may apply maximal principle. How about when the domain is not bounded? 
 A: Here is a variational argument to prove that the maximizers do not change sign.
If $f \in H^1 (\mathbb{R}^N)$ be a maximizer, $u$ can be written as 
$$
  f = f_+ - f_-,
$$
with $f_+ \ne 0$ and $f_- \ne 0$.
Moreover
$$
  \Vert f \Vert_{H^1}^2 =  \Vert f_+ \Vert_{H^1}^2 +  \Vert f_- \Vert_{H^1}^2
$$
and
$$
  \Vert f \Vert_{L^p}^p=  \Vert f_+ \Vert_{L^p}^p +  \Vert f_- \Vert_{L^p}^p.
$$
We have thus
$$
  \Vert f \Vert_{L^p}^2 = \frac{\Vert f_+\Vert_{L^p}^p}{\Vert f\Vert_{L^p}^p} \Vert f\Vert_{L^p}^2 + \frac{\Vert f_-\Vert_{L^p}^p}{\Vert f\Vert_{L^p}^p} \Vert f\Vert_{L^p}^2.
$$
By strict concavity of the map $t \in \mathbb{R} + \mapsto \vert t \vert^{\frac{2}{p}}$ and the optimality of (f),
$$
\Vert f \Vert_{L^p}^2
<\Vert f_+ \Vert_{L^p}^2 + \Vert f_- \Vert_{L^p}^2
\le \frac{\Vert f \Vert_{L^p}^2}{\Vert f \Vert_{H^1}^2}
\bigl(\Vert f_+ \Vert_{H^1}^2 + \Vert f_- \Vert_{H^1}^2 \bigr)
= \Vert f \Vert_{L^p}^p,
$$
which is a contradiction.
Essentially, the argument says that if $f$ changes sign then taking either $f_+$ or $f_-$ increases the quotient.
The argument extends to maximizers for embedding of $W^{1, q}$ with $1 \le q < \infty$.
A: For bounded domains it follows from the Rellich-Kondrashov compactness theorem $H^1\subset\subset L^p$.
If you denote by 
$$
S = \inf \frac{\|u\|{H^1}}{\|u\|_{L^p}}
$$ 
and take a sequence $\{u_n\}$ such that $\|u_n\|_{H^1}\to S$ and $\|u_n\|_{L^p} = 1$ 
then there exists a subsequence $\{u_{n_k}\}$ and a function $u$ such that $u_{n_k}\rightharpoonup u$ weakly in $H^1$ and so
$$
\|u\|_{H^1}\le \liminf \|u_{n_k}\|_{H^1} = S
$$
Now, you apply R-K Theorem to conclude that $u_{n_k}\to u$ strongly in $L^p$ and so $\|u\|_{L^p}=1$.
By the maximum principle, as you said, it follows that the function $u$ must be positive inside the domain.
