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). $$

You prove it the usual way:
Base. Establish the result for $n=1$. 
If $n=1$, then the left hand side is
$$\sum_{i=1}^1(3i-1)^2 = (3(1)-1)^2 = 4,$$
and the right hand side is
$$\frac{1}{2}(1)\left(6(1)^2 + 3(1) - 1\right) = \frac{1}{2}(8) = 4.$$
So we have equality.
Inductive Step.
Induction Hypothesis. The result holds for $k$; that is,
$$\sum_{i=1}^k(3i-1)^2 = \frac{1}{2}k(6k^2 + 3k - 1).$$
To prove. The result holds for $k+1$.
$$\begin{align*}
\sum_{i=1}^{k+1}(3i-1)^2 &= \left(\sum_{i=1}^k(3i-1)^2\right) + (3(k+1)-1)^2\\
&= \frac{1}{2}k(6k^2+3k-1) + (3(k+1)-1)^2 &\text{(by the Induction Hypothesis)}\\
&=\frac{1}{2}k(6k^2+3k-1) + (3k+2)^2\\
&=\frac{1}{2}k(6k^2+3k-1) + (9k^2 + 12k+4)\\
&= \frac{1}{2}\left(6k^3 + 3k^2 - k + 18k^2 + 24k + 8\right)\\
&= \frac{1}{2}\left(6k^3 + 21k^2 + 23k + 8\right)\\
&=\frac{1}{2}\left(6(k^3 + 3k^2 + 3k + 1) + 3k^2 + 5k + 2\right)\\
&=\frac{1}{2}\left(6(k+1)^3 + 3(k^2 + 2k + 1) -k - 1\right)\\
&=\frac{1}{2}\left(6(k+1)^3 + 3(k+1)^2 - (k+1)\right)\\
&=\frac{1}{2}(k+1)\left(6(k+1)^2 + 3(k+1) - 1\right).
\end{align*}$$
As this is exactly what we needed to show for $k+1$, this proves the inductive step.
Conclusion. The given formula holds for $n=1$; and if it holds for $k$, then it also holds for $k+1$. By mathematical induction, the given formula holds for all positive integers $n$. $\Box$
