Is there a simply function in WL which converts some given system eqns of linear equations in vars into the standard matrix form A.x == b ?
eqns
vars
A.x == b
As an example:
I have such a function but it's non-trivial. It uses the CoefficientList-tensors. I suspect that there must be something better.
CoefficientList
For verification, there is LinearFunctionQ in the Wolfram Function Repository. For the actual conversion of equations to matrix-vector, CoefficientArays is the recommended method (that is to say, it's what we use in-house).
CoefficientArays
Oh thanks, Daniel. I did not know this LinearFunctionQ. I will examine it.
Daniel, I examined LinearFunctionQ and found:
Hence your function is perfect (BTW: Is the source code available?).
My code may be overloaded, since it outputs detailed messages to tell the user exactly what is wrong with which equation. For simplicity, I think I'll throw that out and use your function.
Thanks for that hint!
It seems the source code is not available for this particular function.
One of the more tricky tasks is to verify that the given equations are linear indeed and contain no mixed terms with respect to the given variables.
You may have a look at CoefficientArrays:
CoefficientArrays
In[1]:= CoefficientArrays[{a + x - y - z == 0, b + x + 2 y + z == 0}, {x, y, z}] // Normal Out[1]= {{a, b}, {{1, -1, -1}, {1, 2, 1}}}
I Know. I use the CoeffientList-tensors, which are easier to use.
CoeffientList