The following unusual optimization problem came up and I don't know where to begin:


Maximize over the real variables $x\_1, \dots, x\_n$ the sum
$$
S = \sum\_{r = 1}^n \frac{1}{x\_1 + \dots + x\_r}
$$
subject to the constraints $1 \leq x\_1 \leq x\_2 \leq \dots \leq x\_n$ and subject to 
$$
p^{x\_1} + \dots + p^{x\_n} \leq t p
$$


Here $p < 1$ is a constant which may become very small, and $1 \leq t \leq n$. 


Any upper bound on $S$ would be useful. Clearly $S \leq \log n$, but for $t$ small much better constraints should be available. 


If you use the Lagrange multiplier approach to constrained optimization you get equations of the form
$$
p^{x\_{i+1}} = p^{x\_i} - \frac{\lambda}{(x\_1 + \dots + x\_i)^2}
$$
for some $\lambda > 0$. (This ignores the boundary constraint $x \geq 0$)


This gives a recursive equation to solve for all $\hat x\_i$ in terms of $\hat x\_1, \lambda$. Experiments show that the sequence $\hat x\_i$ increasingly converges to some constant $y$, and this convergence is rapid.


If you could show that the convergence was rapid enough, then you would basically know that critical situation is one in which all the $x\_i$ are equal. It is quite easy to bound $S$ in this case.



An Optimization problem
Calculus is a tough discipline. No wonder our students don't get it. On the other hand, analysis is an easy subject (so easy that we find it unnecessary to teach it to our students). So, let's do analysis instead of calculus. The key difference between the two is that in analysis we do not care much about constant factors. We'll get the answer up to a factor of $4$.


Let $S(x)$, $x=(x\_1,x\_2,\dots)$ be the objective function as written. Define $y$ by $y\_r=1$ if $r\le t$, $rp^{y\_r}=tp$ if $r\ge t$. Obviously, $x\_r\ge y\_r$ for every $r$, so $S(x)\le S(y)$. Our aim will be to show that there exists $x$ satisfying all the restrictions such that $S(x)\ge S(y)/4$.


Note that $S(y)=\sum\_{r\le t}+\sum\_{t< r< t+1}+\sum\_{r\ge t+1}=S\_1+S\_2+S\_3$.
If $S\_1\ge S(y)/4$, we can just take $x\_r=y\_r$ for $r\le t$ and $x\_r=+\infty$ for $r>t$.
If $S\_2\ge S(y)/4$, we can take $x\_1=y\_k$ where $k\in(t,t+1)$ (there can be only one number there) and $x\_r=+\infty$ for $r>1$. 
The only remaining option is $S\_3\ge S(y)/2$. In this case we note that
$$
\sum\_{r\ge t+1}p^{2y\_r}=\sum\_{r\ge t+1}\frac{(tp)^2}{r^2}\le tp^2\le tp
$$  

so if we take $x\_r=2y\_{r+k-1}$ where $k$ is the least integer exceeding $t+1$, we'll get $S(x)\ge S\_3/2\ge S(y)/4$.


If you want a more explicit formula, then again, algebra is a hard subject but analysis is an easy one. Start with noticing that $S(y)$ is larger than $T(y)=\sum\_r \frac 1{ry\_r}$ but less than $2T(y)$ because $y\_1+\dots+y\_{2r}>y\_1+\dots+y\_{2r-1}\ge ry\_r$ for each $r$.
Thus, we are interested in estimating
$$
\sum\_{r\le t}\frac 1r+\sum\_{r\ge t}\frac {1}{r(1+\frac{\log(r/t)}{\log(1/p)})}
$$
The behavior of the first sum is clear. The second sum is comparable to its first term corresponding to the least integer $k\ge t$ plus the integral 
$$
\int\_k^n \frac {dr}{r(1+\frac{\log(r/t)}{\log(1/p)})}=\int\_{\log(k/t)}^{\log(n/t)}\frac {ds}{(1+\frac{s}{\log(1/p)})}
$$
which has an (rather ugly) explicit formula.


At last, let us discuss the guess that the maximizer consists of approximately equal entries. The equal entries would give the value about $\frac{\log n}{1+\frac{\log(n/t)}{\log(1/p)}}$, which tends to $\log(1/p)$ as $n\to\infty$ and $t$ and $p$ stay fixed. However, the integral above has asymptotics $\log(1/p)\log\log n$, which is a bit larger for really large $n$. 


