Difference between revisions of "Scilab/C4/Linear-equations-Gaussian-Methods/English-timed"
From Script | Spoken-Tutorial
Sandhya.np14 (Talk | contribs) |
|||
(3 intermediate revisions by 2 users not shown) | |||
Line 6: | Line 6: | ||
|- | |- | ||
| 00:01 | | 00:01 | ||
− | |Dear Friends, | + | |Dear Friends, 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: | ||
Line 23: | Line 18: | ||
|- | |- | ||
|00:20 | |00:20 | ||
− | |Develop '''Scilab''' code to solve linear equations | + | |Develop '''Scilab''' code to solve linear equations. |
− | + | ||
|- | |- | ||
Line 33: | Line 27: | ||
|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 50: | ||
|- | |- | ||
| 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 63: | ||
|01:06 | |01:06 | ||
|'''A x equal to b''' | |'''A x equal to b''' | ||
− | |||
|- | |- | ||
Line 82: | Line 74: | ||
|01:10 | |01:10 | ||
− | |'''n''' unknowns | + | |'''n''' unknowns. |
|- | |- | ||
Line 93: | Line 85: | ||
| 01:16 | | 01:16 | ||
− | ||along with the '''constants b one''' to '''b | + | ||along with the '''constants b one''' to '''b m ''' of the system of equations |
|- | |- | ||
| 01:22 | | 01:22 | ||
− | || in one '''matrix''' called the '''augmented matrix''' | + | || in one '''matrix''' called the '''augmented matrix'''. |
|- | |- | ||
Line 110: | Line 102: | ||
| 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 121: | ||
|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 140: | ||
|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 170: | Line 157: | ||
|- | |- | ||
| 02:43 | | 02:43 | ||
− | | It will display a message to the user and get the values of '''A''' and ''' | + | | It will display a message to the user and get the values of '''A''' and '''b''' matrices. |
|- | |- | ||
Line 187: | Line 174: | ||
| 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 196: | ||
|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 201: | ||
| 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 231: | Line 212: | ||
| 03:57 | | 03:57 | ||
− | | If '''n''' and '''n one''' are not equal | + | | If '''n''' and '''n one''' are not equal then we display a message that '''Matrix A must be square.''' |
− | + | ||
|- | |- | ||
Line 238: | Line 218: | ||
| 04:05 | | 04:05 | ||
− | | If '''n''' and '''m''' | + | | 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 229: | ||
| 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 235: | ||
||This matrix '''C''' is called '''augmented matrix. ''' | ||This matrix '''C''' is called '''augmented matrix. ''' | ||
− | |||
|- | |- | ||
Line 272: | Line 247: | ||
| 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 253: | ||
|Finally, we perform '''back substitution.''' | |Finally, we perform '''back substitution.''' | ||
− | |||
− | |||
|- | |- | ||
Line 294: | Line 265: | ||
| 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 271: | ||
||Thus the system of '''linear equations''' is solved. | ||Thus the system of '''linear equations''' is solved. | ||
− | |||
− | |||
|- | |- | ||
Line 320: | Line 288: | ||
|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 294: | ||
|So we enter the values of '''matrix A.''' | |So we enter the values of '''matrix A.''' | ||
− | |||
|- | |- | ||
Line 333: | Line 299: | ||
|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 342: | Line 306: | ||
| '''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 312: | ||
| '''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 317: | ||
|05:53 | |05:53 | ||
− | ||Press '''Enter''' | + | ||Press '''Enter'''. The next prompt is for '''matrix b.''' |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
Line 373: | Line 323: | ||
| 05:57 | | 05:57 | ||
− | |So we type | + | |So we type '''open square bracket four point seven two semi colon three point one semi colon two point nine one close square bracket.''' |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
Line 386: | Line 329: | ||
| 06:10 | | 06:10 | ||
− | |Press '''Enter''' | + | |Press '''Enter'''. |
− | + | ||
|- | |- | ||
Line 394: | Line 336: | ||
| Then we call the function by typing | | Then we call the function by typing | ||
− | |||
|- | |- | ||
Line 400: | Line 341: | ||
| 06:16 | | 06:16 | ||
− | | '''naive gaussian elimination open | + | | '''naive gaussian elimination open parenthesis A comma b close parenthesis ''' |
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
Line 409: | Line 347: | ||
| 06:24 | | 06:24 | ||
− | | Press '''Enter''' | + | | Press '''Enter'''. |
− | + | ||
− | + | ||
|- | |- | ||
Line 419: | Line 355: | ||
|- | |- | ||
| 06:32 | | 06:32 | ||
− | |Next we shall study the '''Gauss- Jordan method.''' | + | |Next we shall study the '''Gauss-Jordan method.''' |
|- | |- | ||
Line 425: | Line 361: | ||
| 06:36 | | 06:36 | ||
− | | In ''' | + | | In '''Gauss–Jordan Method''', |
|- | |- | ||
Line 431: | Line 367: | ||
| 06:38 | | 06:38 | ||
− | | | + | | the first step is to form the '''augmented matrix.''' |
|- | |- | ||
Line 437: | Line 373: | ||
| 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 450: | Line 386: | ||
| 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 409: | ||
| 07:27 | | 07:27 | ||
− | |Let us solve this example using '''Gauss- Jordan Method.''' | + | |Let us solve this example using '''Gauss-Jordan Method.''' |
|- | |- | ||
Line 504: | Line 439: | ||
| 07:55 | | 07:55 | ||
− | |Then we get the '''A''' and '''b matrix''' using the '''input | + | |Then we get the '''A''' and '''b matrix''' using the '''input''' function. |
|- | |- | ||
Line 515: | Line 450: | ||
| 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 456: | ||
| 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 545: | Line 480: | ||
| 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 557: | Line 492: | ||
| 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 594: | Line 528: | ||
| 09:22 | | 09:22 | ||
− | |So we type | + | |So we type '''open square bracket zero point seven comma one seven two five semi colon''' |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
Line 613: | Line 540: | ||
| 09:41 | | 09:41 | ||
− | |Press '''Enter''' | + | |Press '''Enter'''. |
− | + | ||
|- | |- | ||
Line 626: | Line 552: | ||
| 09:45 | | 09:45 | ||
− | |So we type '''open | + | |So we type '''open square bracket one seven three nine semi colon''' |
− | + | ||
− | + | ||
|- | |- | ||
Line 634: | Line 558: | ||
| 09:51 | | 09:51 | ||
− | |'''three point two seven one close square bracket''' | + | |'''three point two seven one close square bracket'''. |
− | + | ||
|- | |- | ||
Line 641: | Line 564: | ||
| 09:55 | | 09:55 | ||
− | |Press '''Enter ''' | + | |Press '''Enter'''. |
− | + | ||
|- | |- | ||
Line 654: | Line 576: | ||
| 10:01 | | 10:01 | ||
− | |'''Gauss Jordan Elimination open | + | |'''Gauss Jordan Elimination open parenthesis A comma b close parenthesis ''' |
− | + | ||
|- | |- | ||
Line 661: | Line 582: | ||
| 10:08 | | 10:08 | ||
− | |Press '''Enter''' | + | |Press '''Enter'''. |
− | + | ||
|- | |- | ||
Line 681: | Line 601: | ||
|In this tutorial, we have learnt to: | |In this tutorial, we have learnt to: | ||
− | |||
|- | |- | ||
Line 687: | Line 606: | ||
| 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. |
|- | |- | ||
Line 702: | Line 621: | ||
| 10:35 | | 10:35 | ||
− | | It | + | | It summarizes the Spoken Tutorial project. |
− | + | ||
− | + | ||
|- | |- | ||
Line 710: | Line 627: | ||
|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 633: | ||
|10:43 | |10:43 | ||
− | ||The spoken tutorial project Team | + | ||The spoken tutorial project Team: |
|- | |- | ||
Line 722: | Line 639: | ||
|10:45 | |10:45 | ||
− | ||Conducts workshops using spoken tutorials | + | ||Conducts workshops using spoken tutorials. |
− | + | ||
|- | |- | ||
Line 729: | Line 645: | ||
|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 651: | ||
|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 657: | ||
|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 668: | ||
| 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 674: | ||
| 11:21 | | 11:21 | ||
− | |This is Ashwini Patil signing off. | + | |This is Ashwini Patil, signing off. |
|- | |- |
Latest revision as of 15:14, 20 November 2017
Time | Narration |
00:01 | Dear Friends, 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 m 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. The next prompt is for matrix b. |
05:57 | So we type 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 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. |