Group Abstract Group Abstract

Message Boards Message Boards

0
|
7.1K Views
|
7 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Convert a system of linear equations to matrix-form

Posted 3 years ago

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 ?

As an example: enter image description here

I have such a function but it's non-trivial. It uses the CoefficientList-tensors. I suspect that there must be something better.

POSTED BY: Werner Geiger
7 Replies

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).

POSTED BY: Daniel Lichtblau

You may have a look at 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}}}
POSTED BY: Gianluca Gorni

It seems the source code is not available for this particular function.

POSTED BY: Daniel Lichtblau
Posted 3 years ago
POSTED BY: Werner Geiger
Posted 3 years ago

Oh thanks, Daniel. I did not know this LinearFunctionQ. I will examine it.

POSTED BY: Werner Geiger
Posted 3 years ago

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.

POSTED BY: Werner Geiger
Posted 3 years ago

I Know. I use the CoeffientList-tensors, which are easier to use.

POSTED BY: Werner Geiger
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard