Consider the following cubic equation: $$x^3 + ax^2 + bx + c = 0$$ where $a, b, c \in \mathbb{C}$.
Suppose $x \in \mathbb{C}$ satisfies this equation. Define $y := x + \frac{a}{3}$, so that $x = y - \frac{a}{3}$. We now substitute this in the original equation.
Stewart's Galois Theory 3rd edition (and also other sources apparently) says that, after substituting:
The equation becomes $$y^3 + py + q = 0$$ where $$ \begin{align} p &= \frac{a^2 - 2a^3 + 3b}{3} \\ q &= \frac{2a^3 - 9ab + 27c}{27} \end{align} $$
I have tried to check this in detail myself. We have: $$ \begin{aligned} \left(y - \frac{a}{3}\right)^3 &= y^3 - ay^2 + \frac{a^2}{3}y - \frac{a^3}{27} \\ a\left(y - \frac{a}{3}\right)^2 = a\left(y^2 - \frac{2a}{3}y + \frac{a^2}{9} \right) &= ay^2 - \frac{2a^2}{3}y + \frac{a^3}{9} \\ b\left(y - \frac{a}{3}\right) &= by - \frac{ab}{3}\\ c &= c \end{aligned} $$ So, summing up everything, we get the equation: $$y^3 + \left(-\frac{a^2}{3} + b\right) y + \left( \frac{2a^3}{27} - \frac{ab}{3} + c \right) = 0$$ So I'm getting $p = \frac{-a^2 + 3b}{3}$.
Where am I going wrong? I must be making some silly mistake during the algebraic manipulations.