<s>[INST] Proof by induction: induction hypothesis question In this question I found online:

*

*Show that $$ S(n):0^2 + 1^2 + 2^2 + · · · + n^2 =
\frac{n(n + 1)(2n + 1)}{6}$$
I don't understand why for S(k+1) they wrote:
$$S(k+1):1^2+2^2+3^2+⋯+k^2+(k+1)^2=\frac{(k+1)(k+2)(2(k+1)+1)}{6}$$
instead of:
$$S(k+1):1^2+2^2+3^2+⋯+(k+1)^2=\frac{(k+1)(k+2)(2(k+1)+1)}{6}$$
Why is the $k^2$ included in the $S(k+1)$ step I don't get it surely you just substitute $k+1$ for $n$ so I don't know why $k^2$ is needed there because in other proof by induction questions I've done for example
for this proof: $$n<2^n$$
for the $k+1$ step the answer was not $$k + k + 1 < 2^k+1$$
it was:
$$k+1 < 2^k+1$$
EDIT
People have mentioned that my version is correct and they just wrote it in a different way but why could I not prove both sides were equal? This is what I did:
$$S(k+1):1^2+2^2+3^2+⋯+(k+1)^2=\frac{(k+1)(k+2)(2(k+1)+1)}{6}$$
I expanded out $$(k+1)^2$$ which gave me $$k^2+2k+1$$
so going back to the k+1 statement we have:
$$S(k+1):1^2+2^2+3^2+⋯+k^2+2k+1=\frac{(k+1)(k+2)(2(k+1)+1)}{6}$$
I subbed in $$\frac{k(k+1)(2k+1)}{6}$$ for $$1^2+2^2+3^2+⋯+k^2$$ (the induction hypothesis) in the k+1 statement and got:
$$\frac{k(k+1)(2k+1)}{6} + 2k+1=\frac{(k+1)(k+2)(2(k+1)+1)}{6}$$
long story short my proof failed and I couldn't prove both sides were equal but why was this if my version of S(k+1) was not incorrect?
 [/INST] Your mistake is in the last equation.  It should read:
$$\frac{k(k+1)(2k+1)}{6} + (k+1)^2= \frac{(k+1)(k(2k+1)+6(k+1))}{6}= \frac{(k+1)(2k^2+7k+6)}{6} \\=\frac{(k+1)(k+2)(2k+3)}{6}=\frac{(k+1)((k+1)+1)(2(k+1)+1)}{6}$$
</s>