TITLE: Maximize $f(0)+\cdots+f(n-1)$ subject to $f(x)f(y) + f(x+y) \leq 1$
QUESTION [10 upvotes]: Suppose $f:\mathbf{N} \to [0,1]$ satisfies $$f(x)f(y) + f(x+y)\leq 1\qquad(1)$$ for all $x,y$. Let $$d_n = \frac{1}{n} \sum_{x=0}^{n-1} f(x).$$ It is easy to prove that $$\limsup d_n \leq 1/\varphi,$$ where $1/\varphi$ is the positive solution to $t^2+t=1$. (Start with $(1)$, take an average and $\limsup$ in $x$, then in $y$.)
What's interesting is that it does not seem nearly so easy to bound $d_n$, without the $\limsup$, independently of $f$. Is it true that $$d_n \leq 1/\varphi + o(1),$$ where the $o(1)$ is independent of $f$?
This does seem to be true numerically. In fact it may even be that $f \equiv 1/\varphi$ is the unique maximizer of $d_n$ for each $n$.

REPLY [4 votes]: Gerhard Paseman's solution is correct, and shows that $f \equiv 1/\phi$ is the unique maximizer of $d_n$ for each $n\geq 0$. Just reproducing here in as few words as I can, for the purpose of succinctness.
Let $c = 1/\varphi$ be the positive solution to $c^2 + c = 1$. Let $m\geq0$ be minimal such that $f(m) \geq c$ (if there is no such $m$ then we can go home). From now on, the only thing we will use is
$$f(x) c + f(x+m) \leq 1. \qquad(*)$$
If $m = 0$ this immediately implies $f(x) \leq c$ for all $x$, so assume $m>0$.
Claim: For any $i < m$ and any $k \geq0$, the sum of $f$ over the arithmetic progression $\{i, i+m, i+2m, \dots, i+(k-1)m\}$ is at most $kc$. The inequality is strict for $k > 0$.
Prove this and we're done, by partitioning $\{1, \dots, n\}$ into such progressions.
Proof: Use induction on $k$. The case $k=0$ is trivial. The case $k=1$ follows from $i < m$. For $k > 1$, note by induction and $(*)$ that
$$f(i) + \cdots + f(i + (k-3)m) \leq (k-2)c,$$
$$f(i) + \cdots + f(i + (k-2)m) < (k-1)c,$$
$$f(i + (k-2)m) c + f(i+(k-1)m) \leq 1.$$
Add these together with weights $c$, $c^2$, and $1$.