Ee4 Mod3
Ee4 Mod3
Ee4 Mod3
College: Engineering
Campus: Bambang
1. Direct Methods
1.1 Gauss elimination method
1.2 Gauss-Jordan method
1.3 Inverse of a matrix by Gauss-Jordan
1.4 Least-Squares regression
1.4.1 Linear Regression
1.4.2 Polynomial Regression
2. Iterative Methods
2.1 Gauss-Jacobi Iteration Method
2.2 Gauss-Seidel Iteration Method
3. Eigen Value Problems
3.1 Eigen Value and Eigen Vectors
3.2 Power Method
V. LESSON CONTENT
Introduction
In this chapter we present the solution of n linear simultaneous algebraic equations in n unknowns.
Linear systems of equations are associated with many problems in engineering and science, as well as
with applications of mathematics to the social sciences and quantitative study of business and economic
problems. A system of algebraic equations has the form
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 1 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
(2.1)
where the coefficients aij and the constants bj are known and xi represents the unknowns. (Dukkipati,
2010)
where:
aij, i = 1, 2, ..., n, j = 1, 2, …, n, are the known coefficients,
bj , j = 1, 2, …, n, are the known right hand side values and
xi, i = 1, 2, …, n are the unknowns to be determined.
(2.1a)
where:
The matrix [A | b], obtained by appending the column b to the matrix A is called the augmented matrix.
(S.R.K. Iyengar, 2009)
Augmented Matrix
Then we have
and
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 2 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
A system of linear equations in n unknowns has a unique solution, provided that the determinant
of the coefficient matrix is non-singular i.e., if |A| ≠ 0. The rows and columns of a non-singular matrix are
linearly independent in the sense that no row (or column) is a linear combination of the other rows (or
columns): (Dukkipati, 2010)
If the coefficient matrix is singular, the equations may have infinite number of solutions, or no
solutions at all, depending on the constant vector.
Linear algebraic equations occur in almost all branches of engineering. Their most important
application in engineering is in the analysis of linear systems (any system whose response is proportional
to the input is deemed to be linear). Linear systems include structures, elastic solids, heat flow, seepage
of fluids, electromagnetic fields and electric circuits i.e., most topics taught in an engineering curriculum.
If the system is discrete, such as a truss or an electric circuit, then its analysis leads directly to linear
algebraic equations.
Summarizing, the modelling of linear systems invariably gives rise to equations of the form Ax =
b, where b is the input and x represents the response of the system. The coefficient matrix A, which
reflects the characteristics of the system, is independent of the input. In other words, if the input is
changed, the equations have to be solved again with a different b, but the same A. Hence, it is desirable
to have an equation solving algorithm that can handle any number of constant vectors with minimal
computational effort. (Dukkipati, 2010)
Methods of Solution (Dukkipati, 2010)
There are two classes of methods for solving system of linear, algebraic equations: direct and
iterative methods. The common characteristics of direct methods are that they transform the original
equation into equivalent equations (equations that have the same solution) that can be solved more
easily. The transformation is carried out by applying certain operations.
The solution does not contain any truncation errors but the round off errors is introduced due to
floating point operations.
Iterative or indirect methods, start with a guess of the solution x, and then repeatedly refine the
solution until a certain convergence criterion is reached. Iterative methods are generally less efficient
than direct methods due to the large number of operations or iterations required.
Iterative procedures are self-correcting, meaning that round off errors (or even arithmetic
mistakes) in one iteration cycle are corrected in subsequent cycles. The solution contains truncation error.
A serious drawback of iterative methods is that they do not always converge to the solution. The initial
guess affects only the number of iterations that are required for convergence. The indirect solution
technique (iterative) is more useful to solve a set of ill-conditioned equations.
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 3 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
1. Direct Methods
Direct methods produce the exact solution after a finite number of steps (disregarding the round-
off errors). In these methods, we can determine the total number of operations (additions,
subtractions, divisions and multiplications). This number is called the operational count of the method.
If the system of equations has some special forms, then the solution is obtained directly. We
consider two such special forms.
(a) Let A be a diagonal matrix, A = D. That is, we consider the system of equations
Dx = b as
(1.34)
(1.35)
(b) Let A be an upper triangular matrix, A = U. That is, we consider the system of equations
Ux = b as
(1.36)
This system is called an upper triangular system of equations. Solving for the unknowns
in the order xn, xn–1, ..., x1, we get
(1.37)
The unknowns are obtained by back substitution and this procedure is called the back
substitution method.
Therefore, when the given system of equations is one of the above two forms, the solution
is obtained directly.
Before we derive some direct methods, we define elementary row operations that can be
performed on the rows of a matrix.
Elementary row transformations (operations) The following operations on the rows of a matrix
A are called the elementary row transformations (operations).
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 4 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
(i) Interchange of any two rows. If we interchange the ith row with the jth row, then we
usually denote the operation as Ri ↔ Rj.
(ii) Division/multiplication of any row by a non-zero number p. If the ith row is multiplied by
p, then we usually denote this operation as pRi.
(iii) Adding/subtracting a scalar multiple of any row to any other row. If all the elements of
the jth row are multiplied by a scalar p and added to the corresponding elements of the ith row,
then, we usually denote this operation as Ri ← Ri + pRj. Note the order in which the operation Ri
+ pRj is written. The elements of the jth row remain unchanged and the elements of the ith row
get changed.
These row operations change the form of A, but do not change the row-rank of A. The
matrix B obtained after the elementary row operations is said to be row equivalent with A. In the
context of the solution of the system of algebraic equations, the solution of the new system is
identical with the solution of the original system.
The above elementary operations performed on the columns of A (column C in place of
row R) are called elementary column transformations (operations). However, we shall be using
only the elementary row operations.
In this section, we derive two direct methods for the solution of the given system of
equations, namely, Gauss elimination method and Gauss-Jordan method.
1.1. Gauss Elimination Method
The method is based on the idea of reducing the given system of equations Ax =
b, to an upper triangular system of equations Ux = z, using elementary row operations.
We know that these two systems are equivalent. That is, the solutions of both the systems
are identical. This reduced system Ux = z, is then solved by the back substitution method
to obtain the solution vector x. (S.R.K. Iyengar, 2009)
Two linear systems Ax = b and A'x = b' of equations are said to be equivalent if
any solution of one is a solution of the other. Also, let Ax = b is a linear non-homogeneous
system of n equations. Suppose we subject this system to the system of following
operations: (Dukkipati, 2010)
1. Multiplication of one equation by a non-zero constant.
2. Addition of a multiple of one equation to another equation.
3. Interchange of two equations.
If the sequence of operations produce the new system A′x = b′, then both the
systems Ax = b and A′x = b' are equivalent. In particular, then A is invertible if A′ is
invertible. In Gauss elimination method, we adopt this and the elimination process is based
on this theorem.
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 5 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
In Gauss elimination method, the unknowns are eliminated such that the
elimination process leads to an upper triangular system and the unknowns are obtained
by back substitution. It is assumed a11 ≠ 0.
Equation (2.15) is called the pivotal equation and the coefficient a11 is the pivot.
Step 2: Eliminate x2 from the Eq. (2.17) using Eq. (2.16) by assuming a'22 ≠ 0. We perform
the following operation:
Step 3: To find x1, x2 and x3, we apply back substitution starting from Eq. (2.20) giving x3,
then x2 from Eq. (2.19) and x1 from Eq. (2.18).
Pivoting:
Gauss elimination method fails if any one of the pivots in the above equations (2.12) to
(2.20) becomes zero. To overcome this difficulty, the equations are to be rewritten in a
slightly different order such that the pivots are not zero.
Step 2: The numerically largest coefficient of x2 is selected from all the remaining
equations as pivot and the corresponding equation becomes the second equation (2.16).
This process is repeated till an equation into a simple variable is obtained.
Gauss Elimination Method according to Iyengar and Jain: (S.R.K. Iyengar, 2009)
First stage of elimination
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 6 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
We assume a11 ≠ 0. This element a11 in the 1 × 1 position is called the first pivot.
We use this pivot to reduce all the elements below this pivot in the first column as zeros.
Multiply the first row in (1.39) by a21/a11 and a31/a11 respectively and subtract from the
second and third rows. That is, we are performing the elementary row operations R2 –
(a21/a11)R1 and R3 –(a31/a11)R1 respectively. We obtain the new augmented matrix as
(1.40)
where
( ) ( )
We assume a ≠ 0. This element a in the 2 x 2 position is called the second
pivot. We use this pivot to reduce the element below this pivot in the second column as
( ) ( )
zero. Multiply the second row in (1.40) by a / a and subtract from the third row. That
( ) ( )
is, we are performing the elementary row operation R3 – (a / a ) R2. We obtain the new
augmented matrix as
(1.41)
where
( )
The element a ≠ 0 is called the third pivot. This system is in the required upper
triangular for [U | z]. The solution vector x is now obtained by back substitution.
In general, using a pivot, all the elements below that pivot in that column are made zeros.
When does the Gauss elimination method as described above fail? (S.R.K. Iyengar, 2009)
It fails when any one of the pivots is zero or it is a very small number, as the
elimination progresses. If a pivot is zero, then division by it gives over flow error, since
division by zero is not defined. If a pivot is a very small number, then division by it
introduces large round-off errors and the solution may contain large errors.
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 7 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
Remark/s:
Example:
1. Solve the system of equations
x1 + 10x2 – x3 = 3
2x1 + 3x2 + 20x3 = 7
10x1 – x2 + 2x3 = 4
Using the Gauss elimination with partial pivoting. (S.R.K. Iyengar, 2009)
Solution:
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 8 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
Solution:
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 9 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
Solution:
Let us solve this problem by making the pivots as 1. The augmented matrix is given by:
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 10 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
Solution:
We have augmented matrix as
Now, rank [A] = 2, and rank [A|b] = 3. Therefore, the system is inconsistent and has no
solution.
5. Solve the following equations by Gauss elimination method: (not using Augmented
Matrix) (Dukkipati, 2010)
2x + 4y – 6z = –4
x + 5y + 3z = 10
x + 3y + 2z = 5
Solution:
2x + 4y – 6z = – 4 (E.1)
x + 5y + 3z = 10 (E.2)
x + 3y + 2z = 5 (E.3)
2x + 4y – 6z = –4
–2x – 10y – 6z = –20
–2x – 6y – 4z = –10
2x + 4y – 6z = –4
Row 1 + Row 2: – 6y – 12z = –24 (E.6)
Row 1 + Row 3: 2y – 10z = –14 1 × (–3) (E.5)
2x + 4y – 6z = –4
–6y – 12z = –24
Row 2 + Row 3: 18z = 18 ⇒z=1
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 11 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
2x + 4y – 6z = –4
2x = –4 – 4y + 6z ⇒x= ⇒ x = -3
According to Iyengar and Jain, the method is based on the idea of reducing the given
system of equations Ax = b, to a diagonal system of equations Ix = d, where I is the identity
matrix, using elementary row operations. We know that the solutions of both the systems are
identical. This reduced system gives the solution vector x. This reduction is equivalent to
finding the solution as x = A–1b.
In this case, after the eliminations are completed, we obtain the augmented matrix for
a 3 × 3 system as (S.R.K. Iyengar, 2009)
(1.42)
Elimination procedure. The first step is same as in Gauss elimination method, that is, we
make the elements below the first pivot as zeros, using the elementary row transformations.
From the second step onwards, we make the elements below and above the pivots as zeros
using the elementary row transformations. Lastly, we divide each row by its pivot so that the
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 12 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
final augmented matrix is of the form (1.42). Partial pivoting can also be used in the solution.
We may also make the pivots as 1 before performing the elimination. (S.R.K. Iyengar, 2009)
Example:
1) Solve the following system of equations
x1 + x2 + x3 = 1
4x1 + 3x2 – x3 = 6
3x1 + 5x2 + 3x3 = 4
using the Gauss-Jordan method (i) without partial pivoting, (ii) with partial pivoting.
(S.R.K. Iyengar, 2009)
Solution:
We have the augmented matrix as
(i) We perform the following elementary row transformations and do the eliminations
(ii) We perform the following elementary row transformations and do the elimination.
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 13 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
Remark/s: The Gauss-Jordan method looks very elegant as the solution is obtained
directly. However, it is computationally more expensive than Gauss elimination. For large
n, the total number of divisions and multiplications for Gauss-Jordan method is almost 1.5
times the total number of divisions and multiplications required for Gauss elimination.
Hence, we do not normally use this method for the solution of the system of equations.
The most important application of this method is to find the inverse of a non-singular
matrix. We present this method in the following section. (S.R.K. Iyengar, 2009)
2) Solve the following system of equations using the Gauss-Jordan method. (Dukkipati,
2010)
x – 2y = –4
5y + z = –9
4x – 3z = –10
Solution:
The augmented matrix is
Multiplying 1st row by –4 and adding the result to the 3rd row, we obtain
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 14 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
Multiply the 2nd row and add the result to the 1st row. Then multiply the 2nd row by
–8 and add the result to the 3rd row.
Multiply 3rd row by 2/5 and add the result to 1st row. Then multiply 3rd row by 1/5 and
add the result to 2nd row.
Hence, the last matrix above represents the system with x = 2, y = 3 and z = 6.
3) Solve the following set of equations by Gauss-Jordan method. (Dukkipati, 2010)
2x1 + x2 – 3x3 = 11
4x1 – 2x2 + 3x3 = 8
–2x1 + 2x2 – x3 = –6
Solution:
The augmented matrix for the given set of equations is
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 15 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
The important application of the Gauss-Jordan method is to find the inverse of a non-
singular matrix A. We start with the augmented matrix of A with the identity matrix I of the
same order. When the Gauss-Jordan procedure is completed, we obtain
since, AA–1 = I.
Remark/s:
Partial pivoting can also be done using the augmented matrix [A|I]. However, we
cannot first interchange the rows of A and then find the inverse. Then, we would be finding
the inverse of a different matrix.
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 16 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
Example:
1) Find the inverse of the matrix
using the Gauss-Jordan method (i) without partial pivoting, and (ii) with partial
pivoting. (S.R.K. Iyengar, 2009)
Solution:
Consider the augmented matrix
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 17 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 18 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
2) Using the Gauss-Jordan method, find the inverse of (S.R.K. Iyengar, 2009)
Solution:
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 19 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
Where substantial error is associated with data, polynomial interpolation is inappropriate and may
yield unsatisfactory results when used to predict intermediate values. Experimental data is often of this
type. For example, Fig. 17.1a shows seven experimentally derived data points exhibiting significant
variability. Visual inspection of the data suggests a positive relationship between y and x. That is, the
overall trend indicates that higher values of y are associated with higher values of x. Now, if a sixth-order
interpolating polynomial is fitted to this data (Fig. 17.1b), it will pass exactly through all of the points.
However, because of the variability in the data, the curve oscillates widely in the interval between the
points. In particular, the interpolated values at x = 1.5 and x = 6.5 appear to be well beyond the range
suggested by the data.
A more appropriate strategy for such cases is to derive an approximating function that fits the
shape or general trend of the data without necessarily matching the individual points. Figure 17.1c
illustrates how a straight line can be used to generally characterize the trend of the data without passing
through any particular point.
One way to determine the line in Fig. 17.1c is to visually inspect the plotted data and then sketch
a “best” line through the points. Although such “eyeball” approaches have commonsense appeal and are
valid for “back-of-the-envelope” calculations, they are deficient because they are arbitrary. That is, unless
the points define a perfect straight line (in which case, interpolation would be appropriate), different
analysts would draw different lines.
To remove this subjectivity, some criterion must be devised to establish a basis for the fit. One
way to do this is to derive a curve that minimizes the discrepancy between the data points and the curve.
A technique for accomplishing this objective, called least-squares regression, will be discussed in this
module.
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 20 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
We can place the line "by eye": try to have the line as close as possible to all points,
and a similar number of points above and below the line.
But for better accuracy let's see how to calculate the line using Least Squares
Regression.
The Line
Our aim is to calculate the values m (slope) and b (y-intercept) in the equation of
a line :
y = mx + b
Where:
y = how far up
x = how far along
m = Slope or Gradient (how steep the line is)
b = the Y-Intercept (where the line crosses the Y axis)
Steps:
Step 2: Sum all x, y, x2 and xy, which gives us Σx, Σy, Σx2 and Σxy (Σ means "sum up")
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 21 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
Example:
1) Write a linear equation that “best fits” the data shown below.
x 1 2 3 4 5 6 7 8
Given:
Σx = 36
Σy = 96.86
Σ(x2)= 204
Σ(xy)= 519.63
∑( ) ∑ ∑
m= ∑( ) (∑ )
( )( . ) ( )( . )
m= ( )( ) ( )
m= 1.994285714
∑ ∑
b=
. ( . )( )
b=
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 22 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
b= 3.133214287
y = 1.994x + 3.1332
x 1 2 3 4 5
x y x2 xy
1 7.11 1 7.11
2 10.01 4 20.02
3 13.2 9 39.6
4 16.1 16 64.4
5 19.12 25 95.6
Σ= 15 65.54 55 226.73
∑( ) ∑ ∑
m= ∑( ) (∑ )
( )( . ) ( )( . )
m= ( )( ) ( )
m= 3.011
∑ ∑
b=
. ( . )( )
b=
b= 4.075
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 23 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
Some engineering data, although exhibiting a marked pattern such as seen in Fig.
17.8, is poorly represented by a straight line. For these cases, a curve would be better
suited to fit the data. As discussed in the previous section, one method to accomplish this
objective is to use transformations. Another alternative is to fit polynomials to the data
using polynomial regression. (Dukkipati, 2010)
The least-squares procedure can be readily extended to fit the data to a higher-
order polynomial. For example, suppose that we fit a second-order polynomial or
quadratic:
To find the polynomial equation, we must find the value of a0, a1, and a2. The
equations below will help you.
Example:
1) Write the polynomial equation that “best fits” the data shown below.
x 1 2 3 4 5 6 7
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 24 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
Solution:
Using the matrix form shown below, calculate the value of a0, a1, and a2.
7 28 140 𝑎 462.98
𝑎 =
28 140 784 2552.34
140 784 4676 𝑎 15115.54
7a0 + 28a1 + 140a2 = 462.98
28a0 + 140a1 + 784a2 = 2552.34
140a0 + 784a1 + 4676a2 = 15115.54
Iterative methods are based on the idea of successive approximations. We start with an initial
approximation to the solution vector x = x0, to solve the system of equations Ax = b, and obtain a
sequence of approximate vectors x0, x1, ..., xk, ..., which in the limit as k → ∞, converges to the exact
solution vector x = A–1b. A general linear iterative method for the solution of the system of equations
Ax = b, can be written in matrix form as
(1.43)
where x(k+1) and x(k) are the approximations for x at the (k + 1)th and kth iterations respectively. H
is called the iteration matrix, which depends on A and c is a column vector, which depends on A and
b.
When to stop the iteration? We stop the iteration procedure when the magnitudes of the differences
between the two successive iterates of all the variables are smaller than a given accuracy or error
tolerance or an error bound ε, that is,
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 25 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
(1.44)
For example, if we require two decimal places of accuracy, then we iterate until |𝒙𝒊 (𝒌 𝟏)
− 𝒙𝒊 (𝒌)|<
0.005 for all i. If we require three decimal places of accuracy, then we iterate until |𝒙𝒊 (𝒌 𝟏)
− 𝒙𝒊 (𝒌) |<
0.0005, for all i.
Now, we derive two iterative methods for the solution of the system of algebraic equations
(1.45)
Sometimes, the method is called Jacobi method. We assume that the pivots aii ≠ 0, for all
i. Write the equations as
(1.46)
Since, we replace the complete vector x(k) in the right hand side of (1.46) at the end of
each iteration, this method is also called the method of simultaneous displacement.
Remark 20 A sufficient condition for convergence of the Jacobi method is that the system of
equations is diagonally dominant, that is, the coefficient matrix A is diagonally dominant. We can
verify that |𝒂𝒊𝒊 | ≥ ∑𝒏𝒋 𝟏,𝒊 𝒋 |𝒂𝒊𝒋 |. This implies that convergence may be obtained even if the system
is not diagonally dominant. If the system is not diagonally dominant, we may exchange the
equations, if possible, such that the new system is diagonally dominant and convergence is
guaranteed. However, such manual verification or exchange of equations may not be possible for
large systems that we obtain in application problems. The necessary and sufficient condition for
convergence is that the spectral radius of the iteration matrix H is less than one unit, that is, ρ(H)
< 1, where ρ(H) is the largest eigen value in magnitude of H. Testing of this condition is beyond
the scope of the syllabus.
Remark 21 How do we find the initial approximations to start the iteration? If the system is
diagonally dominant, then the iteration converges for any initial solution vector. If no suitable
approximation is available, we can choose x = 0, that is xi = 0 for all i. Then, the initial
approximation becomes xi = bi /aii, for all i.
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 26 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
In mathematics, a square matrix is said to be diagonally dominant if for every row of the matrix,
the magnitude of the diagonal entry in a row is larger than or equal to the sum of the magnitudes
of all the other (non-diagonal) entries in that row. More precisely, the matrix A is diagonally
dominant if
Example:
1) Solve the system of equations
4x1 + x2 + x3 = 2
x1 + 5x2 + 2x3 = – 6
x1 + 2x2 + 3x3 = – 4
using the Jacobi iteration method. Use the initial approximations as
(i) xi = 0, i = 1, 2, 3, (ii) x1 = 0.5, x2 = – 0.5, x3 = – 0.5.
Perform five iterations in each case.
Solution:
Note that the given system is diagonally dominant. Jacobi method gives the
iterations as (review general iteration method)
x1(k+1) = 0.25 [2 – (x2(k) + x3(k))]
x2(k+1) = 0.2 [– 6 – (x1(k) + 2x3(k))]
x3(k+1) = 0.33333 [– 4 – (x1(k) + 2x2(k))], k = 0, 1, ...
First iteration:
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 27 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
Second iteration:
Third iteration:
Fourth iteration:
Fifth iteration:
It is interesting to note that the iterations oscillate and converge to the exact
solution
x1 = 1.0, x2 = – 1, x3 = – 1.0.
First iteration:
Second iteration:
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 28 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
Third iteration:
Fourth iteration:
Fifth iteration:
Solution:
The given system of equations is strongly diagonally dominant. Hence, we can
expect faster convergence. Jacobi method gives the iterations as
First iteration:
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 29 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
Second iteration:
Third iteration:
Fourth iteration:
We find
Fifth iteration:
We find
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 30 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
Since, all the errors in magnitude are less than 0.0005, the required solution is
x1 = 0.5, x2 = – 0.6, x3 = 0.4.
Remark 22 What is the disadvantage of the Gauss-Jacobi method? At any iteration step,
the value of the first variable x1 is obtained using the values of the previous iteration. The
value of the second variable x2 is also obtained using the values of the previous iteration,
even though the updated value of x1 is available. In general, at every stage in the iteration,
values of the previous iteration are used even though the updated values of the previous
variables are available. If we use the updated values of x1, x2,..., xi–1 in computing the value
of the variable xi, then we obtain a new method called Gauss-Seidel iteration method.
As pointed out in Remark 22, we use the updated values of x1, x2,..., xi–1 in computing the
value of the variable xi. We assume that the pivots aii ≠ 0, for all i. We write the equations as
(1.47)
(1.48)
Remark 23 A sufficient condition for convergence of the Gauss-Seidel method is that the system
of equations is diagonally dominant, that is, the coefficient matrix A is diagonally dominant. This
implies that convergence may be obtained even if the system is not diagonally dominant. If the
system is not diagonally dominant, we may exchange the equations, if possible, such that the
new system is diagonally dominant and convergence is guaranteed. The necessary and sufficient
condition for convergence is that the spectral radius of the iteration matrix H is less than one unit,
that is, ρ(H) < 1, where ρ(H) is the largest eigen value in magnitude of H. Testing of this condition
is beyond the scope of the syllabus.
If both the Gauss-Jacobi and Gauss-Seidel methods converge, then Gauss-Seidel method
converges at least two times faster than the Gauss-Jacobi method.
Example:
1) Find the solution of the system of equations
45x1 + 2x2 + 3x3 = 58
– 3x1 + 22x2 + 2x3 = 47
5x1 + x2 + 20x3 = 67
correct to three decimal places, using the Gauss-Seidel iteration method.
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 31 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
Solution:
The given system of equations is strongly diagonally dominant. Hence, we can expect
fast convergence. Gauss-Seidel method gives the iteration
First iteration:
Second iteration:
Third iteration:
Fourth iteration:
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 32 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
We find
Since, all the errors in magnitude are less than 0.0005, the required solution is
x1 = 1.0, x2 = 1.99999, x3 = 3.0.
Rounding to three decimal places, we get x1 = 1.0, x2 = 2.0, x3 = 3.0.
Second iteration:
Third iteration:
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 33 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
– 4x1 + x2 – x3 = – 8
3x1 – 6x2 + 2x3 = 23
x1 – 3x2 + 7x3 = 17.
The system of equations is now diagonally dominant. Gauss-Seidel method gives iteration
x1(k+1) = [8 + x2(k) – x3(k)]/4
x2(k+1) = – [23 – 3x1(k+1) – 2x3(k)]/6
x3(k+1) = [17 – x1(k+1) + 3x2(k+1)]/7.
Starting with the initial approximations x1 = 0.9, x2 = – 3.1, x3 = 0.9, we obtain the
following results.
First iteration:
Second iteration:
Third iteration:
Fourth iteration:
We find
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 34 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
Since, all the errors in magnitude are less than 0.005, the required solution is
x1 = 0.9998, x2 = – 3.0002, x3 = 0.9999.
Rounding to two decimal places, we get x1 = 1.0, x2 = – 3.0, x3 = 1.0.
The concept of eigen values and finding eigen values and eigen vectors of a given matrix
are very important for engineers and scientists.
Consider the eigen value problem
(1.49)
The eigen values of a matrix A are given by the roots of the characteristic equation.
(1.50)
If the matrix A is of order n, then expanding the determinant, we obtain the characteristic
equation as
(1.51)
For any given matrix we write the characteristic equation (1.50), expand it and find the
roots λ1, λ2,..., λn, which are the eigen values. The roots may be real, repeated or complex. Let xi
be the solution of the system of the homogeneous equations (1.49), corresponding to the eigen
value λi. These vectors xi, i = 1, 2, …, n are called the eigen vectors of the system. There are
several methods for finding the eigen values of a general matrix or a symmetric matrix. In the
syllabus, only the power method for finding the largest eigen value in magnitude of a matrix and
the corresponding eigen vector, is included.
The method for finding the largest eigen value in magnitude and the corresponding eigen
vector of the eigen value problem Ax = λ x, is called the power method.
What is the importance of this method? Let us re-look at the Remarks 20 and 23. The
necessary and sufficient condition for convergence of the Gauss-Jacobi and Gauss-Seidel
iteration methods is that the spectral radius of the iteration matrix H is less than one unit, that is,
ρ(H) < 1, where ρ(H) is the largest eigen value in magnitude of H. If we write the matrix
formulations of the methods, then we know H. We can now find the largest eigen value in
magnitude of H, which determines whether the methods converge or not.
We assume that λ1, λ2,..., λn are distinct eigen values such that
Let v1, v2,..., vn be the eigen vectors corresponding to the eigen values λ1, λ2,..., λn,
respectively. The method is applicable if a complete system of n linearly independent eigen
vectors exist, even though some of the eigen values λ2, λ3,..., λn, may not be distinct. The n
linearly independent eigen vectors form an n-dimensional vector space. Any vector v in this space
of eigen vectors v1, v2,..., vn can be written as a linear combination of these vectors. That is,
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 35 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
Premultiplying by A and substituting Av1 = λ1v1, Av2 = λ2v2,..., Avn = λnvn, we get
(1.54)
(1.55)
As k → ∞, the right hand sides of (1.54) and (1.55) tend to λ1k c1v1 and λ1k+1 c1v1, since
| λi /λ1 | < 1, i = 2, 3, …, n. Both the right hand side vectors in (1.54), (1.55)
tend to c1v1, which is the eigen vector corresponding to λ1. The eigen value λ1 is obtained as the
ratio of the corresponding components of Ak+1v and Akv. That is,
(1.56)
where the suffix r denotes the rth component of the vector. Therefore, we obtain n ratios, all of
them tending to the same value, which is the largest eigen value in magnitude, | λ1 |.
When do we stop the iteration The iterations are stopped when all the magnitudes of the
differences of the ratios are less than the given error tolerance.
(1.57)
(1.58)
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 36 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
where mk+1 is the largest element in magnitude of yk+1. Now, the largest element in magnitude of
vk+1 is one unit. Then (1.56) can be written as
(1.59)
Example:
1 2
1) Determine the dominant eigen value of A = by power method.
3 4
Solution:
Let the initial approximation to the eigen vector be v0. Then, the power method is given by
where mk+1 is the largest element in magnitude of yk+1. The dominant eigen value in
magnitude is given by
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 37 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
The magnitude of the error between the ratios is | 5.37225 – 5.37229 | = 0.00004< 0.00005.
Hence, the dominant eigen value, correct to four decimal places is 5.3722.
DIRECT METHODS
A. Solve the following system of equations by Gauss elimination method.
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 38 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
INDIRECT METHODS
A. Solve the following system of equations using the Gauss-Jacobi iteration method.
B. Solve the following system of equations using the Gauss-Seidel iteration method.
VII. ASSIGNMENT
1. When the system of algebraic equations is large, how do we conclude that it is consistent or not,
using the Gauss elimination method?
4. Define an iterative procedure for solving a system of algebraic equations Ax = b. What do we mean
by convergence of an iterative procedure?
5. How do we terminate an iterative procedure for the solution of a system of algebraic equations Ax =
b?
6. Which method, Gauss-Jacobi method or Gauss-Seidel method converges faster, for the solution of a
system of algebraic equations Ax = b ?
9. Show that the following systems of equations are inconsistent using the Gauss elimination
method.
a.) b.)
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 39 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”
Republic of the Philippines
NUEVA VIZCAYA STATE UNIVERSITY
Bayombong, Nueva Vizcaya
INSTRUCTIONAL MODULE
IM No.03:IM-MATH11-1STSEM-2020-2021
VIII. REFERENCES
Chapra, S. C., & Canale, R. P. (2010). Numerical Methods for Engineers (Sixth Edition). New York City: McGraw-Hill.
Dukkipati, R. V. (2010). Numerical Methods. New Delhi: New Age International Publisher.
MathisFun. (2017). Math is Fun Advanced. Retrieved from MathisFun.com: https://www.mathsisfun.com/data/least-
squares-regression.html
S.R.K. Iyengar, R. J. (2009). Numerical Methods. New Delhi: New Age International Publishers.
Tomar, S. (2018, January 08). Geeks for geeks. Retrieved from https://www.geeksforgeeks.org/:
https://www.geeksforgeeks.org/diagonally-dominant-matrix/
University of Pittsburgh. (n.d.). Math Pitt. Retrieved from math.pitt.edu:
http://www.math.pitt.edu/~trenchea/math1070/MATH1070_5_Rootfinding.pdf
NVSU-FR-ICD-05-00 (081220) “In accordance with Section 185, Fair use of a Copyrighted Work of Republic Page 40 of 40
Act 8293, the copyrighted works included in this material may be reproduced
for educational purposes only and not for commercial distribution.”