What is the strategy to populate a matrix from a linear system of equations?

As a toy example, I have some scary, complicated math, that generates eq1 and eq2. I can solve this, linear, system using Solve. I want to inspect the matrix that is made before the Solve step. In my application I expect this to be a system to be over defined.

eq1 = a x + y;
eq2 = b x - y;
Solve[{eq1 == 7, eq2 == 1}, {x, y}]

In the toy example, it would be this matrix:

( {
   {a, 1},
   {b, -1}
  } ) // MatrixForm

I could imagine parsing the text or something wacky like that.


1 Answer 1

CoefficientArrays[{eq1, eq2}, {x, y}][[2]] // Normal

{{a, 1}, {b, -1}}


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.