Solve matrix vector equation Let $A$ be a real $n\times n$ matrix and $w,x$ real $n\times 1$ vectors.
For fixed $A$ and $w$ solve the following for $x$:
$(x^\top A x)w - (x^\top w) (A+A^\top) x = 0$
Any hints?
I do not really feel confident on what kind of rearrangements are legit since multiplication is generally not commutative and I do not know how to deal with the scalar products in there.
 A: Firstly, if $w=0$ then any $x$ is a solution.
We now consider the nontrivial case $w\neq 0$.
Let us assume that $x$ is a solution, and let $\mathcal N:= {\rm Ker}(A+A^T)$.
Notice that any $x\in\mathcal N$ is a solution (to see this you may need to observe that $x^TAx = \frac12x^T(A+A^T)x$).
Let us now look for solutions $x\notin\mathcal N$, and let us decompose $x=x_\parallel + x_\perp$ with $x_\parallel\in \mathcal N$ and $x_\perp \in \mathcal N^\perp$.
Then,
$$
(x^TAx)w - (x^Tw)(A+A^T)x
=
(x^TAx)w - (x^Tw)(A+A^T)x_\perp
$$
We have two options now:


*

*either $x^TAx = 0$, in which case necessarily $x\perp w$ (since $x\notin\mathcal N$ we have $x_\perp\neq 0$);

*or $x^TAx\neq 0$ and $w=\frac{x^Tw}{x^TAx}(A+A^T)x$.


The first case tells us that any vector in the set $\{x:~x^TAx = 0,~x\perp w\}$ is a solution.
In the second case, we may recursively replace $w$ on the rhs, yielding
\begin{align}
\color{blue}w
={} &
\frac{x^T\color{red}w}{x^TAx}(A+A^T)x
=
\frac{x^T\color{red}{\left(
\frac{x^Tw}{x^TAx}(A+A^T)x
\right)}}{x^TAx}(A+A^T)x
=
\frac{(x^T(A+A^T)x)
  \frac{x^Tw}{x^TAx}
  }
  {x^TAx}
  (A+A^T)x
\\
={} &
\frac{2x^TAx
  \frac{x^Tw}{x^TAx}
  }
  {x^TAx}
  (A+A^T)x
=
2
\frac{x^Tw}
  {x^TAx}
  (A+A^T)x
=
\color{blue}{2w}
\end{align}
So necessarily $w=2w$ and hence $w=0$, which we excluded at the beginning.
It follows that the set of solutions is
$$
X^\star
=
\begin{cases}
\mathbb R^n & \text{if } w=0 \\
\{x:x^TAx=0\} \cap \{w\}^\perp & \text{otherwise}
\end{cases}
$$


Extra: how to determine the set $\mathcal N_0:=\{x:~x^TAx=0\}$
If $(A+A^T)$ is semidefinite (either positive or negative), then it is trivial to observe that such set is simply ${\rm Ker}(A+A^T)$.
In general, $\mathcal N\subseteq N_0$.
To determine it you can compute the eigenvalues $\lambda_1\ldots\lambda_n$ and a corresponding orthonormal basis of eigenvectors $e^1\ldots e^n$ of $A+A^T$.
(note: in order to avoid confusion I use superscripts for vectors and subscripts for scalars, and it should be obvious that when both appear, then the superscript is a power...).
Then each $x$ decomposes as $x=\sum_{i=1}^nx_ie^i$ and
$$
x^TAx = \sum_{i=1}^n\lambda_ix_i^2
$$
Let $(p,q,r)$ be the signature of $A+A^T$, and reorder eigenvectors/eigenvalues according to the sign of the eigenvalues as follows:
$$
\lambda_1\ldots\lambda_p >0
\quad
\lambda_{p+1}\ldots\lambda_{p+q} <0
\quad
\lambda_{p+q+1}\ldots\lambda_n = 0
$$
($r=n-p-q$).
For clarity, let $\mu_1=-\lambda_{p+1}\cdots \mu_q=-\lambda_{p+q}>0$ so that
$$
x^TAx = \sum_{i=1}^p\lambda_i x_i^2 - \sum_{j=1}^q\mu_j x_{p+j}^2
$$
From the expression above it is clear that in order for it to vanish, the two sums must cancel out while the components $x_{p+q+1}\ldots x_n$ can be anything (indeed $\mathcal N\subseteq\mathcal N_0$).
Furthermore, notice that, trivially, $\mathcal N_0$ is a vector space and hence it suffices to find a set of generators.
Considering couples $w^{i,j} = a_{i,j}e^i + b_{i,j}e^{p+j}$ for $i=1\ldots p$ and $j=1\ldots q$ and for some $a_{i,j},b_{i,j}$ to be determined, we have
$$
{w^{i,j}}^TAw^{i,j}
=
a_{i,j}^2\lambda_i - b_{i,j}^2\mu_j
$$
In order for it to be zero we may consider $a_{i,j} = \sqrt{\mu_j}$ and $b_{i,j} = \sqrt{\lambda_i}$.
We hence have that
$$
\mathcal N
\oplus
{\rm span}
\bigl\{
 \sqrt{\mu_j}e^i+\sqrt{\lambda_i}e^{p+j}
 \,:~
 i=1\ldots p,~ j=1\ldots q
\bigr\}
\leq\mathcal N_0
$$
I guess that with a small extra effort it can be proved that the opposite inclusion works as well. I encourage you to try and let me know :)
