If you let and
You can see that the product rule will yield the derivative:
With this in hand, you must find the derivatives of A and B.
To do this you can use the chain rule:
For the example of A, let
You can combine all of this into one formula, but it's easiest done in seperate steps.