Solve $\operatorname{diag}(x) \nabla f(x)= A x, f(0)=0$

linear algebramultivariable-calculuspartial differential equations

How to solve the following equation:
$$
\operatorname{diag}(x) \nabla f(x)= A x
$$

where $f: \mathbb{R}^n \to \mathbb{R}$ and $A \in \mathbb{R}^{n \times n}$ with condition $f(0)=0$. Assume column vectors are used. Here $\operatorname{diag}(x)$ for a vector $x$ is a squared matrix where $x$ forms a main diagonal. $\nabla f(x)$ is a gradient of $f$.

Here is my approach.
$$
\nabla f(x) = \operatorname{diag}^{-1}(x) A x.
$$

Now using FTC and choosing $r(t)=(1-t)0+t*x$
\begin{align}
f(x)=f(r(1))&= \int_0^1 \nabla f(r(t)) \cdot r'(t) \,\mathrm dt\\
&= \int_0^1 x^T \operatorname{diag}^{-1}(tx) A tx \,\mathrm dt\\
&= x^T \operatorname{diag}^{-1}(x) A x\\
&= \mathbb{1}^TA x
\end{align}

where $\mathbb{1}$ is a vector of of all ones.

However, upon checking we have that
$$
\nabla f(x)= \nabla \mathbb{1}^TA x= A^T \mathbb{1}
$$

and now checkign the differential equation
$$
\operatorname{diag}(x) A^T \mathbb{1}= A x .
$$

However, I don't think the above equality is true. I am not sure where I am making a mistake.

Edit 2: From one of the answers, it appears that the solution exists only if, $A$ is a diagonal matrix.

Best Answer

It is sometimes useful to look at subcases in order to get an intuition about the problem and its solution.

  • If $n=1$, then we consider the differential equation $x f'(x) = A x$, $f(0) = 0$. The differential equation is always satisfied at $x=0$, for all $f$, $A$. For $x\neq 0$, we can divide on both sides, and we obtain the solution $f(x) = A x$.

  • If $n=2$, then we consider the PDE system $$ \begin{aligned} x_1 f_{,1}(x) &= A_{11} x_1 + A_{12} x_2 \\ x_2 f_{,2}(x) &= A_{21} x_1 + A_{22} x_2 \, . \end{aligned} $$ With a similar reasoning, the first equation yields $f(x) = A_{11} x_1 + A_{12} x_2\ln x_1 + c_1(x_2)$. Substitution in the second equation gives $c'_1(x_2) = A_{21} x_1/x_2 + A_{22} - A_{12} \ln x_1$, which is supposed to be a function of $x_2$ only. Thus, $A_{21} = A_{12} = 0$ is required, and we have $$f(x) = A_{11} x_1 + A_{22} x_2 \, ,$$ by using the initial condition.

Hope this helps for solving the general case, which partial resolution in OP looks fine.


Hint: The linear system of algebraic equations $\text{diag}(x)A^\top 1 = Ax$ may be rewritten as $$ \sum_{j\neq i} (A_{ji} x_i - A_{ij} x_j) = 0 \qquad \forall\, i\in \lbrace1\dots n\rbrace ,\; \forall\, x $$ which is of the form $Bx = 0$. Since this identity must be true for all $x$, the matrix $B$ has to be equal to zero, which is already the case for $n=1$. In the case $n=2$, we end up with the condition $A_{21} = A_{12} = 0$. In the general case, the previous linear system implies that $A$ has to be diagonal.

Following this post, one may alternatively use the fact that $\nabla f(x) = \text{diag}(x)^{-1}\! A x$ leads to the identity $\text{curl} (\text{diag}(x)^{-1}\! A x) = 0$ to be satisfied for all $x$.

Related Question