You are on page 1of 45

APPLICATIONS

OF
LINEAR ALGEBRA
Group Members
Department- Electrical
L.L Samarathunga 120566H
S.D.M Sandanayaka 120575J
M.G.A.B.N Sandanuwan 120578V
I.K.A Sandeepa 120583G
D.S Saputhanthri 120589F
M.H.M Sazni 120592H
T.M Senarath 120598G
T.S.S Senarathna 120601M
K.M.G.Y Sewwandi 120608P
L.C.J Silva 120618V
Contents
1) Applications in Graph theory
2) Application in Games
3) Balancing chemical equation with aid of Linear Algebra
4) Application to Traffic flow
5) Application in Image Processing and Transformations
6) Weighted Least-Squares-Application of inner product space
7) Application to Genetics
8) Applications to Fibonacci numbers
1. Applications in Graph theory
Graph finite set of points called Vertices {P1,P2, ,Pn}
finite set of ordered pairs called Edges

Used for problem solving in Electrical engineering, computer programming, networking, economics and
communication.
Graph representation is done in matrix form to reduce the complexity
This matrix is referred as adjacency matrix P1

1 if there exists an edge from Pi to Pj


P2
Mij =
0 otherwise P3

P4
Reducing Complexity
For a simple graph, For a directed graph,

G= G=

The problem is now converted to a numerical form hence theorems of linear algebra are
applicable.
Walks between vertices
To find the number of walks of a specified length

the number of walks between i


A= and j vertices is given by the
(i,j)th entry of the matrix A3.

The adjacency matrix

To reduce the complexity of finding A3 Diagonalization process is used


Diagonalization process
By finding a similar matrix D, to A which is diagonal, it is easy to obtain the powers of A. If there
exist a matrix P such that A = PDP-1, calculating A3 will be simply calculating PD3P-1 in which D3 is
the matrix obtained easily by taking the cube of each diagonal element of the matrix D thus making
the calculations less complicated.
Finding the isomorphic matrix
In order to decide whether two graphs are
isomorphic, its adjacency matrix can be
used.
Two isomorphic graphs If two graphs are isomorphic their adjacency
matrices are similar to each other.
Thus the rules of linear algebra will be
applicable once the problem is converted to
the numerical form.
2. Application in Games
Below figure shows some examples for how vectors are used in setting, storing
positions, directions and velocities.

In the position vector the man is standing two units east from the origin and one
unit to the north.
In the velocity vector it says that the plane moves two units west and three units
north.
The direction vector shows us that the gun is pointed to the east side
One of the most popular applications in games is vector addition in physics
integration.
Any physical object in the game will have a vector for velocity, position and
acceleration.
For every frame one has to integrate these vectors meaning adding velocity to the
position and acceleration to the velocity.
For an example lets consider Mario jumping. Mario starts at (0,0) and he moves
upward and right at the same time with a velocity of (1,3).His acceleration is (0,-1)
throughout the jump. Below figure show Marios jump for 7 more frames and
velocities are stated near.
Initially we add his velocity (1,3) to his initial position (0,0) and we get his new position
as (1,3).
Then we add his acceleration to the velocity (0.-1) and get new velocity as (1,2). Like
this we can do this for other frames and get the values.

For vector subtraction, it works as same as the vector addition. Below figure is an
example for vector subtraction in games.

(4,3)-(1,2) = (4-1, 3-2) = (3,1).


We also get scalar-vector multiplication in games. For an example we can take air
resistance into account and use it in calculating velocity. For an example for velocity
(10,20) and for air resistance 0.9, new velocity can be calculated as,

0.9*(10,20) = (0.9*10, 0.9*20) = (9,18)

Like this linear algebra can be used in calculating length, distance, dot product , cross
product as well. Examples are in figures.
In advanced way these things can be used in 2D and 3D games design as well.

2D rotations.
3. Balancing chemical equation with aid of Linear Algebra
As an example consider the following chemical equation
NaOH + H2SO4 Na2SO4 +H2O

Assign variables to each of the unknown coefficients. Then the equation can be written

as follows :-
w NaOH + x H2SO4 y Na2SO4 +Z H2O

Following linear equations are obtained, by comparing the numbers of atoms in the
reactants and products.
w=2y w+4x=4y+z w+2x=2z x=y
w -2y =0
w 4x -4y -z =0
Rewrite the linear equations in standard form to get a homogeneous system of
w 2x -2z =0
equations with 4 variables. x -y =0
Perform the Gauss-Jordan elimination method to reduce the matrix.

for our variables : w = 2y x=y 2y = z

Balanced equations values can be obtained by adding the smallest


possible positive integer value for y.In this case it is 1.

Then final values are as follows :


y=1 , x=1 , w=2 , z=2

Balanced equation :-
2 NaOH + 1 H2SO4 1 Na2SO4 + 2 H2O

Although this method may not be necessary for a simple equation as


in the above example,but it will quickly prove to be beneficial with
more complex equations.
4. Application to Traffic flow
Many mathematical theories are applicable to most of
practical applications in day to day life.
As an example arranging an efficient flow in a system is a
major area that linear algebra can applicable.
Data through a network, vehicle through traffic and fluids
through pipes are famous examples for uses of flow
management.
By using linear algebra we can simplify those flow problems.
We can use matrices to analyze the system and determine
which variables have forced values and which are free to be
chosen.
Example
The following figure shows a road network of city which includes four intersects of four
one-way streets. The numbers in the figure indicates the number of vehicles per hour
that enter and leave that street. The traffic between those intersections are presented by
using variables x 1, x2 , x3 and x4.
Finding traffic between each of four intersections using
linear algebra
Assume this is a smooth traffic flow. Therefore at each intersection, the
incoming traffic has to equal with the outgoing traffic.

Therefore we can obtain following formulas


Now we can arrange above relationship in
matrix, M=

We can use row operations to solve this linear


system,
Then we can obtain the reduced form of the linear system
as follows,

We can rewrite the above solution follows,

The system has a free variable (). Therefore the system has
many solution if only where > 100

Lets take = 500. Then,

Therefore using linear algebra we can simplify a


traffic flow of a network and can be obtained the
solutions.
5. Application in Image Processing and Transformations

In Computer Graphics and Image Processing


environment the video re-fresh (row by row from top-
left to bottom-right) is usually followed with the origin
at the top left of the screen and +x to the right and +y
pointing downwards!
MATLAB has an even a stranger convention for image
arrays, by storing it in the (y; x) instead of (x; y) order.
So, for entry (i; j) in MATLAB, I represents the y-line and
j the x-line.
An image processing convolution flter uses a set of global position-
dependent weights to sum intensities in each local n x m pixel area into an
inner product value that is placed at the corresponding center of an output
image.
For a 3 3 local filter, with pixel-intensities I(i; j):

The 2D environments of pixel-values and coefficients are serialized row-wise into:


Their inner product Iout is written to the corresponding middle position (i; j)
of the output image.
Including Translations in coordinate transformations via linear algebra

Elementary coordinate transformations in 2D and 3D using 2 x 2 or 3 x 3


transformation matrices cannot implement translations of the origin
Such a translation is an often used elementary transformation in Computer Graphics
and Image Processing, for instance when rotating an image around its center instead
of its origin in the top left corner.
The 2 x 2 and 3 x 3 transformation matrices for 2D and 3D coordinate
transformations are also enlarged to 3 x 3 and 4 x 4 homogeneous transformation
matrices for 2D and 3D transformations:
Elementary homogeneous transformations now look like this in 2D:
Homogeneous coordinate transformations in 2D are applied as follows:

For instance: rotate an image 300(degrees) around its center (30; 70). To do this we
have to concatenate three elementary operations: translate origin to center, rotate
around this new center, translate back to old origin position.
The concatenated transformation matrix C becomes:
Applied to a pixel position (x; y):

Since this result is already in normalized form, the top 2 positions are the resulting
transformed point (x; y).(Note that under this transformation the rotation center (30; 70) remains
invariant: if (x; y) = (30; 70),)
6. Weighted Least-Squares-Application of inner product space
Let y be a vector of n observations, y1, . . . , yn, and suppose we wish to approximate y
by a vector y that belongs to some specified subspace of Rn
Denote the entries in y by y1, . . . , yn.
Then the sum of the squares for error, or SS(E), in approximating y by y is,
SS(E) = (y1 y1)2 + + (yn yn)2 (1)
This is simply 2, using the standard length in Rn.

Now suppose the measurements that produced the entries in y are not equally
reliable.
Then it becomes appropriate to weight the squared errors in (1) in such a way that
more importance is assigned to the more reliable measurements.
If the weights are denoted by w12, . . . , wn2, then the weighted sum of the squares for
error is,
Weighted SS(E) = w12(y1 y1)2 + + wn2(yn yn)2 (2)
This is the square of the length of y y, where the length is derived from an inner
product namely,

It is sometimes convenient to transform a weighted least-squares problem into an


equivalent ordinary least-squares problem.
Let W be the diagonal matrix with (positive) w1, . . . , wn on its diagonal, so that
With a similar expression for W .y Observe that the j th term in (2) can be written as

It follows that the weighted SS(E) in (2) is the square of the ordinary length in Rn of W.y W.y,
which we write as 2.
Now suppose the approximating vector y is to be constructed from the columns of a matrix A.
Then we seek an x that makes Ax = y as close to y as possible. However, the measure of
closeness is the weighted error,

Thus x is the (ordinary) least-squares solution of the equation,


WAx = Wy
The normal equation for the least-squares solution is
(WA)T WAx = (WA)TWy
7. Application to Genetics
Genetics is the study of genes , heredity, and genetic variation in living
organisms. It is generally considered a field of biology, but it intersects
frequently with many of the life sciences. Linear Algebra can also apply to
genetics. Genetics is the branch of science concerned with genes, heredity,
and variation in living organisms. It seeks to understand the process of trait
inheritance from parents to offspring, including the molecular structure and
function of genes, gene behavior in the context of a cell or organism gene
distribution, and variation and change in populations.

There are several types of inheritance; one of particular interest for us is the
autosomal type in which each heritable trait is assumed to be governed by a
single gene. Typically, there are two different forms of genes denoted by A
and
a. Each individual in a population carries a pair of genes; the pairs are
called
the individuals genotype. This gives three possible genotypes for each
inheritable trait: AA, Aa, and aa (aA is genetically the same as Aa).
How genes of parents are passed onto their offspring?

Each individual inhererits one of the genes from one of its parent and
the another gene from its other parent. Since each parent can pass on
only one gene to the offspring, which of the two genes passes on is a
matter of chance.
Lets consider an example of use of Linear Algebra regarding this matter
Example
A common problem in this field is finding the probability of certain genotype after a given number of years. For example, suppose we
want to study the fractions of the three genotypes in the n th generation of cows in terms of the initial genotype fractions. The
Following example is regarding that.

Professor Vetar, at UC Davis, discovers that cows with genotype AA can produce a better quality milk than other
genotypes. Professor Vetar is interested in discovering the fraction of offspring cows with genotype AA. If professor
Vetar choses to cross only genotype AA with other genotypes, what are the probabilities of the offspring being AA, Aa,
or aa ?

To analyze the problem, we will consider three cases:

First assume, the crossing of AA with AA. This will always gives the genotype AA, therefore the probabilities of an
offspring to be AA, Aa, and aa respectively are equal to 1, 0, and 0.

Second, assume crossing of Aa with AA. The offspring will have half chance to be of genotype AA and half chance the
genotype Aa, therefore the probabilities of AA, Aa, and aa respectively are 1/2, 1/2, and 0.

Third, consider crossing of aa with AA. This will always results in genotype Aa. Therefore, the probabilities of genotypes
AA, Aa, and aa respectively are 0, 1, and 0, respectively.
Example Cont.
The following matrix is the result of the pervious observation:

This matrix can be viewed as the following table:

Assume that the initial population of cows made up of an equal number of each genotype, therefore, the initial
distribution vector is given by,

One year later, the distribution is,


Example Cont.
After another year passed by, the distribution vector can be obtained as follow:

For any positive integer n, that is n years later,

Now if n gets larger and larger, the matrix is equal to,


Example Cont.
Therefore will approach to,

Suppose someone is interested to see the number of cows with genotype AA, Aa, and aa after 20 generations. One way
to answer this question is to compute which may result in computational error during the matrix multiplication.
Another approach using of diagonalization reduces computation. If the matrix A can be written as product of an
invertible matrix P a diagonal matrix and inverse of P ,that is, then computation will be much simples and
therefore much less computational error. This is mainly because of the following fact:

and
Example Cont.
Not every matrix A is diagonalizable. For A to be diagonalizable it needs to have n linearly independent
eigenvectors. The matrix P is formed by writing these eigenvectors as columns of P. To find eigenvectors
we will first find the eigenvalues.
For the matrix A above the eigenvalues are,

and corresponding eigenvectors are:

The diagonal matrix

and

Therefore, as n approach infinity..


X-linked inheritance
Some genes found on the x-chromosome, are not in pair in males, female has two and male has only one. Inheritance of
these genes is as follow: If offspring is a male then he receives one of his mother's two genes; if offspring is a female she
receives one gene from his father and another one from her mother.
8. Applications of linear algebra Fibonacci numbers
Let fn denote the nth Fibonacci
number, then we have
f0=1, f1=1, f2=2, f3=3, f4=5,... (Look
at the diagram given here)
Generally,
fn=fn-1+fn-2.
In other words, every term in the
Fibonacci sequence (start with n=2) is
equal to the sum of the previous two
terms.
Table given below shows first 55 Fibonacci numbers
So the Fibonacci numbers get bigger and bigger with
increasing the n value.
We can find Fibonacci number for any n value by using matrix
diagonalization. This method fully consist with linear algebra.
n, fn n, fn n, fn n, fn n, fn
1, 1 12, 144 23, 28657 34, 5702887 45, 1134903170
2, 1 13, 233 24, 46368 35, 9227465 46, 1836311903
3, 2 14, 377 25, 75025 36, 14930352 47, 2971215073
4, 3 15, 610 26, 121393 37, 24157817 48, 4807526976
5, 5 16, 987 27, 196418 38, 39088169 49, 7778742049
6, 8 17, 1597 28, 317811 39, 63245986 50, 12586260925
7, 13 18, 2584 29, 514229 40, 102334155 51, 20365011074
8, 21 19, 4181 30, 832040 41, 165580141 52, 32951280099
9, 34 20, 6765 31, 1346269 42, 267914296 53, 53316291173
10, 55 21, 10946 32, 2178309 43, 433494437 54, 86267571272
11, 89 22, 17711 33, 3524578 44, 701408733 55, 139583862445
A square matrix is called diagonal if all its entries are zero except the entries on the
main diagonal.
A square matrix Ais called diagonalizable if there exists an invertible matrix P of the
same size satisfying this condition for some diagonal matrix D,
(Normally say that Ais similar to a diagonal matrix)
Then if A is diagonalizable, then A=PDP-1 for some invertible matrix Pand diagonal
matrix D.And the figure given below shows some powers of A

Generally we can see Ak=PDkP-1 for any power k. And also Disadiagonalmatrix.
Therefore we can compute Dkasfollows,

Therefore, computing the powers of a diagonalizable matrix is an easy


task once we know the matrices P and D in the formula
This Theorem gives an algorithm for diagonalization.
Theorem - Let Abe an nxnmatrix, and let 1,, k be the distinct
(real) Eigen values of A. Then we have the following,
1. A is diagonalizable if and only if dim (E1) ++ dim (Ek)=n.
2. If A is diagonalizable with P-1AP=D, then the columns
of Pare ,basis vectors for the Eigen spaces of A and the
diagonal entries of D are the corresponding Eigen values.
Let us consider about the matrix A
then

Therefore, the vector is an eigenvector for the


matrix A corresponding to the Eigen value (1+5)/2.
The Eigen values of A are the solutions to this equation
Solving the above equation can take two Eigen values
So the Eigen space E corresponding to the Eigen value to
be the set of all eigenvector of together with the zero
vector. In other words, E is the solution set to the
homogeneous system (A- I)X=0
Then find the eigenvectors of Acorresponding to the Eigen
value 1=(1+5)/2, by solving system
This equivalent to

Therefore the solution is and


That means the vector X1 is a basis for E1
Similarly we can show that the vector X2,
is a basis for the Eigen space E2
and also dim (E1) + dim (E2)=2.
Then and apply the diagonalization algorithm to the matrix A.
Since we showed above that dim (E1) + dim (E2)=2, we know now that Ais
diagonalizable
Let be the matrix whose columns are the basis vectors
of the
Eigen spaces found above.
And

Then the Theorem stated above gives the following decomposition of A

Then this things can be applied to find Fibonacci numbers. The general pattern
for the Fibonacci sequence is
fn=fn-1+fn-2
A general expression for fn is not apparent, but can be transform the problem
into a simpler one using matrices. The idea is to compute the vector Vn,
for each n0 rather than fnitself. The relation fn=fn-1+fn-
2 gives

Where Is the
same matrix taken above.
Using the relationship,
and
Also An=PDnP-1
where

andVn=PDnP-1Vo
For all n0, The last vector of the formula for Vn is,

By carefully multiplying the equation for Vnand by taking the first


component of the result, we can get the nth Fibonacci term

For example, now we can easily compute the 100 th term of the
Fibonacci sequence as follows
References
Application to Graph theory -
http://aix1.uottawa.ca/~jkhoury/graph.htm
Linear Algebra and Gaming -
http://home2.fvcc.edu/~dhicketh/linearalgebra/studentprojects/spring2012/BryanLutgen/Linear %20Algebra%20and%20Gaming.pdf
Balancing Chemical Equations with Linear Algebra -(VIDEO)
https://www.youtube.com/watch?v=yCxDAj87W8M
Applications of systems of linear equations: traffic flow -(VIDEO)
https://www.youtube.com/watch?v=8Kg21jBCm-k
Numerical Linear Algebra, Data Mining and Image Processing
http://www.math.hkbu.edu.hk/~mng/siamala.pdf
On Linear Least-Squares Problems with Diagonally Dominant Weight Matrices
http://epubs.siam.org/doi/abs/10.1137/S0895479895284014
Linear Algebra & Genetics
http://www.math.uci.edu/~brusso/ReedBAMS97.pdf
The Fibonacci Numbers Using Linear Algebra (VIDEO)
https://www.youtube.com/watch?v=L4Rgq8J7ZzA

You might also like