Solving Linear Functions
Steven Co Jr., CIE, AAE
Linear Functions
• A linear function is a function that represents a straight line on the
coordinate plane.
• It follows the form f(x) = mx + b
• m = slope of the line
• b = y-intercept of the line
• x = independent variable
• f(x) = dependent variable (can also be in the form of “y”)
Linear Functions
• Example:
• A movie streaming service charges a monthly fee of $4.50 and an
additional fee of $0.35 for every movie downloaded.
• f(x) = 0.35x + 4.50
• A t-shirt company charges a one-time fee of $50 and $7 per T-shirt to
print logos on T-shirts.
• f(x) = 7x + 50
Solving Linear Algebraic Functions
• Method of elimination
• Gauss-Jordan reduction method
• Inverse application method
• Cramer’s rule
• L-U decomposition method
Method of Elimination
• Reduces the equations to one variable, then solves the remaining
variable
Method of Elimination
• Example:
Consider the following equations:
Equation 1: 2x + 3y = 8
Equation 2: 3x + 2y = 7
Find x and y using the elimination method.
Method of Elimination
• Answer:
Equation 1: 2x + 3y = 8
Equation 2: 3x + 2y = 7
Step 1: Eliminate one variable by multiplying coefficients to each
equation to make them the same.
• To eliminate x, multiply Equation 1 by 3; then multiply Equation 2 by 2
Method of Elimination
• Answer:
Equation 1: (2x + 3y = 8)*3 = 6x + 9y = 24
Equation 2: (3x + 2y = 7)*2 = 6x + 4y = 14
Step 2: Subtract the second equation from the first.
(6x + 9y = 24) – (6x + 4y = 14)
5y = 10
y=2
Method of Elimination
• Answer:
Step 3: Substitute the solved variable to either of the two initial equations to
solve for the remaining variable.
• Substituting y to Equation 1:
2x + 3(2) = 8
2x = 8 – 6
2x = 2
x=1
The answer is (1,2).
Method of Elimination
• When there are 3 variables, we choose a variable to eliminate to
create two new equations.
• Once we create new equations, use method of elimination to solve
for one variable.
• Substitute the answers to get the remaining variable.
Method of Elimination
• Example:
Consider the following equations:
Equation 1: 4x - 2y + 3z = 1
Equation 2: x + 3y – 4z = -7
Equation 3: 3x + y + 2z = 5
Find x, y, and z using the elimination method.
Method of Elimination
• Answer:
Choose a variable to eliminate first (example, x).
Using equations 1 and 2:
4x - 2y + 3z = 1
-4x - 12y + 16z = 28
-14y + 19z = 29 (equation 4)
Method of Elimination
• Answer:
Using equations 2 and 3:
-3x - 9y + 12z = 21
3x + y + 2z = 5
-8y + 14z = 26 (equation 5)
Method of Elimination
• Answer:
Using equations 4 and 5:
112y - 152z = -232
-112y + 196z = 364
44z = 132
z=3
Method of Elimination
• Answer:
Substitute z to equation 4 to get y:
-14y – 19(3) = 29
-14y = -28
y=2
Method of Elimination
• Answer:
Substitute y and z to any of the first 3 equations to get x:
x + 3(2) – 4(3) = -7
x = -1
The answer is x = -1, y = 2, z = 3
Augmented Matrix of a Linear Function
System
• To translate a set of linear functions to an augmented matrix (its
matrix equivalent):
• Place the coefficients of each variable in a column per variable (x in the first
column, y in second column, etc.)
• Place the constant of each function on the last column.
Augmented Matrix of a Linear Function
System
• Example:
For the given two equations:
Equation 1: 3x + 4y = 7
Equation 2: 4x – 2y = 5
The augmented matrix becomes:
3 4 7
4 −2 5
Augmented Matrix of a Linear Function
System
• Example:
For the given two equations:
Equation 1: 3x + 4y = 7
Equation 2: 4x – 2y = 5
If just using the coefficients, the matrix is called the coefficient matrix.
3 4
4 −2
Row-Echelon Form
• A row-echelon form is when a matrix has 1’s down the main diagonal
from the upper left corner to the lower right corner, and zeros in
every position below the main diagonal.
• Example:
1 𝑎 𝑏
0 1 𝑑
0 0 1
Row-Echelon Form
• To obtain a row-echelon form:
• In any nonzero row, the first nonzero number is a 1. It is called a leading 1.
• Any all-zero rows are placed at the bottom on the matrix.
• Any leading 1 is below and to the right of a previous leading 1.
• Any column containing a leading 1 has zeros in all other positions in the
column.
• A strategy to get the row-echelon form of a matrix is called the
Gaussian elimination method.
Gauss Elimination Method
1. The first equation should have a leading coefficient of 1. Interchange
rows or multiply by a constant, if necessary.
2. Use row operations to obtain zeros down the first column below the first
entry of 1.
3. Use row operations to obtain a 1 in row 2, column 2.
4. Use row operations to obtain zeros down column 2, below the entry of 1.
5. Use row operations to obtain a 1 in row 3, column 3.
6. Continue this process for all rows until there is a 1 in every entry down
the main diagonal and there are only zeros below.
7. If any rows contain all zeros, place them at the bottom.
Gauss Elimination Method
• Row operations that can be done when transforming to row-echelon
form are:
• Interchange rows (switch rows with each other)
• Multiply a row by a constant
• Add the product of a row and a constant to another row (multiplying a row
first with a constant then adding it to another row)
Gauss Elimination Method
• Example:
Given the equations, solve using Gaussian elimination:
Equation 1: 2x + 3y = 6
Equation 2: x – y = ½
Transform into an augmented matrix:
2 3 6
1
1 −1
2
Gauss Elimination Method
• Answer:
Step 1: The first equation should have a leading coefficient of 1.
Interchange rows or multiply by a constant, if necessary.
Interchange row 1 and row 2 to place the 1 in the entry 1-1:
2 3 6 1
1 ; 𝑅1 𝑅2 = 1 −1
2
1 −1
2 2 3 6
Gauss Elimination Method
• Answer:
Step 2: Use row operations to obtain zeros down the first column below
the first entry of 1.
Change entry 1-2 to zero by multiplying row 1 by -2 then adding to row 2.
1 1
1 −1 ; −2𝑅1 + 𝑅2 = 𝑅2; 1 −1
2 2
2 3 6 0 5 5
Gauss Elimination Method
• Answer:
Step 3: Use row operations to obtain a 1 in row 2, column 2.
Change entry 2-2 to 1 by multiplying row 2 by 1/5.
1 1 1
1 −1 ; 𝑅2 = 𝑅2; 1 −1
2 5 2
0 5 5 0 1 1
Gauss Elimination Method
• Answer:
The second row can be interpreted as y = 1. Use this to solve for x using
the first equation.
x+1=½
x = 3/2
The answer is (3/2, 1).
Gauss Elimination Method
• Example 2:
Given the equations, solve using Gaussian elimination:
Equation 1: 2x + y = 1
Equation 2: 4x + 2y = 6
Transform into an augmented matrix:
2 1 1
4 2 6
Gauss Elimination Method
• Answer:
Step 1:
1 1 1
2 1 1
; 𝑅1 = 𝑅1; 1 2 2
4 2 6 2
4 2 6
Step 2:
1 1 1 1
1 ; −4𝑅1 + 𝑅2 = 𝑅2; 1
2 2 2 2
4 2 6 0 0 4
Gauss Elimination Method
• The second row can be interpreted as 0 = 4. Therefore, the system
has no solution.
1 1
1
2 2
0 0 4
Gauss-Jordan Reduction Method
• The Gauss-Jordan reduction method is an extension of the Gauss
elimination method.
• In this method, a reduced row-echelon form is made, wherein all the
variables above and below the leading one is converted to zero.
• The same method for the Gauss elimination is used, except we only
stop until the next row/s and column/s after the last leading one is
zero or non-existent.
Gauss-Jordan Reduction Method
• Example:
Find the solution to the set of equations using Gauss-Jordan reduction.
Equation 1: x + 2y – z=2
Equation 2: x + y – z = 0
Equation 3: 2x – y + z = 3
The augmented matrix is:
1 2 −1 2
1 1 −1 0
2 −1 1 3
Gauss-Jordan Reduction Method
• Answer:
Step 1:
R2 = R2 – R1
R3 = R3 – 2R1
1 2 −1 2
0 −1 0 −2
0 −5 3 −1
Gauss-Jordan Reduction Method
• Answer:
Step 2:
R2 = –R2
1 2 −1 2
0 1 0 2
0 −5 3 −1
Gauss-Jordan Reduction Method
• Answer:
Step 3:
R3 = R3 – 5R2
1 2 −1 2
0 1 0 2
0 0 3 9
Gauss-Jordan Reduction Method
• Answer:
Step 4:
R3 = (1/3)R3
1 2 −1 2
0 1 0 2
0 0 1 3
Gauss-Jordan Reduction Method
• Answer:
Step 5:
R1 = R1 – 2R2
1 0 −1 −2
0 1 0 2
0 0 1 3
Gauss-Jordan Reduction Method
• Answer:
Step 6:
R1 = R1 + R3
1 0 0 1
0 1 0 2
0 0 1 3
Gauss-Jordan Reduction Method
• Answer:
To interpret, row 1 is x = 1, row 2 is y = 2, and row 3 is z = 3.
1 0 0 1
0 1 0 2
0 0 1 3
Gauss-Jordan Reduction Method
• If during the method, a column cannot be reduced further and it does
not have a leading one, it is called a free variable.
Gauss-Jordan Reduction Method
• Example:
Find the solution to the set of equations using Gauss-Jordan reduction.
Equation 1: x + y – z – w = 2
Equation 2: x – y – z + w = 4
Equation 3: 2x + y – z + w = 1
The augmented matrix is:
1 1 −1 −1 2
1 −1 −1 1 4
2 1 −1 1 1
Gauss-Jordan Reduction Method
• Answer:
Step 1:
R2 = R2 – R1
R3 = R3 – 2R1
1 1 −1 −1 2
0 −2 0 2 2
0 −1 1 3 −3
Gauss-Jordan Reduction Method
• Answer:
Step 2:
R2 = (-½)R2
1 1 −1 −1 2
0 1 0 −1 −1
0 −1 1 3 −3
Gauss-Jordan Reduction Method
• Answer:
Step 3:
R1 = R1 – R2
R3 = R3 + R2
1 0 −1 0 3
0 1 0 −1 −1
0 0 1 2 −4
Gauss-Jordan Reduction Method
• Answer:
Step 4:
R1 = R1 + R3
1 0 0 2 −1
0 1 0 −1 −1
0 0 1 2 −4
Since there are no other rows after the leading one on the third row
and all values above and below all leading ones are zero, we stop.
Gauss-Jordan Reduction Method
• Answer:
Since the column on w has no leading one, w is a free variable. Free variables
can be assigned a variable value (example, “a”).
1 0 0 2 −1
0 1 0 −1 −1
0 0 1 2 −4
w becomes w = a
x becomes x = -1 – 2a
y becomes y = -1 + a
z becomes z = -4 – 2a
Inverse Application Method
• To solve a system of linear functions using the inverse of a matrix, the
system is divided into three parts: A, X, and B.
• A is the coefficient matrix
• X is the variable matrix
• B is the constant matrix
• The solution for this method utilizes the inverse of A, and multiplying
it with B.
𝑋 = 𝐴−1 𝐵
Inverse Application Method
• Example:
Find the solution to the set of equations using Inverse application.
Equation 1: 5x + 15y + 56z = 35
Equation 2: -4x – 11y – 41z = -26
Equation 3: -x – 3y – 11z = -7
Inverse Application Method
• Answer:
Write the equation as AX=B.
5 15 56 𝑥 35
−4 −11 −41 𝑦 = −26
−1 −3 −11 𝑧 −7
Inverse Application Method
• Answer:
Get the inverse of A by augmenting it with an identity matrix, and
reducing to reduced row-echelon form.
5 15 56 1 0 0
−4 −11 −41 0 1 0
−1 −3 −11 0 0 1
Inverse Application Method
• Answer:
Iteration 1 (multiply row 1 by 1/5):
1 3 56/5 1/5 0 0
−4 −11 −41 0 1 0
−1 −3 −11 0 0 1
Inverse Application Method
• Answer:
Iteration 2 (multiply row 1 by 4 then add to row 2; add row 1 to row 3):
1 3 56/5 1/5 0 0
0 1 19/5 4/5 1 0
0 0 1/5 1/5 0 1
Inverse Application Method
• Answer:
Iteration 3 (multiply row 2 by -3 then add to row 1; multiply row 3 by
5):
1 0 −1/5 −11/5 −3 0
0 1 19/5 4/5 1 0
0 0 1 1 0 5
Inverse Application Method
• Answer:
Iteration 4 (multiply row 3 by 1/5 then add to row 1; multiply row 3 by
-19/5 then add to row 2):
1 0 0 −2 −3 1
0 1 0 −3 1 −19
0 0 1 1 0 5
Inverse Application Method
• Answer:
Based on the last iteration:
−2 −3 1
𝐴−1 = −3 1 −19
1 0 5
Inverse Application Method
• Answer:
Multiply the inverse of A with B to get the answer.
−2 −3 1 35 1
𝐴−1 𝐵 = −3 1 −19 −26 = 2
1 0 5 −7 0
Therefore, the solution is:
X = 1, Y = 2, Z = 0
Cramer’s Rule
• Cramer’s Rule, coined after Gabriel Cramer, is a method of solving for
linear functions using the determinants of its equivalent matrix.
• This is only applicable if the number of linear functions in the system
is the same as the number of variables in each function.
• If x and y are missing, there must be two functions in the system.
• If x, y, and z are missing, there must be three functions in the system.
• The set of equations is still written as with others:
𝑎1 𝑥 + 𝑏1 𝑦 + 𝑐1 𝑧 = 𝑑1
𝑎2 𝑥 + 𝑏2 𝑦 + 𝑐2 𝑧 = 𝑑2
𝑎3 𝑥 + 𝑏3 𝑦 + 𝑐3 𝑧 = 𝑑3
Cramer’s Rule
• For a system with two unknowns (x and y), the formula is taken as:
𝑐1 𝑏1
𝐷𝑥 𝑐2 𝑏2
𝑥= = ,𝐷 ≠ 0
𝐷 𝑎1 𝑏1
𝑎2 𝑏2
𝑎1 𝑐1
𝐷𝑦 𝑎2 𝑐2
𝑦= = ,𝐷 ≠ 0
𝐷 𝑎1 𝑏1
𝑎2 𝑏2
Cramer’s Rule
• For a system with three unknowns (x, y, and z), the formula is taken as:
𝑑1 𝑏1 𝑐1 𝑎1 𝑑1 𝑐1 𝑎1 𝑏1 𝑑1
𝑑2 𝑏2 𝑐2 𝑎2 𝑑2 𝑐2 𝑎2 𝑏2 𝑑2
𝐷𝑥 𝑑3 𝑏3 𝑐3 𝐷𝑦 𝑎3 𝑑3 𝑐3 𝐷𝑧 𝑎3 𝑏3 𝑑3
𝑥= = ; 𝑦= = ;𝑧 = =
𝐷 𝑎1 𝑏1 𝑐1 𝐷 𝑎1 𝑏1 𝑐1 𝐷 𝑎1 𝑏1 𝑐1
𝑎2 𝑏2 𝑐2 𝑎2 𝑏2 𝑐2 𝑎2 𝑏2 𝑐2
𝑎3 𝑏3 𝑐3 𝑎3 𝑏3 𝑐3 𝑎3 𝑏3 𝑐3
L-U Decomposition Method
• The L-U Decomposition Method of a matrix is the factorization of a
given square matrix into two triangular matrices, one upper triangular
matrix and one lower triangular matrix, such that the product of
these two matrices gives the original matrix.
L-U Decomposition Method
• Steps:
1. Write the system as AX=B (same as the inverse application method)
2. Reduce matrix A to its lower-triangular matrix (defined as L) and its upper-
triangular matrix (defined as U):
1 0 0
𝐿 = 𝑙21 1 0
𝑙31 𝑙32 1
𝑢11 𝑢12 𝑢13
𝑈= 0 𝑢22 𝑢23
0 0 𝑢33
L-U Decomposition Method
• Steps:
3. Digits for L are taken from the values multiplied to the main diagonal digit
above them in order to convert them to 0.
4. Once the digits corresponding to L from matrix A are reduced to 0, the
remaining matrix is matrix U.
5. Once L and U are obtained, compute for matrix Z using the formula:
𝐿𝑍 = 𝐵
6. Once Z is obtained, solve for X using:
𝑈𝑋 = 𝑍
L-U Decomposition Method
• Example:
Solve for the following using L-U Decomposition method:
Equation 1: 5x + 15y + 56z = 35
Equation 2: -4x – 11y – 41z = -26
Equation 3: -x – 3y – 11z = -7
L-U Decomposition Method
• Answer:
Write the equation as AX=B.
5 15 56 𝑥 35
−4 −11 −41 𝑦 = −26
−1 −3 −11 𝑧 −7
L-U Decomposition Method
• Answer:
Find L and U.
5 15 56
−4 −11 −41
−1 −3 −11
Matrix L will be:
1 0 0
𝐿 = 𝑙21 1 0
𝑙31 𝑙32 1
L-U Decomposition Method
• Answer:
Iteration 1: Reduce A21 to 0 (multiply -4/5 to row 1 and subtract from
row 2).
5 15 56
0 1 19/5
−1 −3 −11
L21 will be -4/5.
1 0 0
𝐿 = −4/5 1 0
𝑙31 𝑙32 1
L-U Decomposition Method
• Answer:
Iteration 2: Reduce A31 to 0 (multiply -1/5 to row 1 and subtract from row
3).
5 15 56
0 1 19/5
0 0 1/5
L31 will be -1/5.
1 0 0
𝐿 = −4/5 1 0
−1/5 𝑙32 1
L-U Decomposition Method
• Answer:
Iteration 3: Reduce A32 to 0 (since A32 is 0 already, no need to multiply).
5 15 56
0 1 19/5
0 0 1/5
L32 will be 0.
1 0 0
𝐿 = −4/5 1 0
−1/5 0 1
L-U Decomposition Method
• Answer:
Since all L values are obtained, the resulting matrix is matrix U.
5 15 56
𝑈 = 0 1 19/5
0 0 1/5
1 0 0
𝐿 = −4/5 1 0
−1/5 0 1
L-U Decomposition Method
• Answer:
Get Z using LZ=B.
1 0 0 𝑧1 35
−4/5 1 0 𝑧2 = −26
−1/5 0 1 𝑧3 −7
Z1 = 35
(-4/5)Z1 + Z2 = -26; Z2 = 2
(-1/5)Z1 + Z3 = -7; Z3 = 0
L-U Decomposition Method
• Answer:
Get X using UX=Z.
5 15 56 𝑥 35
0 1 19/5 𝑦 = 2
0 0 1/5 𝑧 0
5x + 15y + 56z = 35; x = 1
y + 19/5z = 2; y = 2
1/5z = 0; z = 0
Thank you!