Two Applications of Matrix Algebra
The Leontief input-output model (Section 2.6) · Applications to computer graphics (Section 2.7)
By the end of this week you will be able to:
- build the consumption matrix of an economy from a description of its sectors, and compute intermediate demand;
- set up and solve the Leontief production equation \(\mathbf x=C\mathbf x+\mathbf d\), with row reduction or with \((I-C)^{-1}\);
- explain the meaning of the entries of \((I-C)^{-1}\) and of the series \(I+C+C^2+\cdots\);
- transform a figure given by a data matrix, and use homogeneous coordinates to write translations, rotations, reflections and scalings as \(3\times3\) matrices;
- write the matrix of a composite transformation in the right order, including rotation about a point that is not the origin;
- use \(4\times4\) matrices for transformations of \(\mathbb R^3\), and compute a perspective projection.
- This note is covered in one lecture. Both sections are applications of the matrix algebra of Week 5.
- Wednesday: review session for Midterm 1. Friday: Midterm 1.
- There is no homework this week.
- Exam scope: Sections 2.6 and 2.7 are not on Midterm 1. They are Midterm 2 material. Expect questions on the Leontief model and on homogeneous coordinates in the second midterm.
Part 1: The Leontief Input-Output Model
An economy with several sectors is described by one matrix. The question "how much must each sector produce?" becomes a matrix equation.
- For a matrix \(C=[\,\mathbf c_1\ \cdots\ \mathbf c_n\,]\) and a vector \(\mathbf x\): \(C\mathbf x=x_1\mathbf c_1+\cdots+x_n\mathbf c_n\).
- \(I\mathbf x=\mathbf x\), and \(A\mathbf x-B\mathbf x=(A-B)\mathbf x\).
- If \(A\) is invertible, \(A\mathbf x=\mathbf b\) has the unique solution \(\mathbf x=A^{-1}\mathbf b\). For \(A=\begin{bmatrix}a&b\\c&d\end{bmatrix}\) with \(ad-bc\neq0\): \(A^{-1}=\dfrac{1}{ad-bc}\begin{bmatrix}d&-b\\-c&a\end{bmatrix}\).
1.1 Sectors, production and demand
Suppose a nation's economy is divided into \(n\) sectors that produce goods or services. Let \(\mathbf x\) in \(\mathbb R^n\) be the production vector: it lists the output of each sector for one year. Another part of the economy, the open sector, does not produce anything; it only consumes. Let \(\mathbf d\) be the final demand vector: it lists the values demanded from each sector by the open sector (consumers, government, exports, and so on).
The producing sectors also demand goods from each other, because they need inputs to produce. This is called intermediate demand. Leontief asked: is there a production level \(\mathbf x\) such that the amount produced exactly balances the total demand?
\[\{\text{amount produced } \mathbf x\}=\{\text{intermediate demand}\}+\{\text{final demand } \mathbf d\}\]The basic assumption of the model is that for each sector \(j\) there is a unit consumption vector \(\mathbf c_j\) in \(\mathbb R^n\) that lists the inputs needed from each sector to produce one unit of output of sector \(j\). All units are measured in millions of dollars, and prices are held constant.
The \(n\times n\) matrix \(C=[\,\mathbf c_1\ \mathbf c_2\ \cdots\ \mathbf c_n\,]\) is the consumption matrix of the economy. Its entry \(c_{ij}\) is the amount of output of sector \(i\) consumed per unit of output of sector \(j\).
As an example, consider an economy with three sectors: manufacturing, agriculture and services. The table lists the inputs consumed per unit of output. Read it column by column: each column is one unit consumption vector.
| Purchased from | Manufacturing | Agriculture | Services |
|---|---|---|---|
| Manufacturing | .50 | .40 | .20 |
| Agriculture | .20 | .30 | .10 |
| Services | .10 | .10 | .30 |
| \(\mathbf c_1\) | \(\mathbf c_2\) | \(\mathbf c_3\) |
Producing one unit of manufacturing output consumes the amounts in \(\mathbf c_1\), so producing 100 units consumes \(100\,\mathbf c_1=(50,20,10)\): 50 units from other companies in the manufacturing sector, 20 from agriculture, 10 from services.
If manufacturing produces \(x_1\) units, agriculture \(x_2\) units and services \(x_3\) units, the intermediate demands they create are \(x_1\mathbf c_1\), \(x_2\mathbf c_2\) and \(x_3\mathbf c_3\). The total intermediate demand is their sum, and a sum of this form is a matrix-vector product:
\[\{\text{intermediate demand}\}=x_1\mathbf c_1+x_2\mathbf c_2+x_3\mathbf c_3=C\mathbf x.\]1.2 The production equation
Putting the two pieces together, the balance condition "produced = intermediate demand + final demand" becomes an equation for \(\mathbf x\).
Since \(\mathbf x=I\mathbf x\), the equation can be written as \(I\mathbf x-C\mathbf x=\mathbf d\), that is,
\[(I-C)\mathbf x=\mathbf d.\]An economy has two sectors with consumption matrix and final demand
\[C=\begin{bmatrix}.1&.6\\.5&.2\end{bmatrix},\qquad \mathbf d=\begin{bmatrix}18\\11\end{bmatrix}.\]Find the production level \(\mathbf x\) that satisfies this demand.
Solution
The coefficient matrix of the production equation is
\[I-C=\begin{bmatrix}1&0\\0&1\end{bmatrix}-\begin{bmatrix}.1&.6\\.5&.2\end{bmatrix}=\begin{bmatrix}.9&-.6\\-.5&.8\end{bmatrix}.\]Its determinant is \((.9)(.8)-(-.6)(-.5)=.72-.30=.42\neq0\), so \(I-C\) is invertible and by the \(2\times2\) formula
\[(I-C)^{-1}=\frac{1}{.42}\begin{bmatrix}.8&.6\\.5&.9\end{bmatrix}.\]Then
\[\mathbf x=(I-C)^{-1}\mathbf d=\frac{1}{.42}\begin{bmatrix}.8(18)+.6(11)\\.5(18)+.9(11)\end{bmatrix}=\frac{1}{.42}\begin{bmatrix}14.4+6.6\\9+9.9\end{bmatrix}=\frac{1}{.42}\begin{bmatrix}21\\18.9\end{bmatrix}=\begin{bmatrix}50\\45\end{bmatrix}.\]Sector 1 must produce 50 units and sector 2 must produce 45 units.
Check. \(C\mathbf x+\mathbf d=\begin{bmatrix}.1(50)+.6(45)\\.5(50)+.2(45)\end{bmatrix}+\begin{bmatrix}18\\11\end{bmatrix}=\begin{bmatrix}32+18\\34+11\end{bmatrix}=\begin{bmatrix}50\\45\end{bmatrix}=\mathbf x\). The intermediate demand is \((32,34)\) and the final demand is \((18,11)\); together they use up exactly what is produced.
An economy is divided into three sectors: manufacturing, agriculture and services. For each unit of output, manufacturing requires .10 unit from other companies in that sector, .30 unit from agriculture, and .30 unit from services. For each unit of output, agriculture uses .20 unit of its own output, .60 unit from manufacturing, and .10 unit from services. For each unit of output, the services sector consumes .10 unit from services, .60 unit from manufacturing, but no agricultural products.
Solution
Check. \(C\mathbf x=\begin{bmatrix}.1(40)+.6(15)+.6(15)\\.3(40)+.2(15)+0\\.3(40)+.1(15)+.1(15)\end{bmatrix}=\begin{bmatrix}22\\15\\15\end{bmatrix}\), and \(C\mathbf x+\mathbf d=(22+18,\ 15,\ 15)=(40,15,15)=\mathbf x\).
Self-check only. These exercises are not graded. Entries may be typed as integers, decimals (1.5 or 1,5) or simple fractions (3/2). Your answers are checked by substitution, not by comparison with one stored answer.
Consider the production model \(\mathbf x=C\mathbf x+\mathbf d\) for an economy with two sectors, where
\[C=\begin{bmatrix}.0&.5\\.6&.2\end{bmatrix},\qquad \mathbf d=\begin{bmatrix}50\\30\end{bmatrix}.\]1.3 When does the model have a good solution?
In Examples 1 and 2 the production vector came out with nonnegative entries, as it should for an economy. The next theorem says this always happens under a natural condition. The column sum of a matrix is the sum of the entries in one column. A column sum of the consumption matrix is less than 1 when a sector needs less than one unit's worth of inputs to produce one unit of output, which is the normal situation.
Let \(C\) be the consumption matrix for an economy, and let \(\mathbf d\) be the final demand. If \(C\) and \(\mathbf d\) have nonnegative entries and if each column sum of \(C\) is less than 1, then \((I-C)^{-1}\) exists and the production vector
\[\mathbf x=(I-C)^{-1}\mathbf d\]has nonnegative entries and is the unique solution of \(\mathbf x=C\mathbf x+\mathbf d\).
In Example 1 the column sums of \(C\) are \(.6\) and \(.8\); in Example 2 they are \(.7\), \(.9\) and \(.7\). In both cases the theorem applies.
A formula for \((I-C)^{-1}\)
The following argument suggests why the theorem is true and gives a second way to compute \((I-C)^{-1}\). Imagine that the demand \(\mathbf d\) is presented to the industries at the beginning of the year, and they set their production at \(\mathbf x=\mathbf d\). To produce \(\mathbf d\) they need inputs, which creates an intermediate demand of \(C\mathbf d\). To meet this additional demand they need further inputs \(C(C\mathbf d)=C^2\mathbf d\), which creates a third round of demand \(C^3\mathbf d\), and so on.
| Demand that must be met | Inputs needed to meet this demand |
|---|---|
| Final demand \(\mathbf d\) | \(C\mathbf d\) |
| 1st round: \(C\mathbf d\) | \(C(C\mathbf d)=C^2\mathbf d\) |
| 2nd round: \(C^2\mathbf d\) | \(C(C^2\mathbf d)=C^3\mathbf d\) |
| 3rd round: \(C^3\mathbf d\) | \(C(C^3\mathbf d)=C^4\mathbf d\) |
| \(\vdots\) | \(\vdots\) |
The production level that meets all of this demand is
\[\mathbf x=\mathbf d+C\mathbf d+C^2\mathbf d+C^3\mathbf d+\cdots=(I+C+C^2+C^3+\cdots)\,\mathbf d. \tag{6}\]To make sense of the infinite sum, multiply out the product below (most terms cancel in pairs):
\[(I-C)(I+C+C^2+\cdots+C^m)=I-C^{m+1}. \tag{7}\]It can be shown that if the column sums of \(C\) are all strictly less than 1, then \(I-C\) is invertible and \(C^m\) approaches the zero matrix as \(m\) grows. (Compare: if \(0 The right side can be made as close to \((I-C)^{-1}\) as desired by taking \(m\) large enough. In real input-output models the powers \(C^m\) become small quickly, so (8) is a practical way to compute \((I-C)^{-1}\), and (6) is a practical way to solve \((I-C)\mathbf x=\mathbf d\). Since all entries in \(C\) and \(\mathbf d\) are nonnegative, (6) also shows why \(\mathbf x\) has nonnegative entries. The entries of \((I-C)^{-1}\) predict how the production must change when the final demand changes. Suppose \(\mathbf x\) satisfies the demand \(\mathbf d\) and \(\Delta\mathbf x\) satisfies a different demand \(\Delta\mathbf d\): Adding the two equations gives \((I-C)(\mathbf x+\Delta\mathbf x)=\mathbf d+\Delta\mathbf d\). So if the final demand changes from \(\mathbf d\) to \(\mathbf d+\Delta\mathbf d\), the new production level is \(\mathbf x+\Delta\mathbf x\), where \(\Delta\mathbf x=(I-C)^{-1}\Delta\mathbf d\). Now take \(\Delta\mathbf d=\mathbf e_j\), an increase of 1 unit in the final demand for sector \(j\) only. Then \(\Delta\mathbf x=(I-C)^{-1}\mathbf e_j\), which is column \(j\) of \((I-C)^{-1}\). Self-check only. Your vectors are checked by substitution into the production equation. Let \(C\) and \(\mathbf d\) be as in Exercise 1.A: \(C=\begin{bmatrix}0&.5\\.6&.2\end{bmatrix}\), \(\mathbf d=\begin{bmatrix}50\\30\end{bmatrix}\), \((I-C)^{-1}=\begin{bmatrix}1.6&1\\1.2&2\end{bmatrix}\).1.4 The economic meaning of the entries of \((I-C)^{-1}\)
Part 2: Applications to Computer Graphics
A picture on a screen is a list of points. Moving the picture is matrix multiplication, once we choose the right coordinates.
- The columns of a product \(AD=[\,A\mathbf d_1\ \cdots\ A\mathbf d_k\,]\) are \(A\) times the columns of \(D\).
- Matrix multiplication is composition: applying \(B\) first and then \(A\) is multiplication by \(AB\). In general \(AB\neq BA\).
- Standard matrices of some linear transformations of \(\mathbb R^2\): rotation through angle \(\varphi\) about the origin \(\begin{bmatrix}\cos\varphi&-\sin\varphi\\ \sin\varphi&\cos\varphi\end{bmatrix}\); reflection through the \(x\)-axis \(\begin{bmatrix}1&0\\0&-1\end{bmatrix}\); reflection through the \(y\)-axis \(\begin{bmatrix}-1&0\\0&1\end{bmatrix}\); scaling \(x\) by \(s\) and \(y\) by \(t\): \(\begin{bmatrix}s&0\\0&t\end{bmatrix}\).
- \(\cos 30^\circ=\sin 60^\circ=\sqrt3/2\), \(\ \sin30^\circ=\cos60^\circ=1/2\), \(\ \cos45^\circ=\sin45^\circ=\sqrt2/2\), \(\ \cos90^\circ=0\), \(\ \sin90^\circ=1\).
2.1 Points, data matrices and transformations
A graphical image on a screen (for example a wire-frame model of an airplane, or a letter) consists of a number of points, the lines that connect them, and information about how to fill the regions between the lines. Curved lines are usually approximated by short straight segments, so a figure is defined mathematically by a list of points.
The data matrix \(D\) of a figure in \(\mathbb R^2\) is the \(2\times k\) matrix whose columns are the coordinates of the \(k\) vertices of the figure. (Which vertices are joined by lines is recorded separately.)
Graphical objects are described by straight-line segments because the standard transformations of computer graphics map line segments onto line segments (a linear transformation maps the segment from \(\mathbf u\) to \(\mathbf v\) onto the segment from \(A\mathbf u\) to \(A\mathbf v\)). So once the vertices have been transformed, their images can be joined by the same lines to produce the complete image of the object.
The capital letter N in Figure 2 is determined by eight vertices, joined in the order \(1,2,\dots,8,1\). Its data matrix is
\[D=\begin{bmatrix}0&.5&.5&6&6&5.5&5.5&0\\0&0&6.42&0&8&8&1.58&8\end{bmatrix}.\]Solution
2.2 Homogeneous coordinates
Moving a figure by a fixed vector, \((x,y)\mapsto(x+h,y+k)\), is called a translation. A translation is not a linear transformation (it does not send \(\mathbf 0\) to \(\mathbf 0\)), so it cannot be written as \(\mathbf x\mapsto A\mathbf x\) with a \(2\times2\) matrix. The standard way around this problem is to add one coordinate.
Each point \((x,y)\) in \(\mathbb R^2\) is identified with the point \((x,y,1)\) in \(\mathbb R^3\), on the plane one unit above the \(xy\)-plane. We say that \((x,y)\) has homogeneous coordinates \((x,y,1)\). For example, \((0,0)\) has homogeneous coordinates \((0,0,1)\).
Homogeneous coordinates of points are not added or multiplied by scalars, but they can be transformed by multiplication with \(3\times3\) matrices.
A translation \((x,y)\mapsto(x+h,y+k)\) is written in homogeneous coordinates as \((x,y,1)\mapsto(x+h,y+k,1)\). This is a matrix multiplication:
\[\begin{bmatrix}1&0&h\\0&1&k\\0&0&1\end{bmatrix}\begin{bmatrix}x\\y\\1\end{bmatrix}=\begin{bmatrix}x+h\\y+k\\1\end{bmatrix}.\]The third coordinate is what makes this work: the constants \(h\) and \(k\) enter through the third column, multiplied by the 1. Figure 4 shows a triangle translated by \((4,3)\).
Any linear transformation \(\mathbf x\mapsto A\mathbf x\) of \(\mathbb R^2\) is represented in homogeneous coordinates by the partitioned matrix \(\begin{bmatrix}A&\mathbf 0\\ \mathbf 0^T&1\end{bmatrix}\): the \(2\times2\) block \(A\) acts on \((x,y)\) and the third coordinate stays 1. Typical examples are
\[\begin{bmatrix}\cos\varphi&-\sin\varphi&0\\ \sin\varphi&\cos\varphi&0\\0&0&1\end{bmatrix},\qquad \begin{bmatrix}0&1&0\\1&0&0\\0&0&1\end{bmatrix},\qquad \begin{bmatrix}s&0&0\\0&t&0\\0&0&1\end{bmatrix},\]which are, in order: counterclockwise rotation about the origin through the angle \(\varphi\); reflection through the line \(y=x\); scaling \(x\) by \(s\) and \(y\) by \(t\). In this way every basic 2D transformation is a \(3\times3\) matrix, so any sequence of them is a product of \(3\times3\) matrices.
2.3 Composite transformations
Moving a figure on a screen often requires two or more basic transformations. With homogeneous coordinates the composition corresponds to matrix multiplication, and the matrices are written from right to left: the first transformation applied is the rightmost factor. For instance, "scale by \(.3\), then rotate \(90^\circ\), then translate by \((-.5,2)\)" is the product
\[\begin{bmatrix}1&0&-.5\\0&1&2\\0&0&1\end{bmatrix}\begin{bmatrix}0&-1&0\\1&0&0\\0&0&1\end{bmatrix}\begin{bmatrix}.3&0&0\\0&.3&0\\0&0&1\end{bmatrix}=\begin{bmatrix}0&-.3&-.5\\.3&0&2\\0&0&1\end{bmatrix},\]with the scaling matrix on the right because it acts first.
The first transformation you apply is the rightmost matrix in the product. "Translate, then rotate" is \(R\,T\), not \(T\,R\), and the two products are different in general: rotating first and then translating moves the figure to a different place.
Rotation of a figure about a point \(\mathbf p\) in \(\mathbb R^2\) is done in three steps (Figure 5): translate the figure by \(-\mathbf p\) so that \(\mathbf p\) moves to the origin, rotate about the origin, and translate back by \(\mathbf p\). The same idea works for reflection through a line that does not pass through the origin, or scaling about a point. Construct the \(3\times3\) matrix that rotates points through \(-30^\circ\) about the point \((-2,6)\), using homogeneous coordinates.
Solution
Here \(\mathbf p=(-2,6)\), \(\cos(-30^\circ)=\sqrt3/2\) and \(\sin(-30^\circ)=-1/2\). The three matrices, written right to left in the order they are applied, are
\[\underbrace{\begin{bmatrix}1&0&-2\\0&1&6\\0&0&1\end{bmatrix}}_{\text{translate back by }\mathbf p}\ \underbrace{\begin{bmatrix}\sqrt3/2&1/2&0\\-1/2&\sqrt3/2&0\\0&0&1\end{bmatrix}}_{\text{rotate about the origin}}\ \underbrace{\begin{bmatrix}1&0&2\\0&1&-6\\0&0&1\end{bmatrix}}_{\text{translate by }-\mathbf p}.\]Multiply the two right factors first (this replaces the third column of the rotation matrix by the rotated vector \(-\mathbf p\)):
\[\begin{bmatrix}\sqrt3/2&1/2&0\\-1/2&\sqrt3/2&0\\0&0&1\end{bmatrix}\begin{bmatrix}1&0&2\\0&1&-6\\0&0&1\end{bmatrix} =\begin{bmatrix}\sqrt3/2&1/2&\sqrt3-3\\-1/2&\sqrt3/2&-1-3\sqrt3\\0&0&1\end{bmatrix}.\]Then the left factor adds \(\mathbf p\) to the third column:
\[\begin{bmatrix}1&0&-2\\0&1&6\\0&0&1\end{bmatrix}\begin{bmatrix}\sqrt3/2&1/2&\sqrt3-3\\-1/2&\sqrt3/2&-1-3\sqrt3\\0&0&1\end{bmatrix} =\begin{bmatrix}\sqrt3/2&1/2&\sqrt3-5\\-1/2&\sqrt3/2&5-3\sqrt3\\0&0&1\end{bmatrix}.\]Check: the center \(\mathbf p\) must not move. The matrix sends \((-2,6,1)\) to \(\big(-\sqrt3+3+\sqrt3-5,\ 1+3\sqrt3+5-3\sqrt3,\ 1\big)=(-2,\ 6,\ 1)\).
Self-check only. In (a) your matrix is checked by applying it to several points.
2.4 Homogeneous coordinates in \(\mathbb R^3\)
By analogy with the 2D case, \((x,y,z,1)\) are homogeneous coordinates for the point \((x,y,z)\) in \(\mathbb R^3\). Transformations of \(\mathbb R^3\), including translations, are then \(4\times4\) matrices. A linear transformation with \(3\times3\) standard matrix \(A\) becomes \(\begin{bmatrix}A&\mathbf 0\\ \mathbf 0^T&1\end{bmatrix}\), and a translation by \(\mathbf p=(h,k,l)\) has \(\mathbf p\) in the last column. For example, rotation about the \(z\)-axis through the angle \(\varphi\) (which acts on \(x\) and \(y\) like the 2D rotation and leaves \(z\) alone) and translation by \((-6,4,5)\) are
\[\begin{bmatrix}\cos\varphi&-\sin\varphi&0&0\\ \sin\varphi&\cos\varphi&0&0\\0&0&1&0\\0&0&0&1\end{bmatrix},\qquad \begin{bmatrix}1&0&0&-6\\0&1&0&4\\0&0&1&5\\0&0&0&1\end{bmatrix}.\]For the perspective projection below we also need the general form of the definition.
\((X,Y,Z,H)\) are homogeneous coordinates for the point \((x,y,z)\) if \(H\neq0\) and
\[x=\frac XH,\qquad y=\frac YH,\qquad z=\frac ZH. \tag{1}\]Each nonzero scalar multiple of \((x,y,z,1)\) gives a set of homogeneous coordinates for \((x,y,z)\). For instance, both \((10,-6,14,2)\) and \((-15,9,-21,-3)\) are homogeneous coordinates for \((5,-3,7)\).
2.5 Perspective projections
A three-dimensional object is shown on a two-dimensional screen by projecting it onto a viewing plane. Let the \(xy\)-plane represent the screen, and imagine the eye of the viewer on the positive \(z\)-axis, at the point \((0,0,d)\). A perspective projection maps each point \((x,y,z)\) onto an image point \((x^*,y^*,0)\) so that the point, its image and the eye position (the center of projection) lie on one line.
In Figure 6 the small triangle (height \(d-z\), base \(x\)) and the large triangle (height \(d\), base \(x^*\)) are similar, so
\[\frac{x^*}{d}=\frac{x}{d-z}\qquad\text{and}\qquad x^*=\frac{dx}{d-z}=\frac{x}{1-z/d}.\]The same argument in the \(yz\)-plane gives \(y^*=\dfrac{y}{1-z/d}\).
The division by \(1-z/d\) is not a linear operation, but homogeneous coordinates handle it. We want \((x,y,z,1)\) to map to \(\left(\dfrac{x}{1-z/d},\ \dfrac{y}{1-z/d},\ 0,\ 1\right)\). Scaling these coordinates by \(1-z/d\) gives another set of homogeneous coordinates for the same image point: \((x,\ y,\ 0,\ 1-z/d)\). This one is a linear function of \((x,y,z,1)\), so the projection is a matrix:
\[P\begin{bmatrix}x\\y\\z\\1\end{bmatrix}=\begin{bmatrix}1&0&0&0\\0&1&0&0\\0&0&0&0\\0&0&-1/d&1\end{bmatrix}\begin{bmatrix}x\\y\\z\\1\end{bmatrix}=\begin{bmatrix}x\\y\\0\\1-z/d\end{bmatrix}.\]To project a figure, multiply \(P\) by its data matrix in homogeneous coordinates, then divide the first three entries of each column by the fourth entry (equation (1)) to read off the points on the screen. Points closer to the eye (larger \(z\)) are pushed farther from the center of the screen; this is the perspective effect.
Self-check only. Your image points in (c) are checked directly from the formula.