# How to solve $\mathrm{diag}(x) \; A \; x = \mathbf{1}$ for $x\in\mathbb{R}^n$ with $A\in\mathbb{R}^{n \times n}$?

I would like to solve the following equation for $x\in\mathbb{R}^{n}$ $$\mathrm{diag}(x) \; A \; x = \mathbf{1}, \quad \text{with A\in\mathbb{R}^{n\times n}},$$ where $\mathrm{diag}(x)$ is a diagonal matrix whose diagonal elements are the elements of $x$ and $\mathbf{1}$ is a vector whose elements are equal to 1.

I will already be very happy to find a solution if $A$ is a positive definite and symmetric.

Ideally I would like to find a closed-form solution for this quadratic equation.

Any ideas (or solution ;-) would be greatly appreciated.

Other formulation

Another way to formulate this equation is as follows $$A \; x = 1./x, \quad \text{with A\in\mathbb{R}^{n\times n}},$$ where $1./x$ denotes the "element-wise inverse of the vector $x$".

Solution for the 1-dimensional case

The solution for the 1-dimensional case is straightforward $$x = \frac{1}{\sqrt{A}} .$$

• its a non-linear equation. you might use newton's iteration to solve it Commented Jan 28, 2014 at 23:58
• Ideally I would like to find a closed-form expression for the solution of this quadratic equations. Any idea? Commented Jan 30, 2014 at 17:12
• Can you handle the 2-by-2 case? Commented Jan 31, 2014 at 23:03
• What about the 1-by-1 case! Commented Jan 31, 2014 at 23:08
• Thank you for your comments. Regarding the 1-by-1 case, I was able to solve it ;). Regarding the 2-by-2 case, I was also able to solve it but not with a nice matrix formulation. Would it help if I post the solution for the 2-by-2 case (and 1-by-1 case)? Commented Jan 31, 2014 at 23:23

$n=2$
\begin{align} % \mathbf{D} \mathbf{A} x &= \mathbf{1} \\ % \left[ \begin{array}{cc} a_{\{1,1\}} & a_{\{1,2\}} \\ a_{\{2,1\}} & a_{\{2,2\}} \\ \end{array} \right] % \left[ \begin{array}{cc} x_{\{1\}} & 0 \\ 0 & x_{\{2\}} \\ \end{array} \right] % \left[ \begin{array}{c} x_{\{1\}}\\ x_{\{2\}} \\ \end{array} \right] % &= % \left[ \begin{array}{c} 1 \\ 1 \\ \end{array} \right] % \end{align} The least squares solution is \begin{align} % x_{LS} &= \left( \mathbf{D} \mathbf{A} \right)^{+} \mathbf{1} \\ % &= \left( \det \mathbf{DA} \right)^{-1} \left[ \begin{array}{c} \frac{a_{\{2,2\}}}{x_{\{1\}}}-\frac{a_{\{1,2\}}}{x_{\{2\}}} \\ \frac{a_{\{1,1\}}}{x_{\{2\}}}-\frac{a_{\{2,1\}}}{x_{\{1\}}}\end{array} \right] % \end{align}
$n=3$
\begin{align} % \mathbf{D} \mathbf{A} x &= \mathbf{1} \\ % \left[ \begin{array}{ccc} x_{\{1\}} & 0 & 0 \\ 0 & x_{\{2\}} & 0 \\ 0 & 0 & x_{\{3\}} \\ \end{array} \right] % \left[ \begin{array}{ccc} a_{\{1,1\}} & a_{\{1,2\}} & a_{\{1,3\}} \\ a_{\{2,1\}} & a_{\{2,2\}} & a_{\{2,3\}} \\ a_{\{3,1\}} & a_{\{3,2\}} & a_{\{3,3\}} \\ \end{array} \right] % \left[ \begin{array}{c} x_{\{1\}} \\ x_{\{2\}} \\ x_{\{3\}} \\ \end{array} \right] % &= % \left[ \begin{array}{c} 1 \\ 1 \\ \end{array} \right] % \end{align} The least squares solution is \begin{align} % x_{LS} &= \left( \mathbf{D} \mathbf{A} \right)^{+} \mathbf{1} \\ % &= \left( \det \mathbf{DA} \right)^{-1} \left[ \begin{array}{c} % \frac{a_{\{1,3\}} a_{\{3,2\}}-a_{\{1,2\}} a_{\{3,3\}}}{x_{\{2\}}}+a_{\{2,3\}} \left(\frac{a_{\{1,2\}}}{x_{\{3\}}}-\frac{a_{\{3,2\}}}{x_{\{1\}}}\right)+a_{\{2,2\}} \left(\frac{a_{\{3,3\}}}{x_{\{1\}}}-\frac{a_{\{1,3\}}}{x_{\{3\}}}\right) \\ % \frac{a_{\{1,1\}} a_{\{3,3\}}-a_{\{1,3\}} a_{\{3,1\}}}{x_{\{2\}}}+a_{\{2,1\}} \left(\frac{a_{\{1,3\}}}{x_{\{3\}}}-\frac{a_{\{3,3\}}}{x_{\{1\}}}\right)+a_{\{2,3\}} \left(\frac{a_{\{3,1\}}}{x_{\{1\}}}-\frac{a_{\{1,1\}}}{x_{\{3\}}}\right) \\ % \frac{a_{\{1,2\}} a_{\{3,1\}}-a_{\{1,1\}} a_{\{3,2\}}}{x_{\{2\}}}+a_{\{2,2\}} \left(\frac{a_{\{1,1\}}}{x_{\{3\}}}-\frac{a_{\{3,1\}}}{x_{\{1\}}}\right)+a_{\{2,1\}} \left(\frac{a_{\{3,2\}}}{x_{\{1\}}}-\frac{a_{\{1,2\}}}{x_{\{3\}}}\right) % \end{array} \right] % \end{align}