Difference between revisions of "Scilab/C4/Linear-equations-Gaussian-Methods/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with '{| Border=1 || Time || Narration |- | 00.01 |Dear Friends, |- | 00.02 |Welcome to the spoken tutorial on ''' “Solving System of Linear Equations using Gauss Elimination a…')
 
Line 1: Line 1:
 
{| Border=1
 
{| Border=1
  
|| Time
+
|'''Time'''
 
+
|'''Narration'''
|| Narration
+
  
 
|-
 
|-
| 00.01
+
| 00:01
 
|Dear Friends,  
 
|Dear Friends,  
  
 
|-
 
|-
| 00.02
+
| 00:02
 
|Welcome to the spoken tutorial on  ''' “Solving System of Linear Equations using Gauss Elimination and Gauss-Jordan Methods”  '''
 
|Welcome to the spoken tutorial on  ''' “Solving System of Linear Equations using Gauss Elimination and Gauss-Jordan Methods”  '''
  
  
 
|-
 
|-
| 00.12.
+
| 00:12.
 
| At the end of this tutorial, you will learn how to:   
 
| At the end of this tutorial, you will learn how to:   
  
 
|-
 
|-
|00.15
+
|00:15
 
|Solve system of linear equations using '''Scilab'''  
 
|Solve system of linear equations using '''Scilab'''  
  
 
|-
 
|-
|00.20
+
|00:20
 
|Develop '''Scilab''' code to solve linear equations  
 
|Develop '''Scilab''' code to solve linear equations  
  
  
 
|-
 
|-
| 00.25
+
| 00:25
 
|To record this tutorial, I am using  
 
|To record this tutorial, I am using  
  
 
|-
 
|-
|00.27
+
|00:27
 
|'''Ubuntu 12.04''' as the operating system  
 
|'''Ubuntu 12.04''' as the operating system  
  
  
 
|-
 
|-
| 00.31
+
| 00:31
 
|with '''Scilab 5.3.3''' version  
 
|with '''Scilab 5.3.3''' version  
  
 
|-
 
|-
| 00.36
+
| 00:36
 
| To practise this tutorial, a learner should have basic knowledge of '''Scilab'''  
 
| To practise this tutorial, a learner should have basic knowledge of '''Scilab'''  
  
 
|-
 
|-
|00.40
+
|00:40
 
|and should know how to solve '''Linear Equations.'''  
 
|and should know how to solve '''Linear Equations.'''  
  
 
|-
 
|-
|00.45
+
|00:45
 
| To learn '''Scilab''', please refer to the relevant tutorials available on the '''Spoken Tutorial''' website.  
 
| To learn '''Scilab''', please refer to the relevant tutorials available on the '''Spoken Tutorial''' website.  
  
 
|-
 
|-
| 00.52
+
| 00:52
 
| A system of '''linear equations''' is a  
 
| A system of '''linear equations''' is a  
  
 
|-
 
|-
| 00.55
+
| 00:55
 
| Finite collection of '''linear equations''' of the same set of  '''variables'''  
 
| Finite collection of '''linear equations''' of the same set of  '''variables'''  
  
 
|-
 
|-
|01.00
+
|01:00
 
|Let us study  '''Gauss elimination method'''
 
|Let us study  '''Gauss elimination method'''
  
 
|-
 
|-
|01.04
+
|01:04
 
| Given a system of equations  
 
| Given a system of equations  
  
 
|-
 
|-
|01.06
+
|01:06
 
|'''A x equal to b'''  
 
|'''A x equal to b'''  
  
Line 75: Line 74:
 
|-
 
|-
  
|01.08
+
|01:08
  
 
|with '''m''' equations and  
 
|with '''m''' equations and  
Line 81: Line 80:
 
|-
 
|-
  
|01.10
+
|01:10
  
 
|'''n''' unknowns  
 
|'''n''' unknowns  
Line 87: Line 86:
 
|-
 
|-
  
| 01.12
+
| 01:12
  
 
|We write the coefficients of the '''variables a one''' to '''a n'''  
 
|We write the coefficients of the '''variables a one''' to '''a n'''  
Line 93: Line 92:
 
|-
 
|-
  
| 01.16
+
| 01:16
 
||along with the '''constants b one''' to  '''b n ''' of the system of equations  
 
||along with the '''constants b one''' to  '''b n ''' of the system of equations  
  
 
|-
 
|-
  
| 01.22
+
| 01:22
 
|| in one '''matrix''' called the '''augmented matrix'''  
 
|| in one '''matrix''' called the '''augmented matrix'''  
  
 
|-
 
|-
  
|01.27
+
|01:27
  
 
|| How do we convert the '''augmented matrix''' to an '''upper triangular form matrix?'''
 
|| How do we convert the '''augmented matrix''' to an '''upper triangular form matrix?'''
 
|-
 
|-
  
|01.33
+
|01:33
  
 
| We do so by performing row wise manipulation of the '''matrix.'''  
 
| We do so by performing row wise manipulation of the '''matrix.'''  
Line 114: Line 113:
  
 
|-
 
|-
|01.40
+
|01:40
 
|Let us solve this system of equations using '''Gaussian elimination method'''
 
|Let us solve this system of equations using '''Gaussian elimination method'''
  
Line 120: Line 119:
 
|-
 
|-
  
|01.45
+
|01:45
  
 
|Before we solve the system, let us go through the code for '''Gaussian elimination method.'''  
 
|Before we solve the system, let us go through the code for '''Gaussian elimination method.'''  
 
|-
 
|-
  
|01.52
+
|01:52
  
 
|| The first line of the code is '''format e comma twenty.'''
 
|| The first line of the code is '''format e comma twenty.'''
  
 
|-
 
|-
|01.58
+
|01:58
 
|This defines how many digits should be displayed in the answer.  
 
|This defines how many digits should be displayed in the answer.  
  
  
 
|-
 
|-
| 02.04
+
| 02:04
 
|The letter 'e' within single quotes denotes that the answer should be displayed in '''scientific notation'''  
 
|The letter 'e' within single quotes denotes that the answer should be displayed in '''scientific notation'''  
  
Line 141: Line 140:
 
|-
 
|-
  
| 02.12
+
| 02:12
 
||The number '''twenty''' is the number of digits that should be displayed.  
 
||The number '''twenty''' is the number of digits that should be displayed.  
  
 
|-
 
|-
  
|02.17
+
|02:17
  
 
||The command '''funcprot''' is used to let '''Scilab''' know what to do when variables are redefined.   
 
||The command '''funcprot''' is used to let '''Scilab''' know what to do when variables are redefined.   
Line 152: Line 151:
 
|-
 
|-
  
|02.26
+
|02:26
  
  
Line 159: Line 158:
 
|-
 
|-
  
|02.33
+
|02:33
  
 
| Other arguments are used to issue warnings or errors if the variables are redefined.  
 
| Other arguments are used to issue warnings or errors if the variables are redefined.  
Line 165: Line 164:
 
|-
 
|-
  
| 02.40
+
| 02:40
  
 
|| Next we use the '''input''' function.  
 
|| Next we use the '''input''' function.  
  
 
|-
 
|-
| 02.43
+
| 02:43
 
| It will display a message to the user and get the values of '''A''' and '''B''' matrices.   
 
| It will display a message to the user and get the values of '''A''' and '''B''' matrices.   
  
 
|-
 
|-
|02.51
+
|02:51
 
| The message should be placed within '''double quotes.'''  
 
| The message should be placed within '''double quotes.'''  
  
 
|-
 
|-
|02.55
+
|02:55
 
| The matrices that the user enters, will be stored in the variables '''A''' and '''b.'''   
 
| The matrices that the user enters, will be stored in the variables '''A''' and '''b.'''   
  
 
|-
 
|-
| 03.02
+
| 03:02
 
| Here '''A''' is the '''coefficient matrix''' and '''b''' is the right-hand-side matrix or the '''constants matrix.'''  
 
| Here '''A''' is the '''coefficient matrix''' and '''b''' is the right-hand-side matrix or the '''constants matrix.'''  
  
 
|-
 
|-
| 03.11
+
| 03:11
 
|Then we define the function '''naive gaussian elimination.'''
 
|Then we define the function '''naive gaussian elimination.'''
  
Line 192: Line 191:
  
 
|-
 
|-
| 03.15
+
| 03:15
 
|And we state that '''A''' and '''b''' are the '''arguments''' of the function '''naive gaussian elimination.'''  
 
|And we state that '''A''' and '''b''' are the '''arguments''' of the function '''naive gaussian elimination.'''  
  
  
 
|-
 
|-
| 03.22
+
| 03:22
 
|We store the output in variable '''x.'''  
 
|We store the output in variable '''x.'''  
  
 
|-
 
|-
|03.27
+
|03:27
 
| Then we find the size of matrices  '''A''' and '''b''' using the ''' size''' command.  
 
| Then we find the size of matrices  '''A''' and '''b''' using the ''' size''' command.  
  
 
|-
 
|-
| 03.34
+
| 03:34
 
| Since they are two dimensional matrices, we use '''n''' and '''n one''' to store the size of matrix '''A.'''
 
| Since they are two dimensional matrices, we use '''n''' and '''n one''' to store the size of matrix '''A.'''
  
 
|-
 
|-
  
| 03.42
+
| 03:42
  
 
|Similarly we can use '''m one''' and '''p''' for matrix '''b.'''  
 
|Similarly we can use '''m one''' and '''p''' for matrix '''b.'''  
Line 218: Line 217:
 
|-
 
|-
  
| 03.48
+
| 03:48
 
|| Then we have to determine if the matrices are compatible with each other and  
 
|| Then we have to determine if the matrices are compatible with each other and  
  
Line 224: Line 223:
 
|-
 
|-
  
|03.53
+
|03:53
  
 
||if '''A''' is a '''square matrix.'''  
 
||if '''A''' is a '''square matrix.'''  
Line 230: Line 229:
 
|-
 
|-
  
| 03.57
+
| 03:57
  
 
| If '''n''' and '''n one''' are not equal, then we display a message that '''Matrix A must be square.'''  
 
| If '''n''' and '''n one''' are not equal, then we display a message that '''Matrix A must be square.'''  
Line 237: Line 236:
 
|-
 
|-
  
| 04.05
+
| 04:05
  
 
| If '''n''' and '''m''' one are not equal, we display a message  
 
| If '''n''' and '''m''' one are not equal, we display a message  
Line 243: Line 242:
  
 
|-
 
|-
|04.10
+
|04:10
 
| '''incompatible dimension of A and b.'''  
 
| '''incompatible dimension of A and b.'''  
  
Line 250: Line 249:
 
|-
 
|-
  
| 04.15
+
| 04:15
  
 
| If the matrices are compatible, we place matrices '''A''' and '''b''' in one matrix, '''C.'''  
 
| If the matrices are compatible, we place matrices '''A''' and '''b''' in one matrix, '''C.'''  
Line 257: Line 256:
 
|-
 
|-
  
|04.23
+
|04:23
  
 
||This matrix '''C''' is called '''augmented matrix. '''
 
||This matrix '''C''' is called '''augmented matrix. '''
Line 264: Line 263:
 
|-
 
|-
  
|04.28
+
|04:28
  
 
|The next block of code performs '''forward elimination.'''  
 
|The next block of code performs '''forward elimination.'''  
Line 270: Line 269:
 
|-
 
|-
  
| 04.32
+
| 04:32
  
 
| This code converts the '''augmented matrix to upper triangular matrix''' form.  
 
| This code converts the '''augmented matrix to upper triangular matrix''' form.  
Line 278: Line 277:
 
|-
 
|-
  
| 04.39
+
| 04:39
  
 
|Finally, we perform '''back substitution.'''  
 
|Finally, we perform '''back substitution.'''  
Line 286: Line 285:
 
|-
 
|-
  
| 04.42
+
| 04:42
  
 
| Once the '''upper triangular matrix''' is obtained, we take the last row and find the value of the variable in that row.  
 
| Once the '''upper triangular matrix''' is obtained, we take the last row and find the value of the variable in that row.  
Line 292: Line 291:
 
|-
 
|-
  
| 04.52
+
| 04:52
  
 
| Then once one variable is solved, we take this variable to solve the other variables.  
 
| Then once one variable is solved, we take this variable to solve the other variables.  
Line 299: Line 298:
 
|-
 
|-
  
| 04.59
+
| 04:59
  
 
||Thus the system of '''linear equations''' is solved.  
 
||Thus the system of '''linear equations''' is solved.  
Line 307: Line 306:
 
|-
 
|-
  
| 05.03
+
| 05:03
  
 
||Let us save and execute the file.  
 
||Let us save and execute the file.  
 
|-
 
|-
  
| 05.06
+
| 05:06
  
 
||Switch to '''Scilab console''' to solve the example.  
 
||Switch to '''Scilab console''' to solve the example.  
Line 318: Line 317:
 
|-
 
|-
  
| 05.10
+
| 05:10
  
 
|On the '''console,''' we have a prompt to enter the value of the '''coefficient matrix.'''  
 
|On the '''console,''' we have a prompt to enter the value of the '''coefficient matrix.'''  
Line 325: Line 324:
 
|-
 
|-
  
| 05.17
+
| 05:17
  
 
|So we enter the values of '''matrix A.'''  
 
|So we enter the values of '''matrix A.'''  
Line 332: Line 331:
 
|-
 
|-
  
|05.20
+
|05:20
  
 
|Type '''square bracket three point four one space one point two three space minus one point zero nine semi colon '''
 
|Type '''square bracket three point four one space one point two three space minus one point zero nine semi colon '''
Line 340: Line 339:
 
|-
 
|-
  
|05.33
+
|05:33
  
 
| '''two point seven one space two point one four space one point two nine semi colon '''
 
| '''two point seven one space two point one four space one point two nine semi colon '''
Line 349: Line 348:
 
|-
 
|-
  
| 05.41
+
| 05:41
  
 
| '''one point eight nine space minus one point nine one space minus one point eight nine close square bracket.'''  
 
| '''one point eight nine space minus one point nine one space minus one point eight nine close square bracket.'''  
Line 358: Line 357:
 
|-
 
|-
  
|05.53
+
|05:53
  
 
||Press '''Enter'''  
 
||Press '''Enter'''  
Line 366: Line 365:
 
|-
 
|-
  
| 05.54
+
| 05:54
  
 
| The next prompt is for '''matrix b.'''  
 
| The next prompt is for '''matrix b.'''  
Line 372: Line 371:
 
|-
 
|-
  
| 05.57
+
| 05:57
  
 
|So we type  
 
|So we type  
Line 378: Line 377:
 
|-
 
|-
  
| 05.58
+
| 05:58
  
 
| '''open square bracket four point seven two semi colon three point one semi colon two point nine one close square bracket. '''
 
| '''open square bracket four point seven two semi colon three point one semi colon two point nine one close square bracket. '''
Line 385: Line 384:
 
|-
 
|-
  
| 06.10
+
| 06:10
  
 
|Press '''Enter'''  
 
|Press '''Enter'''  
Line 392: Line 391:
 
|-
 
|-
  
| 06.13
+
| 06:13
  
 
| Then we call the function by typing  
 
| Then we call the function by typing  
Line 399: Line 398:
 
|-
 
|-
  
| 06.16
+
| 06:16
  
 
| '''naive gaussian elimination open paranthesis A comma b close paranthesis '''
 
| '''naive gaussian elimination open paranthesis A comma b close paranthesis '''
Line 408: Line 407:
 
|-
 
|-
  
| 06.24
+
| 06:24
  
 
| Press '''Enter'''
 
| Press '''Enter'''
Line 415: Line 414:
  
 
|-
 
|-
| 06.26
+
| 06:26
 
| The solution to the system of linear equations is shown on '''Scilab console.'''  
 
| The solution to the system of linear equations is shown on '''Scilab console.'''  
  
 
|-
 
|-
| 06.32
+
| 06:32
 
|Next we shall study the '''Gauss- Jordan method.'''  
 
|Next we shall study the '''Gauss- Jordan method.'''  
  
 
|-
 
|-
  
| 06.36
+
| 06:36
  
 
| In '''Gauss – Jordan Method'''
 
| In '''Gauss – Jordan Method'''
Line 430: Line 429:
 
|-
 
|-
  
| 06.38
+
| 06:38
  
 
| The first step is to form the '''augmented matrix.'''  
 
| The first step is to form the '''augmented matrix.'''  
Line 436: Line 435:
 
|-
 
|-
  
| 06.42
+
| 06:42
  
 
| To do this place the coefficient '''matrix A''' and the right hand side '''matrix b''' together in one '''matrix.'''  
 
| To do this place the coefficient '''matrix A''' and the right hand side '''matrix b''' together in one '''matrix.'''  
Line 442: Line 441:
 
|-
 
|-
  
| 06.50
+
| 06:50
  
 
| Then we perform '''row operations''' to convert '''matrix A '''to diagonal form.  
 
| Then we perform '''row operations''' to convert '''matrix A '''to diagonal form.  
Line 448: Line 447:
 
|-
 
|-
  
| 06.56
+
| 06:56
  
 
| In diagonal form, only the elements '''a i i ''' are non-zero. Rest of the elements are zero.  
 
| In diagonal form, only the elements '''a i i ''' are non-zero. Rest of the elements are zero.  
Line 455: Line 454:
 
|-
 
|-
  
| 07.05
+
| 07:05
  
 
| Then we divide the diagonal element and corresponding element of right hand side element, by the diagonal element.  
 
| Then we divide the diagonal element and corresponding element of right hand side element, by the diagonal element.  
Line 461: Line 460:
 
|-
 
|-
  
| 07.14
+
| 07:14
  
 
| We do this to get '''diagonal element''' equal to one.  
 
| We do this to get '''diagonal element''' equal to one.  
Line 467: Line 466:
 
|-
 
|-
  
| 07.19
+
| 07:19
  
 
| The resulting value of the elements of each row of the right hand side matrix gives the value of each variable.  
 
| The resulting value of the elements of each row of the right hand side matrix gives the value of each variable.  
Line 473: Line 472:
 
|-
 
|-
  
| 07.27
+
| 07:27
  
 
|Let us solve this example using '''Gauss- Jordan Method.'''  
 
|Let us solve this example using '''Gauss- Jordan Method.'''  
Line 479: Line 478:
 
|-
 
|-
  
| 07.33
+
| 07:33
  
 
|Let us look at the code first.  
 
|Let us look at the code first.  
Line 485: Line 484:
 
|-
 
|-
  
| 07.36
+
| 07:36
  
 
|The first line of the code uses '''format function''' to specify the format of the displayed answers.  
 
|The first line of the code uses '''format function''' to specify the format of the displayed answers.  
Line 491: Line 490:
 
|-
 
|-
  
| 07.44
+
| 07:44
  
 
|The parameter e specifies the answer should be in '''scientific notation.'''  
 
|The parameter e specifies the answer should be in '''scientific notation.'''  
Line 497: Line 496:
 
|-
 
|-
  
| 07.49
+
| 07:49
  
 
|'''Twenty (20)''' denotes that only '''twenty digits''' should be displayed.  
 
|'''Twenty (20)''' denotes that only '''twenty digits''' should be displayed.  
Line 503: Line 502:
 
|-
 
|-
  
| 07.55
+
| 07:55
  
 
|Then we get the '''A''' and '''b matrix''' using the '''input function. '''
 
|Then we get the '''A''' and '''b matrix''' using the '''input function. '''
Line 509: Line 508:
 
|-
 
|-
  
| 08.00
+
| 08:00
  
 
|We define the function '''Gauss Jordan Elimination''' with input arguments '''A''' and '''b''' and output argument x.
 
|We define the function '''Gauss Jordan Elimination''' with input arguments '''A''' and '''b''' and output argument x.
Line 515: Line 514:
 
|-
 
|-
  
| 08.11
+
| 08:11
 
|We get the size of '''matrix A''' and store it in '''m''' and '''n'''
 
|We get the size of '''matrix A''' and store it in '''m''' and '''n'''
  
 
|-
 
|-
  
| 08.17
+
| 08:17
  
 
|Similarly, we get the size of '''matrix b''' and store it in '''r''' and '''s'''
 
|Similarly, we get the size of '''matrix b''' and store it in '''r''' and '''s'''
Line 526: Line 525:
 
|-
 
|-
  
| 08.23
+
| 08:23
  
 
|If the sizes of '''A''' and '''b''' are not compatible, we display an error on the '''console''' using '''error function.'''  
 
|If the sizes of '''A''' and '''b''' are not compatible, we display an error on the '''console''' using '''error function.'''  
Line 532: Line 531:
 
|-
 
|-
  
| 08.33
+
| 08:33
  
 
|Then we perform '''row operations''' to get diagonal form of the '''matrix.'''  
 
|Then we perform '''row operations''' to get diagonal form of the '''matrix.'''  
Line 538: Line 537:
 
|-
 
|-
  
| 08.38
+
| 08:38
  
 
|Here '''pivot''' refers to the first non-zero element of a '''column.'''  
 
|Here '''pivot''' refers to the first non-zero element of a '''column.'''  
Line 544: Line 543:
 
|-
 
|-
  
| 08.45
+
| 08:45
  
 
|Then we create a '''matrix''' of zeros called '''x''' with '''m''' rows and ''' s columns.'''  
 
|Then we create a '''matrix''' of zeros called '''x''' with '''m''' rows and ''' s columns.'''  
Line 550: Line 549:
 
|-
 
|-
  
| 08.52
+
| 08:52
  
 
|Once we have the diagonal form,  
 
|Once we have the diagonal form,  
Line 556: Line 555:
 
|-
 
|-
  
| 08.54
+
| 08:54
  
 
|we divide the right hand side part of '''augmented matrix'''  by the corresponding '''diagonal element to get the value of each variable.'''  
 
|we divide the right hand side part of '''augmented matrix'''  by the corresponding '''diagonal element to get the value of each variable.'''  
Line 563: Line 562:
 
|-
 
|-
  
| 09.04
+
| 09:04
  
 
|We store the value of each variable in '''x.'''
 
|We store the value of each variable in '''x.'''
Line 569: Line 568:
 
|-
 
|-
  
| 09.08
+
| 09:08
  
 
|Then we return the value of '''x.'''
 
|Then we return the value of '''x.'''
Line 575: Line 574:
 
|-
 
|-
  
| 09.11
+
| 09:11
  
 
|Finally, we '''end''' the function.  
 
|Finally, we '''end''' the function.  
Line 581: Line 580:
 
|-
 
|-
  
| 09.13
+
| 09:13
  
 
|Now let us save and execute the function.  
 
|Now let us save and execute the function.  
Line 587: Line 586:
 
|-
 
|-
  
| 09.18
+
| 09:18
  
 
|The prompt requires us to enter the value of '''matrix A.'''  
 
|The prompt requires us to enter the value of '''matrix A.'''  
Line 593: Line 592:
 
|-
 
|-
  
| 09.22
+
| 09:22
  
 
|So we type  
 
|So we type  
Line 599: Line 598:
 
|-
 
|-
  
| 09.23
+
| 09:23
  
 
|'''open square bracket zero point seven comma one seven two five semi colon '''
 
|'''open square bracket zero point seven comma one seven two five semi colon '''
Line 606: Line 605:
 
|-
 
|-
  
| 09.31
+
| 09:31
  
 
|'''zero point four three five two comma minus five point four three three close square bracket.'''
 
|'''zero point four three five two comma minus five point four three three close square bracket.'''
Line 612: Line 611:
 
|-
 
|-
  
| 09.41
+
| 09:41
  
 
|Press '''Enter'''  
 
|Press '''Enter'''  
Line 619: Line 618:
 
|-
 
|-
  
| 09.43
+
| 09:43
  
 
|The next prompt is for '''vector b. '''
 
|The next prompt is for '''vector b. '''
Line 625: Line 624:
 
|-
 
|-
  
| 09.45
+
| 09:45
  
 
|So we type '''open squre bracket one seven three nine semi colon '''
 
|So we type '''open squre bracket one seven three nine semi colon '''
Line 633: Line 632:
 
|-
 
|-
  
| 09.51
+
| 09:51
  
 
|'''three point two seven one close square bracket'''  
 
|'''three point two seven one close square bracket'''  
Line 640: Line 639:
 
|-
 
|-
  
| 09.55
+
| 09:55
  
 
|Press '''Enter '''
 
|Press '''Enter '''
Line 647: Line 646:
 
|-
 
|-
  
| 09.58
+
| 09:58
  
 
|Then we call the function by typing  
 
|Then we call the function by typing  
Line 653: Line 652:
 
|-
 
|-
  
| 10.01
+
| 10:01
  
 
|'''Gauss Jordan Elimination open paranthesis A comma b close paranthesis '''
 
|'''Gauss Jordan Elimination open paranthesis A comma b close paranthesis '''
Line 660: Line 659:
 
|-
 
|-
  
| 10.08
+
| 10:08
  
 
|Press '''Enter'''  
 
|Press '''Enter'''  
Line 667: Line 666:
 
|-
 
|-
  
| 10.10
+
| 10:10
  
 
|The values of '''x one''' and '''x two''' are shown on the '''console. '''
 
|The values of '''x one''' and '''x two''' are shown on the '''console. '''
Line 673: Line 672:
 
|-
 
|-
  
| 10.15
+
| 10:15
  
 
|Let us summarize this tutorial.  
 
|Let us summarize this tutorial.  
Line 679: Line 678:
 
|-
 
|-
  
| 10.18
+
| 10:18
  
 
|In this tutorial, we have learnt to:  
 
|In this tutorial, we have learnt to:  
Line 686: Line 685:
 
|-
 
|-
  
| 10.21
+
| 10:21
  
 
|Develop '''Scilab''' code for solving system of '''linear equations'''  
 
|Develop '''Scilab''' code for solving system of '''linear equations'''  
  
 
|-
 
|-
|10.25
+
|10:25
  
 
| Find the value of the unknown variables of a system of '''linear equations'''  
 
| Find the value of the unknown variables of a system of '''linear equations'''  
  
 
|-
 
|-
|10.32
+
|10:32
 
| Watch the video available at the link shown below  
 
| Watch the video available at the link shown below  
  
 
|-
 
|-
  
| 10.35
+
| 10:35
  
 
| It summarises the Spoken Tutorial project  
 
| It summarises the Spoken Tutorial project  
Line 709: Line 708:
 
|-
 
|-
  
|10.38
+
|10:38
  
 
||If you do not have good bandwidth, you can download and watch it  
 
||If you do not have good bandwidth, you can download and watch it  
Line 715: Line 714:
 
|-
 
|-
  
|10.43
+
|10:43
  
 
||The spoken tutorial project Team
 
||The spoken tutorial project Team
Line 721: Line 720:
 
|-
 
|-
  
|10.45
+
|10:45
  
 
||Conducts workshops using spoken tutorials  
 
||Conducts workshops using spoken tutorials  
Line 728: Line 727:
 
|-
 
|-
  
|10.48
+
|10:48
  
 
||Gives certificates to those who pass an online test  
 
||Gives certificates to those who pass an online test  
Line 735: Line 734:
 
|-
 
|-
  
|10.52
+
|10:52
  
 
||For more details, please write to conatct@spoken-tutorial.org  
 
||For more details, please write to conatct@spoken-tutorial.org  
Line 742: Line 741:
 
|-
 
|-
  
|10.59
+
|10:59
  
 
|Spoken Tutorial Project is a part of the Talk to a Teacher project  
 
|Spoken Tutorial Project is a part of the Talk to a Teacher project  
Line 750: Line 749:
 
|-
 
|-
  
| 11.03
+
| 11:03
  
 
| It is supported by the National Mission on Eduction through ICT, MHRD, Government of India.  
 
| It is supported by the National Mission on Eduction through ICT, MHRD, Government of India.  
 
|-
 
|-
  
| 11.10
+
| 11:10
  
 
|More information on this mission is available at  http://spoken-tutorial.org/NMEICT-Intro
 
|More information on this mission is available at  http://spoken-tutorial.org/NMEICT-Intro
Line 761: Line 760:
 
|-
 
|-
  
| 11.21
+
| 11:21
  
 
|This is Ashwini Patil signing off.
 
|This is Ashwini Patil signing off.
Line 767: Line 766:
 
|-
 
|-
  
|11.23
+
|11:23
  
 
| Thank you for joining.
 
| Thank you for joining.

Revision as of 17:54, 10 July 2014

Time Narration
00:01 Dear Friends,
00:02 Welcome to the spoken tutorial on “Solving System of Linear Equations using Gauss Elimination and Gauss-Jordan Methods”


00:12. At the end of this tutorial, you will learn how to:
00:15 Solve system of linear equations using Scilab
00:20 Develop Scilab code to solve linear equations


00:25 To record this tutorial, I am using
00:27 Ubuntu 12.04 as the operating system


00:31 with Scilab 5.3.3 version
00:36 To practise this tutorial, a learner should have basic knowledge of Scilab
00:40 and should know how to solve Linear Equations.
00:45 To learn Scilab, please refer to the relevant tutorials available on the Spoken Tutorial website.
00:52 A system of linear equations is a
00:55 Finite collection of linear equations of the same set of variables
01:00 Let us study Gauss elimination method
01:04 Given a system of equations
01:06 A x equal to b


01:08 with m equations and
01:10 n unknowns
01:12 We write the coefficients of the variables a one to a n
01:16 along with the constants b one to b n of the system of equations
01:22 in one matrix called the augmented matrix
01:27 How do we convert the augmented matrix to an upper triangular form matrix?
01:33 We do so by performing row wise manipulation of the matrix.


01:40 Let us solve this system of equations using Gaussian elimination method


01:45 Before we solve the system, let us go through the code for Gaussian elimination method.
01:52 The first line of the code is format e comma twenty.
01:58 This defines how many digits should be displayed in the answer.


02:04 The letter 'e' within single quotes denotes that the answer should be displayed in scientific notation


02:12 The number twenty is the number of digits that should be displayed.
02:17 The command funcprot is used to let Scilab know what to do when variables are redefined.
02:26


The argument zero specifies that Scilab need not do anything if the variables are redefined.
02:33 Other arguments are used to issue warnings or errors if the variables are redefined.
02:40 Next we use the input function.
02:43 It will display a message to the user and get the values of A and B matrices.
02:51 The message should be placed within double quotes.
02:55 The matrices that the user enters, will be stored in the variables A and b.
03:02 Here A is the coefficient matrix and b is the right-hand-side matrix or the constants matrix.
03:11 Then we define the function naive gaussian elimination.


03:15 And we state that A and b are the arguments of the function naive gaussian elimination.


03:22 We store the output in variable x.
03:27 Then we find the size of matrices A and b using the size command.
03:34 Since they are two dimensional matrices, we use n and n one to store the size of matrix A.
03:42 Similarly we can use m one and p for matrix b.


03:48 Then we have to determine if the matrices are compatible with each other and


03:53 if A is a square matrix.
03:57 If n and n one are not equal, then we display a message that Matrix A must be square.


04:05 If n and m one are not equal, we display a message


04:10 incompatible dimension of A and b.


04:15 If the matrices are compatible, we place matrices A and b in one matrix, C.


04:23 This matrix C is called augmented matrix.


04:28 The next block of code performs forward elimination.
04:32 This code converts the augmented matrix to upper triangular matrix form.


04:39 Finally, we perform back substitution.


04:42 Once the upper triangular matrix is obtained, we take the last row and find the value of the variable in that row.
04:52 Then once one variable is solved, we take this variable to solve the other variables.


04:59 Thus the system of linear equations is solved.


05:03 Let us save and execute the file.
05:06 Switch to Scilab console to solve the example.
05:10 On the console, we have a prompt to enter the value of the coefficient matrix.


05:17 So we enter the values of matrix A.


05:20 Type square bracket three point four one space one point two three space minus one point zero nine semi colon


05:33 two point seven one space two point one four space one point two nine semi colon



05:41 one point eight nine space minus one point nine one space minus one point eight nine close square bracket.



05:53 Press Enter


05:54 The next prompt is for matrix b.
05:57 So we type
05:58 open square bracket four point seven two semi colon three point one semi colon two point nine one close square bracket.


06:10 Press Enter


06:13 Then we call the function by typing


06:16 naive gaussian elimination open paranthesis A comma b close paranthesis



06:24 Press Enter


06:26 The solution to the system of linear equations is shown on Scilab console.
06:32 Next we shall study the Gauss- Jordan method.
06:36 In Gauss – Jordan Method
06:38 The first step is to form the augmented matrix.
06:42 To do this place the coefficient matrix A and the right hand side matrix b together in one matrix.
06:50 Then we perform row operations to convert matrix A to diagonal form.
06:56 In diagonal form, only the elements a i i are non-zero. Rest of the elements are zero.


07:05 Then we divide the diagonal element and corresponding element of right hand side element, by the diagonal element.
07:14 We do this to get diagonal element equal to one.
07:19 The resulting value of the elements of each row of the right hand side matrix gives the value of each variable.
07:27 Let us solve this example using Gauss- Jordan Method.
07:33 Let us look at the code first.
07:36 The first line of the code uses format function to specify the format of the displayed answers.
07:44 The parameter e specifies the answer should be in scientific notation.
07:49 Twenty (20) denotes that only twenty digits should be displayed.
07:55 Then we get the A and b matrix using the input function.
08:00 We define the function Gauss Jordan Elimination with input arguments A and b and output argument x.
08:11 We get the size of matrix A and store it in m and n
08:17 Similarly, we get the size of matrix b and store it in r and s
08:23 If the sizes of A and b are not compatible, we display an error on the console using error function.
08:33 Then we perform row operations to get diagonal form of the matrix.
08:38 Here pivot refers to the first non-zero element of a column.
08:45 Then we create a matrix of zeros called x with m rows and s columns.
08:52 Once we have the diagonal form,
08:54 we divide the right hand side part of augmented matrix by the corresponding diagonal element to get the value of each variable.


09:04 We store the value of each variable in x.
09:08 Then we return the value of x.
09:11 Finally, we end the function.
09:13 Now let us save and execute the function.
09:18 The prompt requires us to enter the value of matrix A.
09:22 So we type
09:23 open square bracket zero point seven comma one seven two five semi colon


09:31 zero point four three five two comma minus five point four three three close square bracket.
09:41 Press Enter


09:43 The next prompt is for vector b.
09:45 So we type open squre bracket one seven three nine semi colon


09:51 three point two seven one close square bracket


09:55 Press Enter


09:58 Then we call the function by typing
10:01 Gauss Jordan Elimination open paranthesis A comma b close paranthesis


10:08 Press Enter


10:10 The values of x one and x two are shown on the console.
10:15 Let us summarize this tutorial.
10:18 In this tutorial, we have learnt to:


10:21 Develop Scilab code for solving system of linear equations
10:25 Find the value of the unknown variables of a system of linear equations
10:32 Watch the video available at the link shown below
10:35 It summarises the Spoken Tutorial project


10:38 If you do not have good bandwidth, you can download and watch it
10:43 The spoken tutorial project Team
10:45 Conducts workshops using spoken tutorials


10:48 Gives certificates to those who pass an online test


10:52 For more details, please write to conatct@spoken-tutorial.org


10:59 Spoken Tutorial Project is a part of the Talk to a Teacher project


11:03 It is supported by the National Mission on Eduction through ICT, MHRD, Government of India.
11:10 More information on this mission is available at http://spoken-tutorial.org/NMEICT-Intro
11:21 This is Ashwini Patil signing off.
11:23 Thank you for joining.

Contributors and Content Editors

Gaurav, PoojaMoolya, Sandhya.np14