Prove that $1^2+2^2+\cdots+n^2=\frac{n(n+1)(2n+1)}{6}$ for $n \in \mathbb{N}$. Problem: Prove that $1^2+2^2+\cdots+n^2=\frac{n(n+1)(2n+1)}{6}$ for $n \in \mathbb{N}$.
My work: So I think I have to do a proof by induction and I just wanted some help editing my proof.
My attempt:
Let $P(n)=1^2+2^2+\cdots+n^2=\frac{n(n+1)(2n+1)}{6}$ for $n \in \mathbb{N}$. 
Then $$P(1)=1^2=\frac{1(1+1)(2+1)}{6}$$
$$1=\frac{6}{6}.$$
So $P(1)$ is true.
Next suppose that $P(k)=1^2+2^2+\cdots+k^2=\frac{k(k+1)(2k+1)}{6}$ for $k \in \mathbb{N}$. Then adding $(k+1)^2$ to both sides of $P(k)$ we obtain the following:
$$1^2+2^2+\cdots+k^2+(k+1)^2=\frac{k(k+1)(2k+1)}{6}+(k+1)^2$$
$$=\frac{2k^3+3k^2+k+6(k^2+2k+1)}{6}$$
$$=\frac{2k^3+9k^2+13k+6}{6}$$
$$=\frac{(k^2+3k+2)(2k+3)}{6}$$
$$=\frac{(k+1)(k+2)(2k+3)}{6}$$
$$=\frac{(k+1)((k+1)+1)(2(k+1)+1)}{6}$$
$$=P(k+1).$$
Thus $P(k)$ is true for $k \in \mathbb{N}$.
Hence by mathematical induction, $1^2+2^2+\cdots+n^2=\frac{n(n+1)(2n+1)}{6}$ is true for $n \in \mathbb{N}$.

Your inductive assumption is such that the formula marked $\color{red}{\mathrm{red}}$ (several lines below) holds for $i=k$: 
$$\sum^{i=k}_{i=1} i^2=\frac{k(k+1)(2k+1)}{6} $$
You need to prove that for $i=k+1$: $$\sum^{i=k+1}_{i=1} i^2=\color{blue}{\frac{(k+1)(k+2)(2k+3)}{6}}$$
To do this you cannot use: $$\sum^{i=k}_{i=n} i^2=\color{red}{\frac{n(n+1)(2n+1)}{6}} $$ as this is what you are trying to prove.
So what you do instead is notice that:
$$\sum^{i=k+1}_{i=1} i^2= \underbrace{\frac{k(k+1)(2k+1)}{6}}_{\text{sum of k terms}} + \underbrace{(k+1)^2}_{\text{(k+1)th term}}$$
$$\sum^{i=k+1}_{i=1} i^2= \frac{k(k+1)(2k+1)}{6}+\frac{6(k+1)^2}{6}$$
$$\sum^{i=k+1}_{i=1} i^2= \frac{(k+1)\left(k(2k+1)+6(k+1)\right)}{6}$$
$$\sum^{i=k+1}_{i=1} i^2= \frac{(k+1)(2k^2+\color{green}{7k}+6)}{6}=\frac{(k+1)(2k^2+\color{green}{4k+3k}+6)}{6}=\frac{(k+1)\left(2k(k+2)+3(k+2)\right)}{6}=\color{blue}{\frac{(k+1)(k+2)(2k+3)}{6}}\quad \forall \space k \in \mathbb{N}$$
Which is the relation we set out to prove. So the method is to substitute $i=k+1$ into the formula you are trying to prove and then use the inductive assumption to recover the $\color{blue}{\mathrm{blue}}$ equation at the end. 
