Let $n$ be a given positive integer, find the maximum of the value of $$f(x)=\dfrac{n^4}{x}+4(n^2+3)x-4x^2-5n^2$$ where $x \le \dfrac{n^2}{4}$ and $x \in \mathbb N^{+}.$
If the $x$ is real positive number, the problem also not easy, because $$f'(x)=-\dfrac{n^4}{x^2}+4(n^2+3)-8x=0$$ This cubic equation is not easy to handle. But if $x$ be positive integer, maybe have other method can solve it.
$n=1$ makes no sense, while for $n=2$ the only allowed value is $x=2$. Thus assume $n>2$.
Using Descartes' rule of signs on $x^2f'(x)=-8x^3+4(n^2+3)x^2-n^4$ we see that $f'(x)$ has zero or two positive roots. Next, $f'(1) = -n^4+4 n^2+4<0$ while $f'\left(\frac{n^2}{4}\right) = 2 \left(n^2-2\right)>0$, so that $f$ has two positive roots. Since $\lim_{x\to\infty} f(x) = -\infty$, the only possibility is that $f'$ has one root between $1$ and $\frac{n^2}{4}$, which must be a minimum, and another root, which must be a maximum, larger than $\frac{n^2}{4}$.
Finally, $f(1) = n^4-n^2+8$ and $f\left(\frac{n^2}{4}\right) = \frac{3 n^4}{4}+2 n^2$, and it's not hard to see that $f(1)\ge f\left(\frac{n^2}{4}\right)$. Thus the maximum occurs for $x=1$.