# Solving linear equations using matrix

I'm doing little program, where I need to solve multiple linear equations like: \begin{align*} B_1 &= A_{11}C_1 + A_{12}C_2 + A_{13}C_3 + A_{14}C_4\\ B_2 &= A_{21}C_1 + A_{22}C_2 + A_{23}C_3 + A_{24}C_4\\ B_3 &= A_{31}C_1 + A_{32}C_2 + A_{33}C_3 + A_{34}C_4\\ B_4 &= A_{41}C_1 + A_{42}C_2 + A_{43}C_3 + A_{44}C_4 \end{align*}

All $A_{ij}$ and $B_j$ values are known. I heard it can be done by matrix solving, but I haven't learned it in the school yet. I can't find any article about it by google, because I have no idea what it's called.

Now the question: How is the procedure to solve these linear equations using matrix?

-

The system of linear equations that you wrote down can be succinctly expressed by arranging the numbers $A_{11}, \dotsc, A_{44}$ in a matrix $A$ and the numbers $B_1, \dotsc,B_4$ and $C_1, \dotsc,C_4$ in vectors $b$ and $c$, respectively. Then the system can be written $b=Ac$, or, more conventionally, $Ac=b$. If you don't understand this notation, you might want to take a look at matrix multiplication.

But this is just a convenient way of collecting all the values that belong together in approriately structured objects -- you don't necessarily have to understand any of that in order to solve the system. The standard algorithm to solve systems of linear equations is Gaussian elimination. That's what you should use if you want to solve a system only once. If you need to solve several systems with the same matrix $A$ (i.e. the same values $A_{11},\dotsc,A_{44}$) but different vectors $b$ (i.e. different values $B_1,\dotsc,B_4$), there are more efficient ways of doing that. Responding to your comment: It's not that other ways of solving systems of linear equations are "better" in general; it depends on what you want to do. If you want to solve several systems with the same matrix $A$, then it makes sense to do as much preprocessing as possible on $A$ before bringing the individual $b$s into play; whereas if you have only one $b$ to solve for, it's easier and faster to just plug it in right from the start.

If you want to learn more about other methods, there are some pointers in this section.

-
if there are any better ways to solve it, can u please show them, i've edited the question – kravemir Jul 8 '11 at 21:52
@Miro: From your edit, it seems that some further explanations are required -- I'll be adding them shortly. – joriki Jul 8 '11 at 21:54
My problem is to get blur coefficients from A source image and B blured image. Theres total 9 C unknowns. – kravemir Jul 8 '11 at 21:54
But you have answered the question. I'll create another question for my problem. – kravemir Jul 8 '11 at 21:56

You might take a look at Gaussian Elimination. Any numerical analysis book will have a chapter on this, such as chapter 2 of Numerical Recipes (the obsolete versions are free)

-