Numerically stable reverse automatic differentiation of power(x, y)?


I would like to compute the adjoints $ \bar x$ and $ \bar y$ , from a reverse automatic differentiation perspective, of the expression $ x^y$ . The adjoint $ \bar{x^y}$ is already known; and we can assume $ x \geq 0$ and $ y \geq 1$ .

The "easy" solution consists of rewriting the expression $ x^y=e^{y \ln x}$ , and proceed piece-wise from there. However, this solution proves to be unstable numerically, it gives:

$ $ \bar y = \bar{x^y} x^y \ln x$ $

and

$ $ \bar x = \bar{x^y} x^{y-1} y$ $

Is there any way to rewrite and/or approximate those expressions with something that is not going to numerically diverge when $ x \approx 0$ ?