Show that the Laplacian of a function $f$ is $\Delta^2 f=(\frac{n−1}{r})g'(r)+g''(r)$

$$ f(x_1, \ldots, x_n) = g(r), \text{ where }r = \left(x_1^2+\ldots+x_n^2\right)^\frac{1}{2}. $$

Then,

$$ \frac{\partial f}{\partial x_i} = g'(r)\frac{\partial r}{\partial x_i} \Rightarrow \frac{\partial^2 f}{\partial x^2_i} = g''(r)\left(\frac{\partial r}{\partial x_i}\right)^2 + g'(r)\frac{\partial^2 r}{\partial x^2_i}, \text{ }i = 1, \ldots, n. $$

Now, let us calculate $\frac{\partial r}{\partial x_i}$ and $\frac{\partial^2 r}{\partial x^2_i}$:

$$ \frac{\partial r}{\partial x_i} = \frac{1}{2}\left(x_1^2+\ldots+x_n^2\right)^{-\frac{1}{2}}\cdot2x_i = \frac{x_i}{r}, \text{ }i = 1, \ldots, n. $$

$$ \underbrace{ \begin{aligned} \frac{\partial^2 r}{\partial x^2_i} &= \frac{\partial}{\partial x_i}\left(\frac{x_i}{r}\right) = \frac{1}{r} +x_i\left(-\frac{1}{r^2}\right)\frac{\partial r}{\partial x_i} = \\ &=\frac{1}{r}-\frac{x^2_i}{r^3}, \text{ }i = 1, \ldots, n. \end{aligned} }_\Downarrow $$

$$ \frac{\partial^2 f}{\partial x^2_i} = g''(r)\frac{x^2_i}{r^2} + g'(r)\left(\frac{1}{r}-\frac{x^2_i}{r^3}\right),\text{ }i = 1, \ldots, n. $$

Now, let us calculate the Laplacian: $$ \begin{aligned} \nabla^2f(x) &= \sum_{i = 1}^n\frac{\partial^2 f}{\partial x^2_i} = \sum_{i = 1}^n\left\{g''(r)\frac{x^2_i}{r^2}+g'(r)\left(\frac{1}{r}-\frac{x^2_i}{r^3}\right)\right\} = \\ &= \frac{g''(r)}{r^2}\sum_{i=1}^n x^2_i + \frac{g'(r)}{r}\sum_{i=1}^n1-\frac{g'(r)}{r^3}\sum_{i=1}^nx^2_i = \\ &= \frac{g''(r)}{r^2}\cdot r^2 + \frac{g'(r)}{r}\cdot n - \frac{g'(r)}{r^3}\cdot r^2 = \\ &= g''(r) + g'(r)\frac{n-1}{r} \end{aligned} $$