Prove by induction (formula for $\sum^n(3i-1)^2$) Anyone knows how to do this? The answer I'm getting is not correct.
Prove by induction that, for all integers $n\ge1$, $$\sum_{i=1}^n (3i-1)^2 = \frac12 n(6n^2 + 3n - 1). $$
Thanks
This Is what I have managed to get. After this I think I'm doing something wrong:
  $$ \frac12 n(6n^2 + 3n - 1 + 6n + 4) (3n +2). $$

$$
\begin{align*}
\sum_{i=1}^n (3i-1)^2 &= \sum_{i=1}^n \left( (9i)^2 -6i +1 \right)\\
        &= 9 \frac{n(n+1)(2n+1)}{6} - 6\frac{n(n+1)}{2} + n\\
        &= 3n(n+1) \left( \frac{2n+1}{2} -1 \right) +n \\
        &= 3n(n+1) \left( \frac{2n-1}{2} \right) +n \\
        &= \frac{3n(n+1)(2n-1)+2n}{2}\\
        &= n \left(\frac{6n^2+3n-1}{2} \right)\\
        &= 3n^3+\frac{3n^2}{2}-\frac{n}{2}\\
\end{align*}
$$
