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!!
 A: As you suggest, take the roots as $a-d,a,a+d$, then you get $p=-a,3q=3a^2-d^2,r=-a^3+ad^2$. Substituting the first and third in the second we get $$-2p^3+3pq-r=0$$ Check: take roots 1,2,3. The equation is $(x-1)(x-2)(x-3)=x^3-6x^2+11x-6$, so $p=-2,3q=11,r=-6$. The relation $-2p^3+3pq-r=0$ holds. The relation given in the question of $-2p^2-3pq+r$ does not.
A: 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$
A: Assuming $p=-a,q=\frac{3a^2-d^2}{3},r=-a(a^2-d^2)$ it follows:
$d^2=3a^2-3q$ and $r=-a(a^2-3a^2+3q)=p(-2p^2+3q)$ and from here $2p^3-3pq+r=0$
A: $(p=-a),q=(\frac{3a^2-d^2}{3}),r=-a(a^2-d^2)\\
r=p(a^2-d^2)\\
\frac rp=(a^2-d^2)\\
3q=(3a^2-d^2)\\
3q=2p^2 + \frac rp\\
0=2p^3 - 3pq + r$
For the answer given, it is not correct.
Check it against $(x+1)(x+2)(x+3) = x^3 + 6x^2 + 11x + 6$
$-2p^2 - 3pq + r = -24$
