TITLE: Find the maximum of the value $f(x)=\frac{n^4}{x}+4(n^2+3)x-4x^2-5n^2$
QUESTION [5 upvotes]: 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.

REPLY [2 votes]: 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$.