To find the critical points of any equation you must take the derivative of the function. So by expanding the equation you are creating more trouble for yourself than is needed. In this case you need to perform the Product Rule for the entire equation while utilizing two separate Chain Rules for the quantities involved.