Actually I think the Leibniz notation is confusing you a little (or at least you are using it very sloppy): you use dU(AW)/dW to denote the derivative of the chained functions as well as the derivative of the outer function applied to the inner function, all in the same equation. As I said: substitute the aforementioned term with z and your equation reads z = Az.