# How to solve for this matrix?

I have a mapping $f:R^3\rightarrow R^3$ such that: $$x_1=(1+\eta)X_1$$ $$x_2=(1+\gamma)X_2$$ $$x_3=(1+\gamma)X_3$$ and I have to obtain the transformation matrix $\varepsilon$ corresponding to this mapping. I know the matrix has to be$$\varepsilon=\begin{pmatrix}1+\eta& 0& 0\\ 0& 1+\gamma& 0\\ 0& 0& 1+\gamma\end{pmatrix}.$$ I want to get this matrix using Mathematica but I don't know how. I tried the following:

x1 = (1 + \[Eta]) X1;
x2 = (1 + \[Gamma]) X2;
x3 = (1 + \[Gamma]) X3;
\[Epsilon] = {{\[Epsilon]11, \[Epsilon]12, \[Epsilon]13}, \
{\[Epsilon]21, \[Epsilon]22, \[Epsilon]23}, {\[Epsilon]31, \
\[Epsilon]32, \[Epsilon]33}};
Solve[{x1, x2, x3} == \[Epsilon] .{X1, X2, X3}, {\[Epsilon]11, \[Epsilon]12,
\[Epsilon]13, \[Epsilon]21, \[Epsilon]22, \[Epsilon]23, \[Epsilon]31,
\[Epsilon]32, \[Epsilon]33}] // Simplify


but I got the message Solve::svars: Equations may not give solutions for all "solve" variables. and some strange output.

How to let Mathematica correctly solve for $\varepsilon$ ?

• It's giving you the correct solution. It's just that you have three equations and 9 variables, so there's infinitely many solutions. Let sol be your solution and try (\[Epsilon] /. sol).{X1, X2, X3} // Simplify. Basically, it means that you're free to set 6 of your variables to whatever you want (like zero). – aardvark2012 Oct 7 '17 at 10:37
• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – Michael E2 Oct 7 '17 at 12:56

In general, for a linear form, you can use the linear component (part [[2]]) of CoefficientArrays:

Normal@CoefficientArrays[{x1, x2, x3}, {X1, X2, X3}][[2]]


Solved the problem in the following way:

Subscript[x, 1] = (1 + \[Eta]) Subscript[X, 1];
Subscript[x, 2] = (1 + \[Gamma]) Subscript[X, 2];
Subscript[x, 3] = (1 + \[Gamma]) Subscript[X, 3];
\[Epsilon] = Table[Coefficient[Subscript[x, i], Subscript[X, j]], {i, 3}, {j, 3}]
\[Epsilon] // MatrixForm


It looks like I shouldn't have dealt with it as an equation to be solved.

• If solving isn't necessary, you could also use DiagonalMatrix[1 + \[Eta], 1 + \[Gamma], 1 + \[Gamma]]. – aardvark2012 Oct 7 '17 at 11:06
• Ok, thank you for this shortcut! – Tofi Oct 7 '17 at 12:18
• Right, no need to solve for anything, it's really a matter of converting from explicit equations to matrix algebra. – Daniel Lichtblau Oct 7 '17 at 15:16