Solution (source code)

= Solution

For the added trial term $q_n=x^ne^{-Ax}$, the left <Dirichlet boundary condition> is automatic for a positive integer $n$. At the right endpoint,
$$
q_n'(1)=e^{-A}(n-A).
$$
To preserve $y'(1)=0$ for an arbitrary variational coefficient $C$, choose $\boxed{A=n}$. Then minimize the <Rayleigh quotient> of $xe^{-x}+Cx^ne^{-nx}$ over $C$.

Since $C=0$ remains available, this optimization cannot worsen the original upper bound. For $n=1$, the added function is a multiple of the first trial, so the quotient does not change: an independent choice $n\geq2$ is needed for extra freedom. More generally, several such functions form the <exponential-polynomial trial space for a mixed Sturm-Liouville problem>, and the <Rayleigh-Ritz method> reduces minimization to a small <generalized eigenvalue problem>.