Difference between revisions of "Scilab/C4/Linear-equations-Gaussian-Methods/English-timed"
From Script | Spoken-Tutorial
Sandhya.np14 (Talk | contribs) |
|||
Line 10: | Line 10: | ||
|- | |- | ||
| 00:02 | | 00:02 | ||
− | |Welcome to the spoken tutorial on | + | |Welcome to the spoken tutorial on '''Solving System of Linear Equations using Gauss Elimination and Gauss-Jordan Methods'''. |
− | + | ||
|- | |- | ||
Line 23: | Line 22: | ||
|- | |- | ||
|00:20 | |00:20 | ||
− | |Develop '''Scilab''' code to solve linear equations | + | |Develop '''Scilab''' code to solve linear equations. |
− | + | ||
|- | |- | ||
Line 33: | Line 31: | ||
|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 | + | | To practice this tutorial, a learner should have basic knowledge of '''Scilab''' |
|- | |- | ||
Line 57: | Line 54: | ||
|- | |- | ||
| 00:55 | | 00:55 | ||
− | | | + | | 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'''. |
|- | |- | ||
Line 70: | Line 67: | ||
|01:06 | |01:06 | ||
|'''A x equal to b''' | |'''A x equal to b''' | ||
− | |||
|- | |- | ||
Line 82: | Line 78: | ||
|01:10 | |01:10 | ||
− | |'''n''' unknowns | + | |'''n''' unknowns. |
|- | |- | ||
Line 98: | Line 94: | ||
| 01:22 | | 01:22 | ||
− | || in one '''matrix''' called the '''augmented matrix''' | + | || in one '''matrix''' called the '''augmented matrix'''. |
|- | |- | ||
Line 110: | Line 106: | ||
| We do so by performing row wise manipulation of the '''matrix.''' | | We do so by performing row wise manipulation of the '''matrix.''' | ||
− | |||
|- | |- | ||
|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 131: | Line 125: | ||
|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 152: | Line 144: | ||
|02:26 | |02:26 | ||
− | |||
| The argument '''zero''' specifies that '''Scilab''' need not do anything if the variables are redefined. | | The argument '''zero''' specifies that '''Scilab''' need not do anything if the variables are redefined. | ||
Line 187: | Line 178: | ||
| 03:11 | | 03:11 | ||
|Then we define the function '''naive gaussian elimination.''' | |Then we define the function '''naive gaussian elimination.''' | ||
− | |||
− | |||
|- | |- | ||
| 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.''' | ||
− | |||
|- | |- | ||
Line 212: | Line 200: | ||
|Similarly we can use '''m one''' and '''p''' for matrix '''b.''' | |Similarly we can use '''m one''' and '''p''' for matrix '''b.''' | ||
− | |||
− | |||
|- | |- | ||
Line 219: | Line 205: | ||
| 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 232: | Line 217: | ||
| 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 239: | Line 223: | ||
| If '''n''' and '''m''' one are not equal, we display a message | | If '''n''' and '''m''' one are not equal, we display a message | ||
− | |||
|- | |- | ||
|04:10 | |04:10 | ||
| '''incompatible dimension of A and b.''' | | '''incompatible dimension of A and b.''' | ||
− | |||
− | |||
|- | |- | ||
Line 252: | Line 233: | ||
| 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 259: | Line 239: | ||
||This matrix '''C''' is called '''augmented matrix. ''' | ||This matrix '''C''' is called '''augmented matrix. ''' | ||
− | |||
|- | |- | ||
Line 272: | Line 251: | ||
| This code converts the '''augmented matrix to upper triangular matrix''' form. | | This code converts the '''augmented matrix to upper triangular matrix''' form. | ||
− | |||
− | |||
|- | |- | ||
Line 280: | Line 257: | ||
|Finally, we perform '''back substitution.''' | |Finally, we perform '''back substitution.''' | ||
− | |||
− | |||
|- | |- | ||
Line 294: | Line 269: | ||
| 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 301: | Line 275: | ||
||Thus the system of '''linear equations''' is solved. | ||Thus the system of '''linear equations''' is solved. | ||
− | |||
− | |||
|- | |- | ||
Line 320: | Line 292: | ||
|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 327: | Line 298: | ||
|So we enter the values of '''matrix A.''' | |So we enter the values of '''matrix A.''' | ||
− | |||
|- | |- | ||
Line 334: | Line 304: | ||
|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 342: | Line 310: | ||
| '''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 351: | Line 316: | ||
| '''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 359: | Line 321: | ||
|05:53 | |05:53 | ||
− | ||Press '''Enter''' | + | ||Press '''Enter'''. |
− | + | ||
− | + | ||
|- | |- | ||
Line 379: | Line 339: | ||
| 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 386: | Line 345: | ||
| 06:10 | | 06:10 | ||
− | |Press '''Enter''' | + | |Press '''Enter'''. |
− | + | ||
|- | |- | ||
Line 394: | Line 352: | ||
| Then we call the function by typing | | Then we call the function by typing | ||
− | |||
|- | |- | ||
Line 400: | Line 357: | ||
| 06:16 | | 06:16 | ||
− | | '''naive gaussian elimination open | + | | '''naive gaussian elimination open parenthesis A comma b close parenthesis ''' |
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
Line 409: | Line 363: | ||
| 06:24 | | 06:24 | ||
− | | Press '''Enter''' | + | | Press '''Enter'''. |
− | + | ||
− | + | ||
|- | |- | ||
Line 425: | Line 377: | ||
| 06:36 | | 06:36 | ||
− | | In '''Gauss – Jordan Method''' | + | | In '''Gauss – Jordan Method''', |
|- | |- | ||
Line 431: | Line 383: | ||
| 06:38 | | 06:38 | ||
− | | | + | | the first step is to form the '''augmented matrix.''' |
|- | |- | ||
Line 450: | Line 402: | ||
| 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 474: | Line 425: | ||
| 07:27 | | 07:27 | ||
− | |Let us solve this example using '''Gauss- Jordan Method.''' | + | |Let us solve this example using '''Gauss-Jordan Method.''' |
|- | |- | ||
Line 515: | Line 466: | ||
| 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'''. |
|- | |- | ||
Line 521: | Line 472: | ||
| 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 558: | Line 509: | ||
|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 600: | Line 550: | ||
| 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 613: | Line 562: | ||
| 09:41 | | 09:41 | ||
− | |Press '''Enter''' | + | |Press '''Enter'''. |
− | + | ||
|- | |- | ||
Line 626: | Line 574: | ||
| 09:45 | | 09:45 | ||
− | |So we type '''open | + | |So we type '''open square bracket one seven three nine semi colon''' |
− | + | ||
− | + | ||
|- | |- | ||
Line 634: | Line 580: | ||
| 09:51 | | 09:51 | ||
− | |'''three point two seven one close square bracket''' | + | |'''three point two seven one close square bracket'''. |
− | + | ||
|- | |- | ||
Line 641: | Line 586: | ||
| 09:55 | | 09:55 | ||
− | |Press '''Enter ''' | + | |Press '''Enter'''. |
− | + | ||
|- | |- | ||
Line 654: | Line 598: | ||
| 10:01 | | 10:01 | ||
− | |'''Gauss Jordan Elimination open | + | |'''Gauss Jordan Elimination open parenthesis A comma b close parenthesis ''' |
− | + | ||
|- | |- | ||
Line 662: | Line 605: | ||
|Press '''Enter''' | |Press '''Enter''' | ||
− | |||
|- | |- | ||
Line 681: | Line 623: | ||
|In this tutorial, we have learnt to: | |In this tutorial, we have learnt to: | ||
− | |||
|- | |- | ||
Line 696: | Line 637: | ||
|- | |- | ||
|10:32 | |10:32 | ||
− | | Watch the video available at the link shown below | + | | Watch the video available at the link shown below. |
|- | |- | ||
Line 702: | Line 643: | ||
| 10:35 | | 10:35 | ||
− | | It | + | | It summarizes the Spoken Tutorial project. |
− | + | ||
− | + | ||
|- | |- | ||
Line 710: | Line 649: | ||
|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 716: | Line 655: | ||
|10:43 | |10:43 | ||
− | ||The spoken tutorial project Team | + | ||The spoken tutorial project Team: |
|- | |- | ||
Line 722: | Line 661: | ||
|10:45 | |10:45 | ||
− | ||Conducts workshops using spoken tutorials | + | ||Conducts workshops using spoken tutorials. |
− | + | ||
|- | |- | ||
Line 729: | Line 667: | ||
|10:48 | |10:48 | ||
− | ||Gives certificates to those who pass an online test | + | ||Gives certificates to those who pass an online test. |
− | + | ||
|- | |- | ||
Line 736: | Line 673: | ||
|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 743: | Line 679: | ||
|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 756: | Line 690: | ||
| 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 762: | Line 696: | ||
| 11:21 | | 11:21 | ||
− | |This is Ashwini Patil signing off. | + | |This is Ashwini Patil, signing off. |
|- | |- |
Revision as of 17:28, 27 February 2015
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 practice 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 parenthesis A comma b close parenthesis |
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 square 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 parenthesis A comma b close parenthesis |
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 summarizes 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. |