# How to join the lhs and rhs of the rows of a matrix equation and solve for one of the variables?

The matrix equation m.{x,y}==b results in an awkward disjointed looking presentation but correct construction of a system of linear equations {x + y, -x + y} == {1, 2}.

• How do I put the results of m.{x,y}==b in a more proper form such as eqs={x+y==1,-x+y==2}.
• How to solve eqs={x+y==1,-x+y==2} for y in terms of x so that the outcome looks like this: eqs={y==1-x,y==2+x}?

Here is the working code...

ClearAll[m,b,vars,x,y,eqs];
m = {{1, 1}, {-1, 1}};
b = {1, 2};
vars={x,y};
eqs = m.vars == b;

• For the first part, do this eqs = Thread[m.vars == b]. For the second part, this is one way: Flatten[Solve[#, y] & /@ eqs] /. Rule -> Equal Aug 5, 2020 at 7:31
• @LouisB Thank you for your help. By the way I had just figured out how to do first part and it is the same as your solution. Who knew Thread was the key and so easy? But I definitely appreciate the second part. Thanks again. Aug 5, 2020 at 7:42
• @LouisB what does this translate to /@? What I mean what is the name of that operator.? How would the second part look if written in StandardForm where all operators and functions are expressed without shortcuts? I wish to examine it closely so I could learn from it. Aug 5, 2020 at 8:34
• /@ is a shortcut to the Map function. The idea is to map the Solve function onto each equation in eqs. Since Solve takes more than one argument, we create a pure function using & (Function) with # (Slot) to indicate the argument of the pure function. Click on the symbol in the front-end and press F1 to get the help page for the symbol. The documentation for Function has many useful examples. Also see Why use pure functions Aug 5, 2020 at 9:04
• @JulesManson If you type /@ in the documentation browser it will take you to the right function. This is very helpful as well for other mysterious glyphs like @*, /* and @@@. You can also use FullForm[Hold[f /@ x]] to see what /@ is short for. Aug 5, 2020 at 9:19