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}==bin a more proper form such aseqs={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;
eqs = Thread[m.vars == b]. For the second part, this is one way:Flatten[Solve[#, y] & /@ eqs] /. Rule -> Equal– LouisB Aug 05 '20 at 07:31Threadwas the key and so easy? But I definitely appreciate the second part. Thanks again. – Jules Manson Aug 05 '20 at 07:42/@? What I mean what is the name of that operator.? How would the second part look if written inStandardFormwhere all operators and functions are expressed without shortcuts? I wish to examine it closely so I could learn from it. – Jules Manson Aug 05 '20 at 08:34/@is a shortcut to theMapfunction. The idea is to map theSolvefunction onto each equation ineqs. SinceSolvetakes 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 forFunctionhas many useful examples. Also see Why use pure functions – LouisB Aug 05 '20 at 09:04/@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 useFullForm[Hold[f /@ x]]to see what/@is short for. – Sjoerd Smit Aug 05 '20 at 09:19