
Take the logarithm of both sides.

In the last equality, we used the fact that

and

.
Differentiating both sides with respect to

, we have

where the left hand side occurs by the chain rule (recall that

is a function of

).
The solution then follows from the steps in your attachment, which is just a matter of algebraic manipulation.