Solve $2n^3 + 3n^2 + n = d$ how to solve the following Diophantine equation?
$$
2n^3+3n^2+n=d
$$
Here, $n$ and $d$ are non-negative integers.
It would also be great if it were possible to formulate an algorithm for
$$
an^3 +bn^2 +n c= d
$$
for arbitrary coprime integers $a$, $b$, $c$.
 A: This can be written as $n(n+1)(2n+1)=d$. The left-hand side satisfies
$$2n^3 < n(n+1)(2n+1) < 2(n+1)^3$$
So $n^3 < d/2 < (n+1)^3$, which means that the only possible integer solution is
$$n=\left\lfloor \sqrt[3] {d/2}\right\rfloor$$
and you just have to check whether this satisfies the equation.
A: HINT:
$$ 2n^3 + 3n^2 + n = d \Longleftrightarrow $$
$$ -d + 2n^3 + 3n^2 + n= 0 \Longleftrightarrow $$

Eliminate the quadratic term bij substituting $x=n+\frac{1}{2}$:

$$-\frac{1}{2}-d+3\left(x-\frac{1}{2}\right)^2+2\left(x-\frac{1}{2}\right)^3+x=0\Longleftrightarrow$$
$$-d-\frac{x}{2}+2x^3=0\Longleftrightarrow$$
$$-\frac{d}{2}-\frac{x}{4}+x^3=0\Longleftrightarrow$$

If $x=y+\frac{\lambda}{y}$ then $y=\frac{1}{2}\left(x+\sqrt{x^2-4\lambda}\right)$ which will be used during back substitution:

$$-\frac{d}{2}+\frac{1}{4}\left(-y-\frac{\lambda}{y}\right)+\left(y+\frac{\lambda}{y}\right)^3=0\Longleftrightarrow$$
$$-\frac{dy^3}{2}+y^6+\lambda^3+y^4\left(3\lambda-\frac{1}{4}\right)+y^2\left(3\lambda^2-\frac{\lambda}{4}\right)=0\Longleftrightarrow$$

Substitute $\lambda=\frac{1}{12}$ and the $z=y^3$, yielding a quadratic equation in the variable $z$:

$$\frac{1}{1728}-\frac{dz}{2}+z^2=0\Longleftrightarrow$$
$$z=\frac{1}{72}\left(18d+\sqrt{3}\sqrt{108d^2-1}\right)$$
From now on you've to substitute everything back and solve $n$.
A: Note that for $n = 0$ or $d = 0$ the only solution is $(0,0)$, so it is enough to consider $n,d$ positive. Then the equation
$$
2n^3 + 3n^2 + n = d \tag{1}
$$
is equivalent to the equation
$$
2n^2 + 3n + 1 = d' \tag{2} \label{eq:reduced}
$$
which has the only positive solution
$$
n = \frac{-3 + \sqrt{9 + 8(d'-1)}}{4}.
$$
All that's left is figure out when this number is an integer... and currently I don't know how to do that.

On the other hand, a quick numerical analysis suggests that the values of $d'$ for which \eqref{eq:reduced} has integer solutions are precisely those of the form
$$
d' = 2k^2 + 7k + 6 \quad \text{for } k \in \Bbb{Z}_{\geq 0} \tag{3} \label{eq:fit}
$$
(I checked this equation for $d' < 10^8$).
A (somewhat messy, but exact) way to compute those values of $d'$ less than $10000$ in Sage is
map(lambda x: x+1, filter(lambda k: is_square(9+8*k) and (-3 + sqrt(9+8*k) % 4) == 0, range(2,10000)))

Plotting each of these numbers against its index suggests a quadratic relationship

and a quick fitting gives the coefficients in \eqref{eq:fit}.
