1) \(\left(a+b\right)^3=\left(a+b\right)\left(a+b\right)^2=\left(a+b\right)\left(a^2+2ab+b^2\right)\)
\(=a^3+2a^2b+ab^2+a^2b+2ab^2+b^3\)
\(=a^3+3a^2b+3ab^2+b^3\)
2) \(\left(a-b\right)^3=\left(a-b\right)\left(a-b\right)^2=\left(a-b\right)\left(a^2-2ab+b^2\right)\)\(=a^3-2a^2b+ab^2-a^2b+2ab^2-b^3\)
\(=a^3-3a^2b+3ab^2-b^3\)