You may be interested (or required by your course!) to know why this rule works. You can derive it using 'implicit differentiation':
Start with the expression
and take logarithms of both sides:
Now, just differentiate both sides of this equation with respect to :
ie. (using the chain rule)
And as a side note: We must have simply because, when working with real numbers, the logarithm of a negative number (or zero) is not defined.