Important Example Solved Problems - Engineering Maths or Mathematics - Linear Algebra: Matrix Decomposition
LEAST
SQUARE SOLUTIONS
WORKED EXAMPLES
Example 1
Find the least squares solutions of Ax=b where
what quantity is being minimized?
Solution:
1. Compute ATA
and ATb

2. Form the augmented
matrix
ATAx = ATb and row
reduce

3. Method of solution
Now
let us consider the above matrix form is in the form
AX=B (Here A = ATA)

Let
us apply Gauss elimination method to find the solution for x and y.

(ie)
[A, B] should be converted as upper triangular matrix.
By
using the back substitution method, we have
5x+3y=0
6y=30
y=30/6
y=
5
Hence
5x=−3y
x=−3/5
5x=−15
x=−3
The solution for x and y is 
The only least squares solution is x = 
This
solution minimizes the distance from Ax to b.
(ie)
The sum of squares of the entries b−Ax.

The minimizing quantity is √6.
Example 2
Find the least squares
solutions of Ax = b where
.
Solution:
1. Compute ATA
and ATb

2. Form the augmented
matrix
ATAx = ATb

3. Method of solution
Now
let us consider, the above matrix form in the form of
AX= B (Here A=ATA)
where

Let
us apply Gauss−elimination method for the solution of x and y.
(Convert
into an upper triangular matrix)

Using
back substitution method, we have
5x−y=2
and 0x + 24y = −8
24y=−8
y=
− 8/24 = − 1/3
Hence
5x−y=2 ⇒ 5x=2+y
⇒ 5x=2−(1/3)
5x = 5/3
x = 1/3
Hence the only least squares solution is

Example 3
Find the least squares
solutions of Ax = b where 
Solution:
1. Compute ATA
and ATb

2. Form the augmented
matrix
ATAx
= ATb.

3. Method of solution
Let
AX=B (Here A = ATA).

Let
us apply Gauss−elimination method to find the solution.

By
using back substitation method, we have
3x+3y−3z=6
2y−4z=−6
0z=0
(i.e.,)
x+y−z=2
y−2z=−3
Put
z=0; then y=−3+2z=−3
Put
z=0 and y=−3 in the first equation, we get
x=2−y+z=2+3+0
x=5
Hence
x=5,y=−3
and z = 0
The least squares solutions is x = 
Example 4
Find a least squares
solutions of Ax=b for

Solution:
1. Compute ATA
and ATb.

2. Form the augmented
matrix.
ATAx = ATb

3. Method of solution
Let
AX=B (Here A = ATA).

Let
us apply Gauss elimination method to find the solution.

By
using back substitution method we have
17x+y=19
84y
= 168
y=168/84
= 2
Substitute
y = 2 in, 17x+y=19 becomes
17x=19−y
⇒ x=1
The
least squares solution is x= 
Example 5
Find the least squares
solution to
x + 2y + z = 1
3x−y=2
2x+y−z=2
x + 2y +2z=1
Solution:
This
system takes the matrix form Ax=b, where

1. Compute ATA
and ATb

2. Form the augmented
matrix
ATAx = ATb

3. Method to solution
Let
AX = B (Here A= ATA)

Let
us apply Gauss elimination method to find the solution

By
using back substitution method, we have
15x+3y+z = 12
384y+1728z = 576
2455z = −435
From
the last equation z = − 435/2455 = −0.177189.
Substitute
z = −0.177189 in the second equation
3384y = 576−1728z
y
= 1/3384 [576−1728z]
y=
882.182592 / 3384
y
= 0.260692
Now
substitute the values of y = 0.260692 and z = −0.177189 in the first equation.
(ie)
15x=12−3y−z
15x
= 11.395113
x
= 11.395113 / 15
=
0.7596742
:.
x=0.759674, y=0.260692 and z=−0.177189
Hence
the least squares solution is

Example 6
Solve the following
system of equations by using the method of least squares solution.
2x1+2x2−2x3=1
2x1+2x2−2x3=3
−2x12x2+6x3 = 2
Solution:
From
the given system of equations, we have

1. Compute ATA
and ATb

2. Form the augmented
matrix
ATAx = ATb

3. Method of solution:
Let
AX=B (Here A = ATA)
where

Let
us apply Gauss elimination method to find the solution
((ie)
Form the upper triangular matrix)

From
the above matrix, by back substitution methods
12x1 +12x2−20x3
= 4
(−32/5) x3 = −32 / 5
From
the last equation x3 = 1.
Put
x3 = 1 in the first
equation, then 12x1 +12x2 = 4+20x3
Therefore,
12x1 + 12x2 = 24
⇒ x1=1 and x2 = 1
Hence
the solution is x1 = 1, x2 = 1 and x3 = 1.
The
solution of the least squares solution is

Example 7
Solve the following
system of equations by using the method of least squares.
x3+2x4=1
x1+2x2+2x3+3x4=2
Solution:
From
the given system of equations, we have

1. Compute AT
and AAT:

2. Calculate the
inverse of AAT:
The inverse of a 2×2 matrix A =
is defined as

We
can use Cayley−Hamilton theorem to find inverse.
|AAT – λI | = 0
= 0
⇒ (5 − λ) (18 − λ) ‒ 64
= 0
90 − 5λ − 18λ + λ2 −64 = 0
λ2 − 23λ + 26 = 0
A2 − 23A + 26I = 0
(÷
by A‒1);
Then A−23I+26A‒1=0
26A−1 = [23I−A]
A−1
= 1/26 [23I−A] (where
A = AAT)

3. Calculate AT(AAT)−1;

4. Calculate the final
solution x = AT(AAT)‒1.b:

Example 8
Find the least squares
solution to the following system of equations.
x1+x2+3x3
= 1
x1+x2+3x3
= 2
Solution:
From
the given system of equation, we have

3. Method of solution
Let
AX=B [Here A = ATA]
Let
us apply Gauss elimination method to find the solution.

The
above matrix gives a single equation 2x1
+ 2x2 + 6x3 = 3.
(i.e.,)
x1+x2+2x3
= 1.5
This
single equation has an infinite number of solutions. To express the general
solution, we can introduce two free parameters, as x2 = 1 and x3
= 1.
Then
x1=1.5−x2−2x3 becomes x1
= 1.5−1−2(1)
x1=1.5−3
x=1.5
Hence
the solution is x1 = 1.5, x2=1 and x3 = 1.
The
least squares solution is 
Example 9
Find the least squares
solution for the given system of equations.
x1+x2=1
2x1=2
x2=3
Solution:
From
the given system of equation, we have

3. Method of solution
Let
AX= B. (Here A = ATA)

Let
us apply Gauss elimination method to find solution.

By
using the back substitution method, from the above matrix,
5x1+x2=5
9x2
= 15
⇒ x2
=
15/9 = 5/3
Substitution
x2 = 5/3 in 5x1
+ x2 = 5.
Then
5x1 = 5 − x2 = [5 - 5/3] = 10/3
x1 = 1/5(10/3) = 2/3
x1
= 2/3; and x2 = 5/3.
The least squares solution is 
Example 10
Find the least squares
line y = mx +c that best fits the data points (0, 6), (1, 0) and (2, 0).
Solution:
From
the above data, let us construct the value as

The
data can be marked as in the following table.

For
this type of data problems, we have to use the following normal equations.

where
N No. of the total data. (ie) N=3.
From
the above two normal equations, we have
5m+3c=0 ... (1)
3m+3c=6 ... (2)
⇒ 5m+3c=0 and ... (3)
m+c=2
... (4)
(3):
5m+3c = 0
(4)
× 5: 5m+5c = 10
(−) ‒2c = ‒10
⇒ c=5.
Put
c=5 in equation (4). Then we get m=2−c
m=2−5
m=−3.
The
values are m = −3 and c = 5.
The least squares straight line y = mx + c becomes
y = − 3x+5.
Example 11
Find the least squares
straight line for the following xy data.

Solution:
From
the above data, let us construct the following table.

For
this type of the problems, we have to use the following normal equations.

Here
N represents the total number of data.
(ie) N=5
From
the above two equation ()
30m+10c
= 65 and ..... (1)
10m+5c=24
... (2)
From
(1): 30m + 10c = 65
From
(2) × 3: 30m + 15c = 72
(−) −5c = −7
c = 7/5
From
equation (2); 10m=24−5c
⇒ 10m=24−5(7/5)
10m = 17 and hence m=17/10 = 1.7
Hence
m = 1.7 and c = 1.4
The
least squares straight line y=mx+c becomes
y=
(1.7)x+(1.4)
Note:
Now
Example 10 can also be solved by using the system of equation Ax=b. Then we
have to calculate ATA and ATb to formulate the equation ATAx=ATb,
to find the solution.
This
method is illustrated in Example 12.
Example 12
Find the least squares
line y=mx+c that best fits the data points (0, 6), (1, 0) and (2, 0).
Solution:
1. Form the system
Ax=b:
We
want to find m and c such that y=mx+c for each data point.
This
gives the system.
For
the point (0, 6): m(0) + c = 6)
For
the point (1, 0): m(1)+c=0
For
the point (2, 0): m (2)+c=0
This
can be written in matrix form as

2. Calculate ATA
and ATb:

3. Solve the normal
equations ATAx = ATb:
ATAx = ATb

Let
us apply the Gauss eliminating method to find m and c.

By
using back substitution method, we have
15m+9c=0
6c
= 30
⇒ c=
30/6 = 5.
Substitute
c=5 in 15m+9c=0 then 15m=−9c
15m=−45
⇒ = −45/15
⇒ m = −3.
m=−3 and c=5.
The
least squares regression line is y = mx + c
y = −3x+5
Linear Algebra: UNIT IV: Matrix Decomposition : Tag: : Matrix Decomposition | Linear Algebra - Least Square Solutions: Example Solved Problems
Linear Algebra
MA25C02 2nd Semester | 2025 Regulation
English Essentials II
EN25C02 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation
Tamils and Technology தமிழர்களும் தொழில்நுட்பமும்
UC25H02 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation
Linear Algebra
MA25C02 2nd Semester | 2025 Regulation
Transforms and its Applications
MA25C03 2nd Semester EEE Dept | 2025 Regulation | 2nd Semester 2025 Regulation
Applied Physics (CE) II
PH25C02 2nd Semester Civil, Agri Depts | 2025 Regulation | 2nd Semester 2025 Regulation
Applied Physics (CSIE) II
PH25C03 2nd Semester AIDS, CSE, IT, CSE(CY) Dept | 2025 Regulation | 2nd Semester 2025 Regulation
Applied Physics (EE) II
PH25C04 2nd Semester EEE Dept | 2025 Regulation | 2nd Semester 2025 Regulation
Applied Physics (ME) II
PH25C05 2nd Semester Mechanical Dept | 2025 Regulation | 2nd Semester 2025 Regulation
Applied Chemistry (CE) II
CY25C02 2nd Semester Civil Dept | 2025 Regulation | 2nd Semester 2025 Regulation
Applied Chemistry (ME) II
CY25C03 2nd Semester Mechanical Dept | 2025 Regulation | 2nd Semester 2025 Regulation
Electron Devices
EC25C01 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation
Digital Principles and Computer Organization
CS25C06 2nd Semester AIDS, CSE, IT, CSE(CY) Dept | 2025 Regulation | 2nd Semester 2025 Regulation
Basic Electrical and Electronics Engineering
EE25C01 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation
Basic Civil and Mechanical Engineering
GE25C01 2nd Semester EEE Dept | 2025 Regulation | 2nd Semester 2025 Regulation
Data Structures using CPlusPlus
CS25C05 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation
Engineering Drawing
ME25C01 EEE, Mech, Agri, EEE Depts | 2025 Regulation | 2nd Semester 2025 Regulation
Data Structures and Algorithms
CS25C04 2nd Semester EEE Dept | 2025 Regulation
Circuits and Network Analysis
EC25C02 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation
Engineering Mechanics
ME25C02 2nd Semester Mech, Civil, Agri Depts | 2025 Regulation | 2nd Semester 2025 Regulation
Object Oriented Programming (OOPs)
CS25C07 2nd Semester CSE, CSE(CY) Depts | 2025 Regulation | 2nd Semester 2025 Regulation