<s>[INST] 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$.
 [/INST] 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$.
</s>