I want to calculate the inverse of matrix $A+B$, where
$$\mathbf{A} = \left( \begin{array}{rrrr} x_1+a & a & \cdots & a \\ a & x_2+a & \cdots & a \\ \vdots & \vdots & \ddots & \vdots \\ a & a & \cdots & x_m+a \end{array} \right) , \qquad \qquad \qquad B= \left( \begin{array}{rrrr} b_1^2 & b_1b_2 & \cdots & b_1b_m \\ b_1b_2 & b_2^2 & \cdots & b_2b_m \\ \vdots & \vdots & \ddots & \vdots \\ b_1b_m & b_2b_m & \cdots & b_m^2 \end{array} \right) $$
Can you help me? Thanks.
$$\mathrm A + \mathrm B = \mbox{diag} (\mathrm x) + a 1_m 1_m^{\top} + \mathrm b \mathrm b^{\top} = \mbox{diag} (\mathrm x) + \begin{bmatrix} | & |\\ \sqrt{a} \, 1_m & \mathrm b\\ | & |\end{bmatrix} \begin{bmatrix} — \sqrt{a} \, 1_m^{\top} —\\ — \mathrm b^{\top} —\end{bmatrix}$$
Let $\mathrm D (\mathrm x) := \mbox{diag} (\mathrm x)$. Assuming that $x_i \neq 0$ for all $i \in [m]$, then $\mathrm D^{-1} (\mathrm x)$ exists and is
$$\mathrm D^{-1} (\mathrm x) = (\mbox{diag} (\mathrm x))^{-1} = \mbox{diag} \left(\frac{1}{x_1}, \frac{1}{x_2}, \dots, \frac{1}{x_m}\right)$$
Using the Woodbury matrix identity, we obtain the following
$$(\mathrm A + \mathrm B)^{-1} = \mathrm D^{-1} (\mathrm x) - -\mathrm D^{-1} (\mathrm x) \begin{bmatrix} | & |\\ \sqrt{a} \, 1_m & \mathrm b\\ | & |\end{bmatrix} \left( \mathrm I_2 + \begin{bmatrix} — \sqrt{a} \, 1_m^{\top} —\\ — \mathrm b^{\top} —\end{bmatrix} \mathrm D^{-1} (\mathrm x) \begin{bmatrix} | & |\\ \sqrt{a} \, 1_m & \mathrm b\\ | & |\end{bmatrix} \right)^{-1} \begin{bmatrix} — \sqrt{a} \, 1_m^{\top} —\\ — \mathrm b^{\top} —\end{bmatrix} \mathrm D^{-1} (\mathrm x)$$
which looks somewhat intimidating but requires only the inversion of a $2 \times 2$ matrix, rather than the inversion of an $m\times m$ matrix.