a) \(\left(x-3\right).\left(x^2+3x+9\right)-x.\left(x+4\right)\left(x-4\right)=21\)
\(\Leftrightarrow x^3-27-x.\left(x^2-16\right)=21\) \(\Leftrightarrow x^3-27-x^3+16x=21\)
\(\Leftrightarrow16x=21+27\) \(\Leftrightarrow16x=48\) \(\Leftrightarrow x=3\)
b) \(\left(x+2\right)\left(x^2-2x+4\right)-x.\left(x^2+2\right)=4\)
\(\Leftrightarrow x^3+8-x^3-2x=4\) \(\Leftrightarrow-2x=4-8\) \(\Leftrightarrow-2x=-4\) \(\Leftrightarrow x=2\)