# Solving a non-linear system where x appears as matrix and vector

I have the following problem. I am trying to solve the following non-linear system of equations in MATLAB

$$\mathbf{b}=\mathrm{diag}\left(\mathbf{x}\right)\left(\mathbf{I}+\mathbf{A'A}\right)^{-1}\left(\mathbf{A'1}-\mathbf{x}\right)$$

where $$\mathbf{b}$$ (known) and $$\mathbf{x}$$ (to be found) are $$N\times1$$ column vectors, $$\mathbf{A'A}$$ (known) is a $$N\times N$$ cosine similarity matrix (symmetric positive definite). $$\mathbf{I}$$ is the identity matrix and $$\mathbf{1}$$ is a $$N\times1$$ vector of ones.

The obvious reference would seem this one: Solving Non Linear System of Equations with MATLAB

the problem is I'm not sure how to take the Jacobian. It seems to me that $$\mathrm{diag}(\mathbf{x})$$ and $$(\mathbf{I+A'A})^{-1}$$ should commute, so perhaps using that could simplify computation of the Jacobian.

But perhaps I'm wrong and that's not the way to go. Perhaps another possibility would be to write

$$\mathbf{b}=\mathrm{diag}\left(\mathbf{x_{t}}\right)\left(\mathbf{I}+\mathbf{A'A}\right)^{-1}\left(\mathbf{A'1}-\mathbf{x_{t+1}}\right)$$

make a guess for $$\mathbf{x}_1$$ and iterate till convergence. Any ideas? Thanks in advance!