I need to find the differential and derivative of $ f: X\rightarrow (I-X(X'X)^{-1}X')$
Now by the product rule I found that the differential of $d(I-X(X'X)^{-1}X')=-(dX(X'X)^{-1}X' + (X)d(X'X)^{-1}X'+X(X'X)^{-1}d(X')$
Now I have issues with finding $d(X'X)^{-1}$ because I am not sure how to use the chain rule here, and with the first term: $(dX(X'X)^{-1}X'$ because it is not in the standard form $A(dX)B$ where $A$ and $B$ are any matrices.
Could anyone show me how to proceed as to find the derivative of this function?