Find the condition such that the roots of the polynomial are in AP 
$f(x)=x^3+3px^2+3qx+r$ has roots in AP.Find the relation between $p,q$ and $r$.
[Answer:$-2p^2-3pq+r=0$]

My attempt:-
Taking $d$ as the common difference of the roots in AP we have $f(x)=(x-(a-d))(x-a)(x-(a+d))=x^3-3x^2a+(3a^2-d^2)x-a(a^2-d^2)$.
Comparing this with,the given equation,we get,
$(p=-a),q=(\frac{3a^2-d^2}{3}),r=-a(a^2-d^2)$.
But,after this I have no idea how to eliminate $a$ and $d$ from the equation and find a relation between $p,r$ and $r$.
Thanks for any help!!

Let $x_1=a, x_2=a+d, x_3=a+2d$.
Use Vieta's Formulas
Then $$\begin{cases}a+a+d+a+2d=-3p
\\
a(a+d)+a(a+2d)+(a+d)(a+2d)=3q
\\
a(a+d)(a+2d)=-r
\end{cases}$$
$$\begin{cases}a+d=-p
\\
3a^2+6ad+2d^2=3q
\\
a(a+d)(a+2d)=-r
\end{cases}$$
Then $-2p^2-3pq+r=-2(a+d)^2+(a+d)(3a^2+6ad+2d^2)-a(a+d)(a+2d)=0$
