Bài 2:
a: Ta có: \(A=\left(x+1\right)^3+\left(x-1\right)^3\)
\(=x^3+3x^2+3x+1+x^3-3x^2+3x-1\)
\(=2x^3+6x\)
b: Ta có: \(B=\left(x-3\right)^3-\left(x+3\right)\left(x^2-3x+9\right)+\left(3x-1\right)\left(3x+1\right)\)
\(=x^3-9x^2+27x-27-x^3-27+9x^2-1\)
\(=27x-55\)