Math 414 Lecture 1 Homework assignments are always due at the beginning of the next lecture. Operations Research studies linear programming and associated algorithms. Businesses use it to find resource allocations and production schedules which yield maximum profit. Linear programming solves problems which can be modeled with linear equations and inequalities. Reading assignment: Text: Pages 1-29 and Scilab Users Guide: Sections 1-3. Install SciLab (or Octave ormatlab). Click SciLab on the class website www.math.hawaii.edu/414. Copy/paste the three lines of 414.txt from the webspage into a SciLab window. Select File/Change current directory. Select a directory such as My Documents. Enter: save( 414.txt ).
SCILAB NOTATION Scilab ignores capitalization: A and a are equal. For matrices A, B and real r: A+B, A-B, A/r are as expected. A*B = AB, r*a = ra. det(a) = the determinate of A. A = A T = the transpose. inv(a) = A -1 = the inverse matrix. eye(n, n) = I n = the nxn identity matrix. I 3 = [A, B] = [A B] = matrix A followed by matrix B. A(i, j) = ij th entry in A, A(i, :) = i th row, A(:, j) = j th column. [1 2 3] is the row vector 1, 2, 3 100 010 001
[3; 6; 7] is the column vector [1 2 3; 4 5 6] is the 2x3 matrix 3 6 7 123 456 How many row does [1 2 3; 4 5 6; 7 8 9] have? How many columns 123 If A = 456 789 A(2,3) =? A(2, :) =? A([2,1], :) =? In SciLab x = y doesn t mean equality, it means set x equal to y What happens to A when you enter the lines below? A(1,:)=2*A(1,:)? A(1, :)=A(1,:)-2*A(2, :)? A([1,2], :)=A([2,1], :)?
To pivot on the row 2, column 3 entry of matrix A, First load the pivot program p, by entering: load('414') Then enter: r = 2; c = 3; execstr(p) (eval(p) in Octave) `For the system of equations, The coefficient matrix =? The matrix equation =? The augmented matrix =? x column =? y column =? constant column =? r: ax + by = c s: dx + ey = f In an identity column, one entry is 1, the rest are 0. 0 1 0
DEFINITION. The tableau row operations are: v Multiply a row by a nonzero constant, v Add a multiple of one row to another row. The elementary row operations consist of the above plus v Interchange two rows. THEOREM. Applying these three row operations to the augmented matrix for a system of equations does not change the set of solutions for the system. A matrix is in tableau form if the number of independent identity columns equals the number of nonzero rows. The basic variables are those associated with the independent columns. The nonbasic variables are parameters. A subset of the variables can be made basic if its set of columns is independent. x y z x y z 014 2 000 0 103 8 tableau rref 103 8 014 2 000 0
A tableau matrix is in reduced row echelon form (rref ) if : v The 1 s of the basic variables form a decreasing line of leading nonzero entries and v Any all zero rows are at the bottom. Associated with every tableau is v A basic solution in which the parameters are zero. v A general solution writes the basic variables in terms of the parameters which are left unassigned, i.e., the parameters are arbitrary. `Suppose the variables are x, y, and z. Then the following augmented matrix is in tableau form. Rearranging the rows gives the rref form on the right. x, y the basic variables and z is nonbasic. x y z x y z 014 2 103 8 000 0 tableau rref 014 2 103 8 000 0 rref system of equations: x + 3z = 8, y + 4z = -2, 0 = 0. Basic solution: General solution: z = 0, x = 8, y = -2, z is the parameter. x = 8-3z, y = -2-4z, z is arbitrary.
To pivot on a nonzero entry in row r, column c of a matrix: Divide row r to set the entry to 1. Add/subtract multiples of row r to set the other column entries to 0. In the matrix below pivot on the r = 2; c = 1 entry. 1 3 0 (2) 4 1 2 0 1... 0 1.5 1 2.5 0 4 2 To do this in Scilab on matrix A, enter: r = 2; c = 1; execstr(p) The pivot operation produces an identity column.. TABLEAU NORMAL FORM ALGORITHM. To reduce a matrix to tableau form: Pivot on the 1 st nonzero entry in the first nonzero row. Pivot on the 1 st nonzero entry in the next nonzero row.... `Convert to tableau form. 0 1 23 0 2 4 6 8 8 8 8... 0 1 2 3 0 0 0 0 1 0 1 2
How would you do these pivots in Scilab (assuming 'P' has been loaded)? Moving the bottom row to the top and the middle row to the bottom gives the reduced row echelon form. To immediately get the rref of a matrix a, enter: rref(a) `Find the basic and general solution to 2z = -4 x + 3y + 2z = 1 x + 3y + 3z = -1 Start with the augmented matrix. Reduce it to tableau or rref form. The basic variables are those with pivot points in their columns. Write them in terms of the parameters (nonbasics). x y z x y z 0 0 2 4 1 3 2 1 1 3 3 1 augmented matrix tableau 0 0 1 2 1 3 0 5 0 0 0 0
Tableau system of equations: z = -2, x+3y = 5, 0 = 0 Basic variables: x, z. Parameter: y. Basic solution: x = 5, z = -2, y = 0. General solution: x = 5-3y, z = -2, y arb.
If the rref of an augmented matrix of a linear system were x y z The reduced 130 5 system x 3y 5 001 2 would be z 2 000 1 0 1 The last equation is impossible, thus the answer is no solutions. A is nonsingular iff det(a) = 0 iff A has an inverse. A is singular otherwise. Know the following definitions from the text or Math 311. Let v 1,..., v k be k vectors in an n-dimensional space. A linear combination of the v 1,..., v k is.... v 1,..., v k is a basis iff.... The dimension of a subspace is.... In the row-column order of a matrix, the first row s entries come first, then the second row s entries, then the third row s entries.... This is also SciLab s order.
ENTERING DATA IN SCILAB Enter: a=[1 2 3] a=[1; 2; 3] a=[0 1 2; 3 4 5; 6 7 8] a(2,2) a(2,:) a(:,2) a If you put two or more commands on the same line, separate them with ;. E.g., a(2,3)=5; a(3,2)=-1/3; r=2 To recover from errors, save a to a backup matrix z: z=a To recover a after it has been lost enter: a=z
PIVOTING First pivot on the first column using row operations. Then pivot on the second column pivot by loading and using the p program. (It has to be loaded since it is a program I wrote and is not part of Scilab.) Enter: Enter: load('414') Do this just once per session. r=2; c=2; execstr(p) a=z rref(a) a [a,eye(3,3)] rref([a,eye(3,3)]) a=[1 2 3; 3 2 1; 1 1 1] rref([a,eye(3,3)]) GETTING RATIONAL ANSWERS i.e., ½ instead of.5 Enter: a = [2.5; 6 1/3] [n,d] = rat(a) b
inv(a) is the inverse of A. The most efficient way to find inv(a) by hand involves pivoting on the augmented matrix [A I ] = [ A, eye(n, n)] to get a matrix rref([ A, eye(n, n)]) = [ I B]. If there is an all 0 row, A is singular and has no inverse. Otherwise, inv(a) = B. 1 2 3 4 `Find the inverse of a = by pivoting. [ a, eye(2)] After 1st pivot After 2nd pivot 1 2 1 0 3 4 0 1 1 2 1 0 0 2 3 1 1 0 2 1 0 1 1.5.5 The last is in rref. Thus the inverse of a is 2 1 3/2 1/2
SAVING DATA To guard against losing your work in event of a crash, periodically save your work to your disk. While in Scilab, to save your work to a file hw3, enter: save('hw3') To retrieve your work, start Scilab and enter: load('hw3') To load/save to a directory named c:\scilab enter: save('c:\scilab\hw3') load('c:\scilab\hw3') EXTRA CREDIT The first one to find an error in the lecture notes or homework gets an extra credit point. ½ point for misspellings. Note execstr(p) always works on whatever is named a. b = [1, 1; 2, 3]; r = 1; c = 1; execstr(p) won t do the desired pivot on b. If you want to do the pivot on b, copy b to a, pivot on a then copy b, a=b; r=1; c=1; execstr(p); b=a; c = a. In Octave, use eval(p) instead of execstr(p).
Let v 1,...,v k be row vectors. Let A = [v 1 ; v k ;...; v k ] be the matrix with rows v 1,...,v k. DEFINITION. rank(a) = the dimension of the subspace spanned by its rows. LEMMA. Elementary row operations on a matrix change the rows but do not change the subspace spanned by the rows. The column rank of a matrix = its row rank. COROLLARY. A and rref(a) have the same rank. COROLLARY. rank(a) = the number of nonzero rows of rref(a). THEOREM. Suppose v 1,...,v k are k vectors in an n-dimensional space and A = [v 1 ;...; v k ]. Then v 1,..., v k independent ˆ k <n v 1,..., v k span the space v 1,..., v k a basis v 1,..., v k independent v 1,..., v k span the space v 1,..., v k is a basis ˆ k> n ˆ k=n rank(a) = k rank(a) = n k = rank(a) = n