# Help understand chain rule derivative

I was verifying a larger function derivative on wolfram alpha and came across this derivative:

$\frac{d}{dx} (1-x)^2 = 2(x -1)$

Using the chain rule, I was expecting to get:

$2(1 - x)$

Instead. I trust wolfram alpha can differentiate better than me, so what am I missing?

You actually didn't use the chain rule correctly: To use the chain rule, you need to also multiply $2(1 - x)$ by $\frac d{dx}(1 - x)= -1$.
In other words, we have $$f(x) = (1 - x)^2 \implies f'(x) = 2(1 - x)\cdot \frac{d}{dx}(1 - x) = -2(1 - x) = 2(x - 1)$$
In more detail: $$\frac{d\left[(1-x)^2\right]}{dx} = 2 (1-x) \frac{d[1-x]}{dx} = 2 (1-x) (-1) = 2 (x-1).$$
$\frac{d (1-x)^2}{dx} =2(1-x) \frac{d (1-x)}{dx}=2(1-x)(-1)=2(x-1)$