Idea. Reduce to a diagonal S. Then tr(ΛP′)=∑λipii′ is a weighted sum with weights in [0,1] adding up to k, which is maximal when the weights sit on the k largest λi.
Step 1: reduction. Let S=QΛQT and P an orthogonal projection of rank k (i.e. P=PT=P2, trP=k). Put P′=QTPQ; it is again an orthogonal projection of rank k and
tr(SP)=tr(QΛQTP)=tr(ΛQTPQ)=tr(ΛP′)=i∑λipii′.
Step 2: the weights. Let pi=pii′. Then pi=eiTP′ei=eiTP′TP′ei=∣P′ei∣2∈[0,1] (because P′ is a projection, ∣P′v∣≤∣v∣), and ∑ipi=trP′=k.
Step 3: the bound. Write
i∑λipi−kλk=i∑(λi−λk)pi.
For i≤k, λi−λk≥0 and pi≤1, so those terms are at most λi−λk. For i>k, λi−λk≤0 and pi≥0, so those terms are ≤0. Therefore
i∑λipi−kλk≤i≤k∑(λi−λk)=i≤k∑λi−kλk,
that is tr(SP)≤λ1+⋯+λk.
Step 4: attained. Let P0 be the orthogonal projection onto the span of the first k columns of Q (the top k eigenvectors). Then tr(SP0)=λ1+⋯+λk. So the maximum exists (also because the set of such projections is compact) and equals the sum.
Step 5: convexity. For each fixed P, S↦tr(SP) is linear. The function S↦λ1+⋯+λk is the maximum of these linear functions, hence convex.
Remark. For k=1 this is the Rayleigh formula for λmax (previous problem). For k=n it is the trace, which is linear.
Lesson. Variational formulas as maxima of linear functions give convexity for free.