Let $f(x)=(2+x+ax^2)\ln (1+x)-2x$ with $f(x)$ achieving its maximum value at $x=0$. Find $a$. Problem
Let $f(x)=(2+x+ax^2)\ln (1+x)-2x$ with $f(x)$ achieving its maximum value at $x=0$. Find $a$.
Solution
At first, let's review a theorem, which states as follows:

Let $f^{(n)}(x)$ denote the $n-$order derivative of $f(x)$,and $k$ be
a positive integer such that $f^{(n)}(x_0) \neq 0$ holds for $n=k$ and
$f^{(n)}(x_0)=0$ holds for all $n=1,2,\cdots,k-1$. Then, if $k$ is
odd, $f(x_0)$ is neither a maximum value nor a minimum value, and if
$k$ is even, $f(x_0)$ is either a maximum value or a minimum value,
which depends on the sign of $f^{(k)}(x_0)$.

Now, let's take up to solve the problem. Notice that, for $f(x)=(2+x+ax^2)\ln (1+x)-2x$, we have $$f'(x)=\frac{a x^2+x+2}{x+1}+(2 a x+1) \ln (x+1)-2,$$$$f''(x)=-\frac{a x^2+x+2}{(x+1)^2}+\frac{2 (2 a x+1)}{x+1}+2 a \ln(x+1),$$$$f'''(x)=\frac{2 \left(a x^2+x+2\right)}{(x+1)^3}+\frac{6 a}{x+1}-\frac{3 (2 a x+1)}{(x+1)^2}.$$ According to these, it's clear that $f'(0)=0, f''(0)=0,f'''(0)=6a+1.$If $f'''(0)=6a+1 \neq 1$. Then, by the theorem above, $f(0)$ is neither a maximum value nor a minimum value, which is a contradiction. Hence, $f'''(0)=6a+1=0$. As a result, $a=-\dfrac{1}{6}.$ Moreover, in this case, $f''''(0)=-2$. This shows that $f(0)$ is a maximum value, which indeed satisfies the requirement.
P.S.
In fact, we can further prove that, in this case $a=-\dfrac{1}{6}$, $f(0)$ is also the global maximum value. Just notice $$f''(x)=\frac{2x-3x^2}{6(x+1)^2}-\frac{1}{3}\ln(x+1)\leq \frac{2x-3x^2}{6(x+1)^2}-\frac{1}{3}\cdot\frac{x}{x+1}=-\frac{5x^2}{6(1+x)^2}\leq 0$$ holds for all $x>-1$,and $f''(x)=0$ holds for $x=0$ only.
Please correct me if I'm wrong. And I'm always waiting for other nicer solutions. Thanks.

Here's a nicer solution: using the Maclaurin series of $\log(1+x)$,
$$
-2x+\left(a x^2+x+2\right) \log (x+1) = -2x+\left(a x^2+x+2\right) \left(x-\frac{x^2}{2}+\frac{x^3}{3}-\frac{x^4}{4}+O\left(x^5\right)\right)
$$
$$
=\left(a+\frac{1}{6}\right) x^3+\left(-\frac{a}{2}-\frac{1}{6}\right)
   x^4+O\left(x^5\right)
$$By your theorem, we must have $a=-1/6$.
