I think you may be having trouble differentiating the equation in the first place.
You differentiate it term by term, using the usual rules:
which is straightforward.
Then needs two things, the power rule (as above) and also the chain rule: , which gives . In this context . (Differentiating with respect to y is the same as w.r.t x except the name of the variable is different.)
Then you have the product rule and the chain rule to use:
which works out as:
Now put it all together, gather the onto one side and solve for it equalling zero.