# Applications of systems of linear equations

Sorry if this questions is overly simplistic. It's just something I haven't been able to figure out.

I've been reading through quite a few linear algebra books and have gone through the various methods of solving linear systems of equations, in particular, $n$ systems in $n$ unknowns. While I understand the techniques used to solve these for the most part, I don't understand how these situations present themselves. I was wondering if anyone could provide a simple real-world example or two from data analysis, finance, economics, etc. in which the problem they were working on led to a system of $n$ equations in $n$ unknowns. I don't need the solution worked out. I just need to know the problem that resulted in the system.

-
I deleted my answer because I realized there was already an answer by Rahul Narain which is better explained and is essential the same (Kirchhoff's circuit laws.) –  Américo Tavares Jun 12 '11 at 21:56
It's is very disheartening that no one can come up with a straight forward example to explain to a Math student how matrices are useful. Anyone have any example that doesn't require an engineering degree? –  JackOfAll May 4 '12 at 22:51

One of the most frequent occasions where linear systems of $n$ equations in $n$ unknowns arise is in least-squares optimization problems. Let us look at an example. Let's say that we are studying two physical quantities $y$ and $x$ and we conjecture that $y$ is a second order polynomial function of $x$, i.e. $y=\alpha x^2 + \beta x + \gamma$ for some real numbers $\alpha$, $\beta$, $\gamma$ that are unknown. Let's say now that we perform experiments and obtain measurements $(x_1,y_1) \cdots (x_{100},y_{100})$. Applying the polynomial model on the measurements yields $y_i=\alpha x_i^2 + \beta x_i + \gamma$ for $i=1, \cdots 100$ or in matrix form $X k=y$ where $k=[\alpha \, \, \beta \, \, \gamma]^T$, $y=[y_1 \cdots y_{100}]^T$ and the $i^{th}$ row of $X$ is the row vector $[x_i^2 \, \, x_i \, \, 1]$. Now, as you might observe, we have $100$ equations in $3$ unknowns, i.e. our linear system $X k=y$ is overdetermined. Practically speaking, this system is consistent (i.e. it has a solution) only if indeed $y$ is related to $x$ via a second order polynomial equation (i.e. our conjecture is true) and additionally there is no noise in our measurements. So assume that none of the above two conditions is true. Hence the system $X k=y$ will not in general have a solution and one might consider finding a vector $k$ that instead minimizes $||X k - y||_2^2$, i.e. the square of the error. Then the solution of this optimization problem is the solution to the $3 \times 3$ system $X^T X k = X^T y$. This formulation comes up all the time in engineering, e.g. in signal prediction. So, least squares problems lead to square (i.e. $n \times n$) linear systems of equations.

-
Thanks Manos, this is very helpful. –  miggety Jun 11 '11 at 11:57
You are welcome! –  Manos Jun 11 '11 at 14:01

I have no knowledge of finance or economics, but problems in physics and engineering often give rise to linear systems.

For example, say you have a complicated network of resistors, and you apply a potential difference to two junctions in the network (connect them to the ends of a battery, say). What is the current going through each resistor? If the network can be split up into series and parallel combinations of resistors, it's easy to solve, but in general, it's not possible to do this. Then the only way to find the solution is linear algebra: you have $n$ unknowns, the relative potentials at all the other junctions, and $n$ equations, from Kirchhoff's current law at those junctions, and you can solve this system to find the unique solution.

If you don't think this is a real-world problem, you should listen to MC Frontalot: people call him up in the middle of the night to ask him the impedance of a resistor icosahedron.

-

A package of gummi bears contains 20 grams of sugars, 5 grams of fat, and 1 gram of proteins.

A package of butter contains 6 grams of sugars, 15 grams of fat, and 2 gram of proteins.

A chicken contains 2 grams of sugars, 4 grams of fat, and 12 gram of proteins.

(The numbers are fake.)

Joe has bought some gummi bears, butter, and chickens. In total, he ate it and it contained 1 ton of sugars, 1 ton of fats, and 1 ton of proteins. How many packages of gummi bears, butter, and chickens did he buy?

-
How is it a real-life problem? It looks like the completely artificial problems that you can find in high-school textbooks that are designed just to see if one is able to replace « gummi bears » by x, « butter » by y, etc. –  gallais Jun 10 '11 at 14:35
@gallais: I second that that formulation is not much "real-life" (to digest 1 ton of fat ;-) ). However a real-life for this type of questions was one I had to solve: to recompute the amount of certain metallic substances involved from which a set of items was made, which had left the factories' door and had then been inventarized. That simply involved to invert the matrix of composition-coefficients for that items. In short: any regression or factor analysis in statistics (which is real life) needs that solving of systems of linear equations... –  Gottfried Helms Jan 11 '12 at 19:37

Here is an example from cost accounting:

In Chapter 15 of Cost Accounting: A Managerial Emphasis, 14th ed., by Horngren, Datar, and Rajan, one of the sections covers a method of allocating costs of support departments such as Personnel and Legal to operating departments such as the refrigerator and dish washer manufacturing divisions of a kitchen appliances manufacturer. Special consideration needs to be given for the common scenario where support departments support each other. For example, the Personnel department may support the Legal department by hiring paralegals and attorneys while the Legal department might support the Personnel department by evaluating compensation plans and interpretting regulatory requirements.

The most justifiable method presented in the chapter is called the "reciprocal method" or "matrix method". It uses a system of linear equations to calculate the total cost of each support department, factoring in reciprocal support, so that the total cost can be allocated to the operating departments.

For example, assume the following facts:

• The Personnel Department's budgeted fixed costs are $1,200,000, not including reciprocal support costs. • The Legal Department's budgeted fixed costs are$2,000,000, not including reciprocal support costs.
• Personnel Department costs are allocated on the basis of recruiter hours.
• Legal Department costs are allocated on the basis of attorney hours.
• The Personnel Department is budgeted to utilize 5% of the Legal Department's budget for attorney hours.
• The Legal Department is budgeted to utilize 10% of the Personnel Department's budget for recruiter hours.

Let $P_F$ be the Personnel Department's total fixed costs and $L_F$ be the Legal Department's total fixed costs. Then:

\begin{align} P_F &= \1,200,000 + 5\% \times L_F\\ L_F &= \2,000,000 + 10\% \times P_F \end{align} We have: \begin{align} L_F &= \2,000,000 + 10\% \times (\1,200,000 + 5\% \times L_F) \\ 99.5\% \times L_F &= \2,120,000 \\ L_F &= \2,130,653.27 \end{align} \begin{align} P_F &= \1,200,000 + 5\% \times \2,130,653.27\\ &= \1,306,532.66 \end{align} The related matrix is: $$\begin{bmatrix} 1 & -0.05 \\ -0.1 & 1 \end{bmatrix}$$

The system of linear equations is larger with more support departments.

-