[Math] Derivative of ratio of functions, $f,g:\mathbb{R}^N\to\mathbb{R}$ with respect to a vector

calculusderivativesmatrices

This is fairly simple, but my matrix calculus is not that strong. Given two functions, $f:\mathbb{R}^N\to\mathbb{R}$, $g:\mathbb{R}^N\to\mathbb{R}$, and $x\in\mathbb{R}^N$, how do I compute the following derivative
$$\frac{\partial }{\partial x}\left(\frac{f(x)}{g(x)}\right)$$

In the scalar case ($N=1$) the derivative of the ratio is just obtained by the basic product rule
$$\frac{\partial }{\partial x}\left(\frac{f(x)}{g(x)}\right) = \frac{f'(x)}{g(x)} – \frac{f(x)g'(x)}{g^2(x)}$$
But if I try to generalize this to the multivariate case, the derivative terms are no longer scalars, they become vectors of dimension $N\times 1$. Does the above idea of applying the product rule generalize to the multivariate case? I realize there needs to be some transpose operators somewhere in there but I'm not sure where.

Also, how would I write out the second derivative in the multivariate case?
$$\frac{\partial^2 }{\partial x^2}\left(\frac{f(x)}{g(x)}\right)$$

(any good references on matrix calculus to help me with this stuff is appreciated!)

Thank you!

Best Answer

You just need a little bit of the chain rule and the product rule.

The vector derivative still obeys the product rule:

$$\nabla \frac{f}{g} = \frac{1}{g} \nabla f + f \nabla \frac{1}{g}$$

The key is doing the derivative of $1/g$. We can set $\tau = 1/g$ and see that $d\tau/dg = -1/g^2$. The key then is to use the chain rule to get

$$\nabla \tau = \frac{d\tau}{dg} \nabla g$$

As has been said, this essentially reproduces the single-variable result. The Laplacian can be attacked in a similar way. The keys to this approach are just to use the product rule, along with the chain rule to turn division into multiplication.