Find the maximum of the value $f(x)=\frac{n^4}{x}+4(n^2+3)x-4x^2-5n^2$ 
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.
 A: $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$.
A: 
Let $\mathbb{N}$ denote  the positive integers. Given $n\in\mathbb{N}$ fixed, we look for
\begin{align*}
&f:\mathbb{N}\to\mathbb{R}\\
&f(x)=\frac{n^4}{x}+4\left(n^2+3\right)x-4x^2-5n^2\qquad\longrightarrow\qquad\max\tag{1}\\
\end{align*}
provided that
$x\leq \frac{n^2}{4}$


*

*The additive constant  $-5n^2$ in (1) is not relevant for determining the value of $x$  which maximizes $f$ and can be ignored.
We consider therefore
\begin{align*}
&g:\mathbb{N}\to\mathbb{R}\\
&g(x)=\frac{n^4}{x}+4\left(n^2+3\right)x-4x^2\qquad\longrightarrow\qquad\max\tag{2}\\
\end{align*}


*We  can   do some    more     simplifications   by   letting $x=\alpha n^2$   with $\alpha\in\left(0,\frac{1}{4}\right]$ respecting this  way  $x\leq \frac{n^2}{4}$. We  obtain
\begin{align*}
g\left(\alpha n^2\right)&=\frac{n^2}{\alpha}+4\left(n^2+3\right)\alpha n^2-4\alpha^2  n^4\\
&=n^2\left(12\alpha+\frac{1}{\alpha}\right)\qquad\longrightarrow\qquad\max
\end{align*}
provided      that    $\alpha\in\left(0,\frac{1}{4}\right]$.


*The problem finally boils down  to analyse  a function $h$
\begin{align*}
&h:\left(0,\frac{1}{4}\right]\to\mathbb{R}\\
&h(\alpha)=12\alpha+\frac{1}{\alpha}\qquad\longrightarrow\qquad\max
\end{align*}
Looking for positive extrema: $h^\prime(\alpha)=12-\frac{1}{\alpha^2}=0$  we find a minimum at $$\alpha=\frac{1}{2\sqrt{3}}$$  (whereby $h^{\prime\prime}\left(\frac{1}{2\sqrt{3}}\right)\ne 0$).
Since the minimum $\alpha=\frac{1}{2\sqrt{3}}>\frac{1}{4}$ and $h^\prime(\alpha)<0$ for $\alpha \in\left(0,\frac{1}{4}\right]$ we conclude the function $h$ is monotonically decreasing in $\left(0,\frac{1}{4}\right]$.

Conclusion: The maximum value of $x=\alpha n^2$ is given when $\alpha=\frac{1}{n^2}$ resulting in $\color{blue}{x=1}$.
We  observe due to $x\leq \frac{n^2}{4}$ the solution   $\color{blue}{x=1}$   is  valid iff $n\geq 2$ and the empty set in case $n=1$.

