# How do you differentiate  f(x)= (xe^x+x)^2  using the chain rule.?

${f}^{'} \left(x\right) = 2 x \left({e}^{x} + 1\right) \left(x {e}^{x} + {e}^{x} + 1\right)$
$f \left(x\right) = {\left(x {e}^{x} + x\right)}^{2}$
$\implies {f}^{'} \left(x\right) = 2 {\left(x {e}^{x} + x\right)}^{2 - 1} \cdot \frac{d}{\mathrm{dx}} \left(x {e}^{x} + x\right)$
$\implies {f}^{'} \left(x\right) = 2 \left(x {e}^{x} + x\right) \left[x \frac{d}{\mathrm{dx}} \left({e}^{x}\right) + {e}^{x} \frac{d}{\mathrm{dx}} \left(x\right) + 1\right]$
$= 2 \left(x {e}^{x} + x\right) \left(x {e}^{x} + {e}^{x} + 1\right)$
${f}^{'} \left(x\right) = 2 x \left({e}^{x} + 1\right) \left(x {e}^{x} + {e}^{x} + 1\right)$