Has this function of density matrices a maximum? I consider the $n\times n$ density matrices $M$ in a given basis.
$V$ is the $n$-dimensional vector with all components equal to 1.
I take the mean value of $M$ in $V$. It is the sum of the $n^2$ components of $M$.
I would like to know if there is a maximum when I take all possible $M$ (with trace $= 1$)
 A: Let $D_n$ be the set of $n\times n$ density matrices, $V = \begin{pmatrix} 1 & 1 & \cdots & 1 \end{pmatrix}^T \in \mathbb R^n$.
We are looking for :
$$\sup_{M\in D_n} V^T MV$$
Now, for any $M\in D_n$, there are non-negative real numbers $p_1,\ldots,p_n$ with $\sum p_i = 1$ and a unitary matrix $U\in\operatorname{U}(n)$ such that :
$$ M = U^T \begin{pmatrix} p_1\\& \ddots \\&&p_n \end{pmatrix}U$$
Then, we have :
\begin{align}
V^T M V &= (UV)^T \begin{pmatrix} p_1\\& \ddots \\&&p_n \end{pmatrix}(UV) \\
&\leq (\max p_i)\|V\|^2\\
&\leq n
\end{align}
This bound is reached for $M = \frac{1}{n} VV^T$, so :
$$\sup_{M\in D_n} V^T MV = n $$
A: Consider a Hilbert space $H$ of dimension $n$ and let $\rho$ denote a density matrix, which we can express in its spectral form:
$$\rho \equiv \sum\limits_{k=1}^n \lambda_k |k\rangle\langle k| \quad ,$$
with its eigenvectors $\{|k\rangle\}_{k=1}^n$ and increasingly ordered eigenvalues $\lambda_k$:
$$  \lambda_1 \leq \lambda_2 \leq ... \leq \lambda_n \quad .$$
Thus, for any (fixed) element $|v\rangle \in H$ it holds that
$$ \langle v|\rho|v\rangle  = \sum\limits_{k=1}^n \lambda_k \, |\langle v|k\rangle|^2  \quad .$$
Quite obvious bounds are:
$$\lambda_1\,  ||v||^2 \leq  \langle v|\rho|v\rangle  \leq \lambda_n \, ||v||^2 \quad . $$
The minimum and maximum eigenvalues of course depend on the density matrix, but are also bounded by $0$ and $1$ for all density matrices, respectively.
We conclude that given a fixed $|v\rangle \in H$, the upper bound of $ \langle v|\rho|v\rangle $ for all density matrices is simply $||v||^2$.
For instance if $||v|| \neq 0$, then the density matrix
$$\rho_v \equiv \frac{|v\rangle \langle v|}{||v||^2} $$
'reaches' this bound and is thus a maximizer.
