<s>[INST] Diophantine equation with cubes. Interested in the solution in general Diophantine equations of the form:
$X^3+Y^3+Z^3=3XYZ+q$
$q$ - what some integer.
Solutions similar equations can be written.
Since this equation is easy, as it is quite symmetrical.
$X^3+Y^3+Z^3-3XYZ=R^3$
Such a solution can write.
$X=sp(p+s)$
$Y=s(2p^2+s^2)$
$Z=p(p^2+2s^2)$
$R=p^3+s^3$
And solutions can be written:
$X=s(9p^2+9ps+10s^2)$
$Y=s(6p^2+12ps+7s^2)$
$Z=3p^3+3p^2s+15ps^2+7s^3$
$R=3(p+2s)(p^2-ps+s^2)$
Whether there are any thoughts how to solve this equation?
At first I thought to use for solving Pell's equation, but I think that you can do without.
 [/INST] You can use the following identity:
$$x^3+y^3+z^3-3xyz=(x+y+z)(x^2+y^2+z^2-xy-xz-yz)$$
Fixed integer q has a finite number of factorial expansions. So we get a finite number of systems of two equations:
$$x+y+z = a$$
$$x^2+y^2+z^2-xy-xz-yz = b$$
for all integers $a$ and $b$ such that $ab=q$. Excluding the variable z we obtain the quadratic equation in x and y.
CALCULATIONS:
Let $u = x + y$ and $v=x y$. Then we have $z = a - u$ and
$$x^2+y^2+z^2-xy-xz-yz = u^2 - 2v + (a-u)^2 - v - (a-u)u =$$
$$u^2 - 3v + a^2 - 2au + u^2 - au +u^2 = 3u^2 - 3au - 3v + a^2$$
Thus, we have a equation in integers u and v:
$$ 3(u^2 - au) - 3v = b - a^2$$ 
It`s something like Pell's equation as you said. But it is more simple and we can express v from u:
$$ 3v = 3(u^2 - au) - (b - a^2)$$ 
Next step. Let suppose that (x,y) is an integer solution of original equation then because $u = x + y$ and $v=x y$ there is integer m such that $u^2-4v=m^2$ (this is a discriminant of a square equation $(\lambda - x)(\lambda - y) = \lambda^2-u\lambda+v=0$). 
So $4v = u^2 - m^2$ and we have the following transformations of the equation:
$$ 3v = 3(u^2 - au) - (b - a^2)$$
$$12(u^2 - au)-3*4v = 4(b-a^2)$$
$$12(u^2 - au)-3(u^2-m^2)=4(b-a^2)$$
$$9u^2 - 12au + 3m^2=4(b-a^2)$$
$$9u^2 - 12au + 4a^2 + 3m^2=4b$$
$$(3u-2a)^2 + 3m^2=4b$$
Thus, we have that the number of solution for each fixed a and b is finite! So for each parameter q we can find all solutions (x,y,z) of the original equation $x^3+y^3+z^3 = 3xyz + q$ by the following formulas:
$$x=\frac{u-m}{2}$$
$$y=\frac{u+m}{2}$$
$$z=a-u$$
where u and m form a solution of the equation:
$$(3u-2a)^2 + 3m^2=4b$$
</s>