I was asked this question in an assignment
Let $G$ be a graph on $n$ vertices and without any cycle of length $4$. Show that $G$ has at most $\frac n2(\sqrt n+1)$ edges.
What I did was this to which I added a small proof of the fact that $\frac n4\left(1+\sqrt{4n-3}\right)\leq\frac n2(\sqrt n+1)$.
But, after submitting the assignment, I felt like I cheated a little. I was asked about the bound $\frac n2(\sqrt n+1)$ which I actually couldn't find. What I found out was something else completely unrelated to this, about which I was lucky that the inequality holds.
So, I wanted to ask if anybody can find a way to arrive at the bound I was asked to show. I don't think, I'll be able to find the way- in these things, once you find one path, it's hard to find another one.
The bound $\frac n2(\sqrt n+1)$ comes from the same initial argument, except you weaken your inequality a little as you go to make the simplification steps easier. You did not "cheat a little", and there is no hidden alternative approach to be found.
Each vertex $v$ contributes $\binom{\deg(v)}{2}$ pairs that are connected by a path of length $2$; no two vertices contribute the same pair (or we'd get a $4$-cycle), and there are only $\binom n2$ pairs of vertices in the graph, so we have $$ \sum_{v \in V} \binom{\deg(v)}{2} \le \binom n2 \le \frac{n^2}{2}. $$ By Jensen's inequality, if $d$ is the average degree of the graph, then $$ n\binom d2 \le \sum_{v \in V} \binom{\deg(v)}{2} \le \frac{n^2}{2} \implies d(d-1) \le n. $$ This inequality is slightly weaker than $d^2 \le n$, which we'd simplify to $d \le \sqrt n$, but it it is very close to that inequality. So we try $d = \sqrt n + 1$, and see that this gives $d(d-1) = n + \sqrt n > n$. Therefore we get $d < \sqrt n + 1$ without having to solve quadratic equations.
Therefore the graph has $\frac12 nd < \frac12 n(\sqrt n + 1)$ edges.
This is maybe slightly weaker than a bound like $\frac n4\left(1+\sqrt{4n-3}\right)$, but both bounds are equally good asymptotically: they're both $\frac12 n \sqrt n + O(n)$, with a slightly different constant hidden in the $O(n)$.