Linear Systems: Solving Equations and Understanding Matrix Notation, Slides of Operating Systems

An introduction to linear systems, including the definition of linear equations and systems, the concept of a solution, and the use of matrix notation for representing and solving systems. An example of a system of equations and its solution, as well as discussions on equivalent systems, triangular linear systems, and the complexity of algorithms for solving large systems.

Typology: Slides

2012/2013

Uploaded on 04/25/2013

baidehi
baidehi 🇮🇳

4.4

(14)

101 documents

1 / 18

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Linear systems
äAlinear equation in the variables x1,···, xnis an equa-
tion that can be written in the form
a1x1+a2x2+··· +anxn=b,
where band the coefficients a1,··· , anare real or complex
numbers that are usually known in advance.
äAsystem of linear equations (or a linear system) is
a collection of one or more linear equations involving the
same variables say, x1, ...., xn.
äAsolution of the system is a list (s1, s2, ..., sn)of num-
bers that makes each equation a true statement when the
values s1, ..., snare substituted for x1, ..., xn, respectively.
3
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12

Partial preview of the text

Download Linear Systems: Solving Equations and Understanding Matrix Notation and more Slides Operating Systems in PDF only on Docsity!

Linear systems

ä A linear equation in the variables x 1 , · · · , xn is an equa- tion that can be written in the form a 1 x 1 + a 2 x 2 + · · · + anxn = b,

where b and the coefficients a 1 , · · · , an are real or complex numbers that are usually known in advance.

ä A system of linear equations (or a linear system) is a collection of one or more linear equations involving the same variables – say, x 1 , ...., xn.

ä A solution of the system is a list (s 1 , s 2 , ..., sn) of num- bers that makes each equation a true statement when the values s 1 , ..., sn are substituted for x 1 , ..., xn, respectively.

Example:

Three winners of a competition labeled G, S, B (for gold, silver, bronze) are to share as a prize 30 coins. The con- ditions are that 1) G’s share of the coins should equal the shares of S and B combined and 2) The difference between the shares of G and S equals the difference between the shares of S and B.

ä How many coins should each of G, S, B receive?

ä Should formulate as a system of equations:

  • 3 conditions → result will be 3 equations
  • 3 unknowns (# coins for each of winner)

ä The set of all possible solutions is called the solution set of the linear system.

ä Two linear systems are called equivalent if they have the same solution set.

ä A system of linear equations has:

  1. no solution, or
  2. exactly one solution, or
  3. infinitely many solutions.

[The above result will be seen in detail later in this class]

ä A system of linear equations is said to be consistent if it has either one solution or infinitely many solutions.

ä A system of linear equation is said to be inconsistent if it has no solution.

Matrix Notation

ä The essential information of a linear system is recorded compactly in a rectangular array called a matrix.

ä For the following system of equations:

x 1 +x 2 +x 3 = 30 x 1 −x 2 −x 3 = 0 x 2 − 2 x 2 +x 3 = 0 The array to the right is called the coefficient matrix of the system:

And the right-hand side is:

ä An augmented matrix of a system consists of the coef- ficient matrix with the R.H.S. added as a last column

ä Note: R.H.S. or RHS = short for right-hand side column.

  • Can we add two equations/rows? Add equations 1 and
  1. What do you get?
  • Now add equations 2 and 3. What do you get? Can you compute x 2?
  • Finally obtain x 3

ä This shows an “ad-hoc” [intuitive] way of manipulating equations to solve the system.

ä Gaussian Elimination [coming shortly] shows a system- atic way

ä Basic Strategy: replace a system with an equivalent system (i.e., one with the same solution set) that is easier to solve.

Terminology on matrices

ä The size of a matrix tells how many rows and columns it has. If m and n are positive numbers, an m × n matrix is a rectangular array of numbers with m rows and n columns. (The number of rows always comes first.)

ä If m = n the matrix is said to be square otherwise it is rectangular

ä The case when n = 1 is a special case where the matrix consists of just one column. The matrix then becomes a vector and this will be revisited later. The right-hand side column is one such vector.

ä Thus a linear system consists of a coefficient matrix A and a right-hand side vector b.

Triangular linear systems are easy to solve

Example:

 



2 x 1 + 4x 2 + 4x 3 = 2 5 x 2 − 2 x 3 = 1 2 x 3 = 4

ä One equation can be trivially solved: the last one. x 3 = 2

ä x 3 is known we can now solve the 2nd equation: 5 x 2 − 2 x 3 = 1 → 5 x 2 − 2 × 4 = 1 → x 2 = 1

ä Finally x 1 can be determined similarly: 2 x 1 + 4 × 1 + 4 × 2 = 2 → ... → x 1 = − 5

Algorithms - complexity

ä Not emphasized in text [unfortunately!]

  • Find (google) the origin of the word ‘Algorithm’ An algorithm is a sequence of instructions given to a machine (typically a computer) to solve a given problem

An example: Find the square root of a number.

Method: calculate

xnew = 0. 5

xold +

a xold

... until xnew no longer changes much. Start with x = a

Matlab function for square root

ä Matlab functions will be seen in detail later [recitations or class] – this is given just as an illustration.

function x = mysqrt(a, tol, maxits) % x = mysqrt(a, tol, maxits) % computes the square root of a (a must be > 0 ) if (a <0) error(’ *** a < 0’) end %%-------------------- main loop for i=1:maxits x = xn ; xn = 0.5(x+a/x) if (abs(xn-x) < tolxn) break end end

  • You can find slightly better implementations

The issue of cost (‘complexity’)

ä For small problems cost may not be important - except when the operation is repeated many times.

ä For systems of equations in the thousands, then the algorithm could make a huge difference.

What to count?

  • Memory copy / move.
  • Comparisons of numbers (integers, floating-points)
  • Floating point operations: add, multiply, divide (more expensive)
  • Intrinsic functions: sin, cos, exp, √^ , etc.. a few times more expensive than add/ multiply.

ä Cost = number of operations to complete a given algo- rithm = function of n the problem size

ä Will find something like [example]

C(n) = 2n^3 + n^2 − 3 n

ä We are interested in cases with large values of n

ä Major point: only the leading term 2 n^3 matters - be- cause the rest is small (relatively to 2 n^3 ) when n is large.

ä We will say that the cost is of order 2 n^3 or even order n^3 [meaning that it increases like the cube of n as n increases]

  • Compare C(100), C(200) and 8 C(100). Explain
  • Suppose it takes 1 sec. run the algorithm for a certain value of n (large), how long would it take to run the same algorithm on a problem of size 2 n?

Back to triangular linear systems - Algorithm

ä Upper triangular system of size n

ALGORITHM : 2 Back-Substitution algorithm

For i = n : −1 : 1 do: t := bi For j = i + 1 : n do t := t − aijxj End xi = t/aii End

ä We must require that each aii 6 = 0