# Building a coefficient matrix for a system of equations

• I

## Main Question or Discussion Point

I want to solve the following system of equations

##M_{1} = f_1+f_2+m_1+m_2\ \ ;\ \ M_{7} = f_1+f_2+s_1+s_2\ \ ;\ \ M_{13} = m_1+m_2+s_1+s_2##
##M_{2} = f_1+f_3+m_1+m_3\ \ ;\ \ M_{8} = f_1+f_3+s_1+s_3\ \ ;\ \ M_{14} = m_1+m_3+s_1+s_3##
##M_{3} = f_1+f_4+m_1+m_4\ \ ;\ \ M_{9} = f_1+f_4+s_1+s_4\ \ ;\ \ M_{15} = m_1+m_4+s_1+s_4##
##M_{4} = f_2+f_3+m_2+m_3\ \ ;\ \ M_{10} = f_2+f_3+s_2+s_3\ \ ;\ \ M_{16} = m_2+m_3+s_2+s_3##
##M_{5} = f_2+f_4+m_2+m_4\ \ ;\ \ M_{11} = f_2+f_4+s_2+s_4\ \ ;\ \ M_{17} = m_2+m_4+s_2+s_4##
##M_{6} = f_3+f_4+m_3+m_4\ \ ;\ \ M_{12} = f_3+f_4+s_3+s_4\ \ ;\ \ M_{18} = m_3+m_4+s_3+s_4##

where the 18 M coefficients are known and the 12 f, m, and s coefficients are unknown.

The strategy I want to use is to build a coefficient matrix and solve by inversion, but how can I do this for this system with minimal algebraic manipulation? For example, it is easy to see that at least 6 expressions for each unknown coefficient can be written. Perhaps this could result in a (6*12) by (6*12) coefficient matrix, but I'm unsure what it would look like, or if I am thinking about this correctly.

So, how do I arrange the coefficients so that
##f_1=M_1-f_2-m_1-m_2##
and
##f_1=M_2-f_3-m_1-m_3##
etc. are both satisfied. I thought you could make them both separate variables, like ##f_{1a}## and ##f_{1b}## and then have another equation express that ##f_{1a}=f_{1b}##, but I can't recall how to do this.

Last edited:

Related Linear and Abstract Algebra News on Phys.org
PeroK
Homework Helper
Gold Member
Can't you simply combine equations? It won't be too bad. Reduce to a set of equations for the ##m_i## first.

I'll be interested in getting rid of superfluous information or simplifying things, but at the moment I just want to get a naive approach working because the solution follows straightforwardly from the equations. Also, I need to learn this..

I figured that the coefficient matrix doesn't need to be square, so maybe the system could look like:

$$\begin{bmatrix} 1 & 1 & & & 1 & 1 & & & & & & \\ 1 & & 1 & & 1 & & 1 & & & & & \\ 1 & & & 1 & 1 & & & 1 & & & & \\ & 1 & 1 & & & 1 & 1 & & & & & \\ & 1 & & 1 & & 1 & & 1 & & & & \\ & & 1 & 1 & & & 1 & 1 & & & & \\ 1 & 1 & & & & & & & 1 & 1 & & \\ 1 & & 1 & & & & & & 1 & & 1 & \\ 1 & & & 1 & & & & & 1 & & & 1\\ & 1 & 1 & & & & & & & 1 & 1 & \\ & 1 & & 1 & & & & & & 1 & & 1\\ & & 1 & 1 & & & & & & & 1 & 1\\ & & & & 1 & 1 & & & 1 & 1 & & \\ & & & & 1 & & 1 & & 1 & & 1 & \\ & & & & 1 & & & 1 & 1 & & & 1\\ & & & & & 1 & 1 & & & 1 & 1 & \\ & & & & & 1 & & 1 & & 1 & & 1\\ & & & & & & 1 & 1 & & & 1 & 1\\ \end{bmatrix} \begin{bmatrix} f_1\\ f_2\\ f_3\\ f_4\\ m_1\\ m_2\\ m_3\\ m_4\\ s_1\\ s_2\\ s_3\\ s_4 \end{bmatrix} = \begin{bmatrix} M_1\\ M_2\\ M_3\\ M_4\\ M_5\\ M_6\\ M_7\\ M_8\\ M_9\\ M_{10}\\ M_{11}\\ M_{12}\\ M_{13}\\ M_{14}\\ M_{15}\\ M_{16}\\ M_{17}\\ M_{18} \end{bmatrix}$$

Unfortunately, I solved an example with matlab backslash and the result is not correct. The solved unknowns do not return the M coefficients with the original equations. Also, vertically flipping the coefficient matrix and left hand side vector changes the solution, which should not happen because they are the same equations.

Last edited:
PeroK
Homework Helper
Gold Member
Doing row operations on that matrix is just the same as combining equations. Using the equations looks like a good option, as you can keep it simple. A 12x18 matrix is a bit unwieldy.

jasonRF
Gold Member
Unfortunately, I solved an example with matlab backslash and the result is not correct. The solved unknowns do not return the M coefficients with the original equations. Also, vertically flipping the coefficient matrix and left hand side vector changes the solution, which should not happen because they are the same equations.
You have 18 equations for 12 unknowns. In this case the backslash operator will find the least-squares solution, so if the equations are not consistent then the solution you get will not exactly solve them. Are your equations consistent?

jason

• Paul Colby
jasonRF
Gold Member
By the way, one way to check for consistency is the following. If your matrix equation is ##\mathbf{A}x=b##, then you can look at the row-reduced form of the augmented matrix to see if any of the equations reduce to ##1=0##. In matlab,
>> M=[A, b]; %M is the augmented matrix
>> R = rref(M) %R is the row-reduced echelon form of M

jason

epenguin
Homework Helper
Gold Member
Hypatio seems almost there. If this is an algebraic problem (and Hypatio, not for the first time, does not fully inform us) I would change the unknowns to more meaningful ones e.g ##a_{i}=f_{i}+m_{i}##, i = 1, 2, 3, 4.
Then the first column of equations is 6 equations in 4 unknowns and you find you must have ##M_{5}-M_{6}=M_{1}-M_{2}## etc. or else this column is not consistent, has no solutions. And there should be a second test of that kind. Similarly you can test the second and third columns.

Assuming this OK, you have for the first column 4 equations in 4 unknowns, ##a_{i}##, fairly easy to solve as the matrices are full of zeroes. If the second and third columns are consistent equations with unique solution you do not have to solve them again, Just change names and numbers in your previous solutions.

It should then be possible to express solutions in terms of the original unknowns in an infinite number of ways, amongst which perhaps some are natural, depending on what the original problem was.

If instead this is not an algebraic question but a numerical analysis/statistical one where e.g. ##\left( M_{1}-M_{2}\right) -\left( M_{5}-M_{6}\right) ## is not exactly 0 but sufficiently small this would be above my pay grade, but I imagine you still do these things anyway.

And anyway (afterthought but should come first) the f, m, s can be isolated. Subtract the second column from the first and add the result to the third and we have a column of s (×2) alone, and we can get one for f and m too.

This problem begins to look so artificially inflated in apparent difficulty I think Hypatio should tell us where it comes from. And also relation with other problems he has brought.

Last edited:
Svein