Matrix Solution to Linear Equations and Markov Chains

Similar documents
MATRICES AND VECTORS SPACE

Matrices. Elementary Matrix Theory. Definition of a Matrix. Matrix Elements:

How do we solve these things, especially when they get complicated? How do we know when a system has a solution, and when is it unique?

Matrices and Determinants

Chapter 14. Matrix Representations of Linear Transformations

Chapter 3 MATRIX. In this chapter: 3.1 MATRIX NOTATION AND TERMINOLOGY

Engineering Analysis ENG 3420 Fall Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00

Matrix Algebra. Matrix Addition, Scalar Multiplication and Transposition. Linear Algebra I 24

CH 9 INTRO TO EQUATIONS

THE DISCRIMINANT & ITS APPLICATIONS

Here we study square linear systems and properties of their coefficient matrices as they relate to the solution set of the linear system.

The Algebra (al-jabr) of Matrices

Pre-Session Review. Part 1: Basic Algebra; Linear Functions and Graphs

How do we solve these things, especially when they get complicated? How do we know when a system has a solution, and when is it unique?

Matrix Eigenvalues and Eigenvectors September 13, 2017

Theoretical foundations of Gaussian quadrature

Operations with Polynomials

Equations and Inequalities

Geometric Sequences. Geometric Sequence a sequence whose consecutive terms have a common ratio.

Matrices 13: determinant properties and rules continued

DETERMINANTS. All Mathematical truths are relative and conditional. C.P. STEINMETZ

a a a a a a a a a a a a a a a a a a a a a a a a In this section, we introduce a general formula for computing determinants.

Lecture 3. In this lecture, we will discuss algorithms for solving systems of linear equations.

State space systems analysis (continued) Stability. A. Definitions A system is said to be Asymptotically Stable (AS) when it satisfies

Module 6: LINEAR TRANSFORMATIONS

Duality # Second iteration for HW problem. Recall our LP example problem we have been working on, in equality form, is given below.

Lecture Note 9: Orthogonal Reduction

fractions Let s Learn to

Operations with Matrices

ECON 331 Lecture Notes: Ch 4 and Ch 5

A-Level Mathematics Transition Task (compulsory for all maths students and all further maths student)

AQA Further Pure 1. Complex Numbers. Section 1: Introduction to Complex Numbers. The number system

We will see what is meant by standard form very shortly

INTRODUCTION TO LINEAR ALGEBRA

The use of a so called graphing calculator or programmable calculator is not permitted. Simple scientific calculators are allowed.

Things to Memorize: A Partial List. January 27, 2017

Introduction To Matrices MCV 4UI Assignment #1

Chapter 2. Determinants

Each term is formed by adding a constant to the previous term. Geometric progression

Algebra Of Matrices & Determinants

Vyacheslav Telnin. Search for New Numbers.

SUMMER KNOWHOW STUDY AND LEARNING CENTRE

Elementary Linear Algebra

Introduction to Determinants. Remarks. Remarks. The determinant applies in the case of square matrices

SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics

Elementary Mathematical Concepts and Operations

MATHEMATICS AND STATISTICS 1.2

Properties of Integrals, Indefinite Integrals. Goals: Definition of the Definite Integral Integral Calculations using Antiderivatives

Consolidation Worksheet

Preparation for A Level Wadebridge School

ODE: Existence and Uniqueness of a Solution

Sample pages. 9:04 Equations with grouping symbols

MTH 5102 Linear Algebra Practice Exam 1 - Solutions Feb. 9, 2016

How do you know you have SLE?

The Islamic University of Gaza Faculty of Engineering Civil Engineering Department. Numerical Analysis ECIV Chapter 11

NUMERICAL INTEGRATION. The inverse process to differentiation in calculus is integration. Mathematically, integration is represented by.

DETERMINANTS. All Mathematical truths are relative and conditional. C.P. STEINMETZ

The Regulated and Riemann Integrals

Review of Calculus, cont d

PART 1 MULTIPLE CHOICE Circle the appropriate response to each of the questions below. Each question has a value of 1 point.

Linear Algebra Introduction

8 Laplace s Method and Local Limit Theorems

UNIT 1 FUNCTIONS AND THEIR INVERSES Lesson 1.4: Logarithmic Functions as Inverses Instruction

Jim Lambers MAT 169 Fall Semester Lecture 4 Notes

set is not closed under matrix [ multiplication, ] and does not form a group.

Natural examples of rings are the ring of integers, a ring of polynomials in one variable, the ring

MATH , Calculus 2, Fall 2018

Math 520 Final Exam Topic Outline Sections 1 3 (Xiao/Dumas/Liaw) Spring 2008

Chapter 4 Contravariance, Covariance, and Spacetime Diagrams

308K. 1 Section 3.2. Zelaya Eufemia. 1. Example 1: Multiplication of Matrices: X Y Z R S R S X Y Z. By associativity we have to choices:

Quadratic Forms. Quadratic Forms

I do slope intercept form With my shades on Martin-Gay, Developmental Mathematics

Linear Inequalities. Work Sheet 1

Recitation 3: More Applications of the Derivative

HW3, Math 307. CSUF. Spring 2007.

Chapter 1. Basic Concepts

Unit #9 : Definite Integral Properties; Fundamental Theorem of Calculus

Week 10: Line Integrals

Unit 1 Exponentials and Logarithms

Chapter 0. What is the Lebesgue integral about?

Elements of Matrix Algebra

Lesson 25: Adding and Subtracting Rational Expressions

I1 = I2 I1 = I2 + I3 I1 + I2 = I3 + I4 I 3

Lecture Solution of a System of Linear Equation

Numerical Integration

Chapter 3. Vector Spaces

Numerical Linear Algebra Assignment 008

New data structures to reduce data size and search time

5.2 Exponent Properties Involving Quotients

N 0 completions on partial matrices

Arithmetic & Algebra. NCTM National Conference, 2017

Bridging the gap: GCSE AS Level

Uses of transformations. 3D transformations. Review of vectors. Vectors in 3D. Points vs. vectors. Homogeneous coordinates S S [ H [ S \ H \ S ] H ]

(e) if x = y + z and a divides any two of the integers x, y, or z, then a divides the remaining integer

Physics 116C Solution of inhomogeneous ordinary differential equations using Green s functions

Logarithms. Logarithm is another word for an index or power. POWER. 2 is the power to which the base 10 must be raised to give 100.

Continuous Random Variables

STEP FUNCTIONS, DELTA FUNCTIONS, AND THE VARIATION OF PARAMETERS FORMULA. 0 if t < 0, 1 if t > 0.

Can the Phase I problem be unfeasible or unbounded? -No

Section 3.2: Negative Exponents

Transcription:

Trding Systems nd Methods, Fifth Edition By Perry J. Kufmn Copyright 2005, 2013 by Perry J. Kufmn APPENDIX 2 Mtrix Solution to Liner Equtions nd Mrkov Chins DIRECT SOLUTION AND CONVERGENCE METHOD Before computer progrms offered redy solutions, problems such s Mrkov chins were solved in direct mnner, by lgebriclly mnipulting the equtions. This direct solution requires n understnding of simple mtrix rithmetic nd very creful ttention to clculting the numbers correctly. The convergence method is now esier, lthough it requires mny more clcultions. Without the computer, we would never even consider using this pproch with computer, it is the best choice. GENERAL MATRIX FORM A mtrix is rectngulr rrngement of elements into rows nd columns. Mtrix A is sid to be m n (pronounced m by n ) if there re m rows nd n columns in A. m n = 12 1n 21 22 2n m1 m2 mn Certin properties of mtrix mke it vluble tool for solving simultneous liner equtions. These elementry mtrix opertions, clled trnsformtions, llow you to lter the rows (which will represent equtions) without chnging the solution. There re three bsic row opertions: 1. Multipliction or division of ll elements of the row by ny number. 2. Interchnging of ny two rows (nd consequently of ll rows). 3. The ddition or subtrction of the elements of one row with the corresponding elements of nother. 51

52 APPENDIX 2 To relte the mtrix to simultneous liner equtions, consider three-eqution exmple, where only the coefficients, x, remin s unknowns: x 1 + 12 x 2 + 13 x 3 = 14 (1) 21 x 1 + 22 x 2 + 23 x 3 = 24 (2) 31 x 1 + 32 x 2 + 33 x 3 = 34 (3) The three elementry row opertions cn now be interpreted in terms of simple opertions on n eqution: 1. When both sides of n eqution re multiplied or divided by the sme vlue, the results re equl. 2. Any two equtions in system of equtions cn be interchnged with no effect. 3. When two equls re dded or subtrcted, the results re equl. DIRECT SOLUTION Putting these rules into use, write the coefficients of the three simultneous liner equtions s 3 4 coefficient mtrix, 12 13 14 21 22 23 24 31 32 33 34 with the objective of reducing the mtrix to the form 1 0 0 0 1 0 0 0 1 A A A 1 2 3 which would men tht x 1 = A 1, x 2 = A 2, nd x 3 = A 3 since 1 x 1 + 0 x 2 + 0 x 3 = A 1 0 x 1 + 1 x 2 + 0 x 3 = A 2 0 x 1 + 0 x 2 + 1 x 3 = A 3 To chieve the results, divide the first eqution by the first element, leving 1 12 13 14 (2-1)

Appendix 2 53 nd then multiply by 21 to get the first elements in rows one nd two the sme: Now subtrct (1-2) from (2) nd get 0 22 21 12 21 13 21 12 21 23 13 21 14 21 24 14 21 (2-2) (2-3) Tht successfully elimintes the first element 21 from the second eqution. By going bck nd multiplying (2-1) by 31 nd subtrcting the resulting eqution from (3), 31 cn be eliminted from eqution (3). Now column 1 looks like 1 0 0 Column two or ny column cn be operted upon in the sme mnner s the first column: 1. Divide row n by the element in position n (for exmple, nn ), thereby setting nn = 1. 2. Multiply row n by the corresponding element in row i n, so tht nn in = in. 3. Subtrct row n from row i, resulting in in = 0, nd ll other elements reduced by the corresponding element in row n. Continue this procedure for ech row i until ll elements For exmple, beginning with 1n, 2n,..., i 1n, 1+1n,..., mn = 0 nd in = 1 2 4 8 34 6 5 2 22 3 6 5 30 Divide row 1 by the vlue 2 (position ): 1 2 4 17 6 5 2 22 3 6 5 30 Multiply row 1 by the vlue 6 to get (6 12 24 102) nd subtrct the new clculted row from row 2: 1 2 4 17 0 7 22 80 3 6 5 30

54 APPENDIX 2 Multiply row 1 by the number 3 to get (3 6 12 51), then subtrct the clculted row from row 3: 1 2 4 17 0 7 22 80 0 0 7 21 Column 1 is now completed. Divide row 2 by 7 nd get: 1 2 4 17 0 1 + 22 / 7 + 80 / 7 0 0 7 21 Multiply row 2 by 2 nd subtrct the result (0 2 44/7 160/7) from row 1 to eliminte position 2 in the first row: 1 0 16 / 7 41 / 7 0 1 + 22 / 7 + 80 / 7 0 0 7 21 Becuse the element in row 3 nd column 2 is lredy 0, move to row 3. Divide row 3 by 7 nd get 1 0 16 / 7 41 / 7 0 1 + 22 / 7 + 80 / 7 0 0 1 3 Multiply row 3 by 16/7 nd subtrct the result (0 0 16/7 48/7) from row 1: 1 0 0 1 0 1 + 22 / 7 + 80 / 7 0 0 1 3 Multiply row 3 by +22/7 nd subtrct (0 0+22/7 +66/7) from row 2: 1 0 0 1 0 1 0 2 0 0 1 3 The results show tht x 1 = 1, x 2 = 2, x 3 = 3. There re other wys to reduce the mtrix to the finl representtion, but this technique is well defined nd lends itself to being progrmmed on computer.

Appendix 2 55 Solution to Wether Probbilities Expressed s Mrkov Chin Let A = P(cler) i+1 = P(cler) i B = P(cloudy) i+1 = P(cloudy) i C = P(riny) i+1 = P(riny) i becuse when they converge ll ith elements will equl (i + 1)th elements. The equtions re In ddition, A = 0.7A + 0.2B + 0.2C (1) B = 0.25A + 0.6B + 0.4C (2) C = 0.05A + 0.2B + 0.4C (3) A + B + C = 1 (4) To solve this system of equtions using mtrices, convert nd dd eqution (3) to (4), which becomes the mtrix 0.3A + 0.2B + 0.2C = 0 (1 ) 0.25A 0.4B + 0.4C = 0 (2 ) 1.05A + 1.2B + 0.4C = 1 (3 ) 0.3 0.2 0.2 0 0.25 0.4 0.4 0 1.05 1.2 0.4 1 (1 ) (2 ) (3 ) The following re key steps in the solution: 1. Reduce the first row, 1 0.6667 0.6667 0 0.25 0.4 0.4 0 1.05 1.2 0.4 1 nd mke the leding entries of rows 2 nd 3 zero: 1 0.6667 0.6667 0 0 0.2333 0.5667 0 0 1.9000 1.1000 1

56 APPENDIX 2 2. Reduce the second row, 1 0.6667 0.6667 0 0 1 2.4291 0 0 1.9000 1.1000 1 nd mke the second entries of rows 1 nd 3 zero: 1 0 2.2857 0 0 1 2.4291 0 0 0 5.7143 1 3. Reduce the third row, 1 0 2.2862 0 0 1 2.4291 0 0 0 1 0.1750 nd mke the third entry of rows 1 nd 2 zero: 1 0 0 0.4000 0 1 0 0.4250 0 0 1 0.1750 Then A = 0.4000, B = 0.4250, nd C = 0.1750. Computer Progrm Direct Solution The following FORTRAN progrm ccepts system of 10 equtions in 10 vribles ( unknowns) nd pplies the mtrix method of solution. This is done using the method of Gussin elimintion. PROGRAM MATRIX C---- Mtrix solution to simultneous liner equtions C---- Copyright 1986 PJ Kufmn DIMENSION A(10,10), C(10) OPEN(6,FILE= PRN ) WRITE(*,7000) 7000 FORMAT( Enter mtrix size (n)> \) READ(*,5000)N 5000 FORMAT(BN,14) IF(N.GT.1O)STOP Mtrix limited to 10 x 10 WRITE(*,7001) (1,1=1,N)

Appendix 2 57 7001 FORMAT( Enter mtrix elements row by row under hedings + do not include constnt to right of + 7X,10(12, -xxxxx )) DO 20 I = 1,N WRITE(*,7003)1 7003 FORMAT( Row,12, : \) READ(*,5003) (A(IMP), J=1,N) 5003 FORMAT(BN,10F8.0) 20 CONTINUE WRITE(*,7004) (J,J=1,N) WRITE(6,7004) (J,J=1,N) 7004 F0RMAT(/ Input mtrix is: //9X,10(I2, -col )) DO 30 I = 1,N WRITE(6,7005)I,(A(I,J),J=1,N) 30 WRITE(*,7005)I,(A(I,J),J=1,N) 7005 FORMAT(/ Row,I2, :,10F8.3) WRITE(*,7008)(I,I=1,N) 7008 FORMAT(/ Enter constnt vector under hedings... / + 1X,10(I1, xxxxxx )) READ(*,5008)(C(I),I=1,N) 5008 FORMAT(BN,10F8.0) WRITE(*,7009)(C(I),I=1,N) WRITE(6,7009)(C(I),I=1,N) 7009 FORMAT(/ Constnt vector is: /10F8.3) C----- Process row by row (Gussin Elimintion) DO 100 I = 1,N DIV = A(I,I) DO 40 J = 1,N 40 A(I,J) = A(I,J)/DIV C(I) = C(I)/DIV C----- Zero out column I for ech row DO 60 J = 1,N IF(J.EQ.I)GOTO 60 FACT0R = A(J,I) DO 50 K = 1,N 50 A(J,K) = A(J,K) - A(I,K)*FACT0R C(J) = C(J) - C(I)*FACT0R 60 CONTINUE 100 CONTINUE WRITE(*,7007)(C(I),I = 1,N) WRITE(6,7007)(C(I),I = 1,N) 7007 FORMAT(/ Solution vector is: /10F8.3) CALL EXIT END

58 APPENDIX 2 Smple Computer Printout MATRIX Enter mtrix size (N)> 3 Enter mtrix elements row by row under hedings... do not include constnt to right of = 1-xxxxx 2-xxxxx 3-xxxxx Row 1: 2 4 8 Row 2: 6 5 2 Row 3: 3 6 5 Input mtrix is: 1-col 2-col 3-col Row 1: 2.000 4.000 8.000 Row 2: 6.000 5.000 2.000 Row 3: 3.000 6.000 5.000 Enter constnt vector under hedings., lxxxxxx 2xxxxxx 3xxxxxx 34 22 30 Constnt vector is: 34.000 22.000 30.000 Solution vector is: 1.000 2.000 3.000 CONVERGENCE METHOD This method performs series of mtrix multiplictions until the difference between the new nd previous mtrix is very smll. 1 Following the procedure in Chpter 2, Bsic Concepts nd Clcultions, we cn crete 3 3 frequency mtrix by counting the number of up, down, nd neutrl dys tht follow other up, down, nd neutrl dys. We use the term neutrl to llow very smll price chnges to be considered in this group, rther thn limit it to only those dys with zero chnges. For this exmple we will look t the number of up, down, nd neutrl dys tht follow 5-dy trend tht ws considered up, down, or neutrl on the previous dy. Suppose the results were those shown in the frequency mtrix F: Next Dy Price Chnge Up Neutrl Down Totl Previous dy trend Up 70 40 30 140 Neutrl 50 30 45 125 Down 35 45 65 145 1 George R. Arrington, Mrkov Chins, Technicl Anlysis of Stocks & Commodities (December 1993).

Appendix 2 59 Divide ech item in F by the totl given t the end of tht row, nd get the probbility of ech occurrence in trnsition mtrix T. Next Dy Price Chnge Up Neutrl Down Previous dy trend Up 0.500 0.285 0.214 Neutrl 0.400 0.240 0.360 Down 0.241 0.310 0.448 Now it is necessry to perform mtrix multipliction. To multiply mtrix A by mtrix B, we multiply the corresponding items in row i of A by the corresponding item in column j of B, dd those products together to get the item in row i, column j of the new mtrix C. If we hve two 3 3 mtrices A nd B, nd we wnted to find the element in row 2, column 1 of the new product mtrix C, we would multiply nd dd The generl formul for this is c 21 = 21 b + 22 b 21 + 23 b 31 N c = ( b ) ij ik kj k= 1 For spredsheet users, there is no generl formul to copy from one cell to nother. For mtrix A of 3 columns nd 3 rows locted in columns A, B, C, rows 1, 2, 3; mtrix B in columns D, E, F, rows 1, 2, 3; nd mtrix C in rows G, H, I, columns 1, 2, 3, we enter the formul for c in cell G1 s cell G1 = A1* D1 + B1* D2 +C1* D3 While this is clerly tedious, t lest the rithmetic will be correct. Itertive Mtrix We cn now find the solution to the Mrkov chin, the long-term probbilities, by performing series of mtrix multiplictions beginning with the trnsition mtrix. 1. Multiply the trnsition mtrix T by itself to get the first itertive mtrix I 1, I 1 = T T 2. Multiply the itertive mtrix by the trnsition mtrix to get the next itertive mtrix, I 2 = I 1 T

60 APPENDIX 2 3. Continue to multiply the lst itertive mtrix by the trnsition mtrix until the new itertive mtrix is unchnged (or very close) to the previous itertive mtrix, I n = I n 1 T When ech element stisfies the condition bs(i ij (n) I ij (n 1)) < 0.001 then the itertive mtrix holds the finl long-term probbilities of the Mrkov chin.