Difference between revisions of "Scilab/C4/Linear-equations-Gaussian-Methods/English-timed"
From Script | Spoken-Tutorial
PoojaMoolya (Talk | contribs) (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…') |
Sandhya.np14 (Talk | contribs) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{| Border=1 | {| Border=1 | ||
− | | | + | |'''Time''' |
− | + | |'''Narration''' | |
− | + | ||
|- | |- | ||
− | | 00 | + | | 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 | + | | 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 | + | |00:15 |
|Solve system of linear equations using '''Scilab''' | |Solve system of linear equations using '''Scilab''' | ||
|- | |- | ||
− | |00 | + | |00:20 |
− | |Develop '''Scilab''' code to solve linear equations | + | |Develop '''Scilab''' code to solve linear equations. |
− | + | ||
|- | |- | ||
− | | 00 | + | | 00:25 |
|To record this tutorial, I am using | |To record this tutorial, I am using | ||
|- | |- | ||
− | |00 | + | |00:27 |
|'''Ubuntu 12.04''' as the operating system | |'''Ubuntu 12.04''' as the operating system | ||
− | |||
|- | |- | ||
− | | 00 | + | | 00:31 |
− | |with '''Scilab 5.3.3''' version | + | |with '''Scilab 5.3.3''' version. |
|- | |- | ||
− | | 00 | + | | 00:36 |
− | | To | + | | To practice this tutorial, a learner should have basic knowledge of '''Scilab''' |
|- | |- | ||
− | |00 | + | |00:40 |
|and should know how to solve '''Linear Equations.''' | |and should know how to solve '''Linear Equations.''' | ||
|- | |- | ||
− | |00 | + | |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 | + | | 00:52 |
| A system of '''linear equations''' is a | | A system of '''linear equations''' is a | ||
|- | |- | ||
− | | 00 | + | | 00:55 |
− | | | + | | finite collection of '''linear equations''' of the same set of '''variables'''. |
|- | |- | ||
− | |01 | + | |01:00 |
− | |Let us study '''Gauss elimination method''' | + | |Let us study '''Gauss elimination method'''. |
|- | |- | ||
− | |01 | + | |01:04 |
| Given a system of equations | | Given a system of equations | ||
|- | |- | ||
− | |01 | + | |01:06 |
|'''A x equal to b''' | |'''A x equal to b''' | ||
− | |||
|- | |- | ||
− | |01 | + | |01:08 |
|with '''m''' equations and | |with '''m''' equations and | ||
Line 81: | Line 72: | ||
|- | |- | ||
− | |01 | + | |01:10 |
− | |'''n''' unknowns | + | |'''n''' unknowns. |
|- | |- | ||
− | | 01 | + | | 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 84: | ||
|- | |- | ||
− | | 01 | + | | 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 | + | | 01:22 |
− | || in one '''matrix''' called the '''augmented matrix''' | + | || in one '''matrix''' called the '''augmented matrix'''. |
|- | |- | ||
− | |01 | + | |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 | + | |01:33 |
| We do so by performing row wise manipulation of the '''matrix.''' | | We do so by performing row wise manipulation of the '''matrix.''' | ||
− | |||
|- | |- | ||
− | |01 | + | |01:40 |
− | |Let us solve this system of equations using '''Gaussian elimination method''' | + | |Let us solve this system of equations using '''Gaussian elimination method'''. |
− | + | ||
|- | |- | ||
− | |01 | + | |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 | + | |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 | + | |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 | + | | 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'''. |
− | + | ||
|- | |- | ||
− | | 02 | + | | 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 | + | |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 139: | ||
|- | |- | ||
− | |02 | + | |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 159: | Line 145: | ||
|- | |- | ||
− | |02 | + | |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 151: | ||
|- | |- | ||
− | | 02 | + | | 02:40 |
|| Next we use the '''input''' function. | || Next we use the '''input''' function. | ||
|- | |- | ||
− | | 02 | + | | 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. |
|- | |- | ||
− | |02 | + | |02:51 |
| The message should be placed within '''double quotes.''' | | The message should be placed within '''double quotes.''' | ||
|- | |- | ||
− | |02 | + | |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 | + | | 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 | + | | 03:11 |
|Then we define the function '''naive gaussian elimination.''' | |Then we define the function '''naive gaussian elimination.''' | ||
− | |||
− | |||
|- | |- | ||
− | | 03 | + | | 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 | + | | 03:22 |
|We store the output in variable '''x.''' | |We store the output in variable '''x.''' | ||
|- | |- | ||
− | |03 | + | |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 | + | | 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 | + | | 03:42 |
|Similarly we can use '''m one''' and '''p''' for matrix '''b.''' | |Similarly we can use '''m one''' and '''p''' for matrix '''b.''' | ||
− | |||
− | |||
|- | |- | ||
− | | 03 | + | | 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 | ||
− | |||
|- | |- | ||
− | |03 | + | |03:53 |
||if '''A''' is a '''square matrix.''' | ||if '''A''' is a '''square matrix.''' | ||
Line 230: | Line 210: | ||
|- | |- | ||
− | | 03 | + | | 03:57 |
− | + | ||
− | + | ||
+ | | If '''n''' and '''n one''' are not equal then we display a message that '''Matrix A must be square.''' | ||
|- | |- | ||
− | | 04 | + | | 04:05 |
− | + | ||
− | + | ||
+ | | If '''n''' and '''m one''' are not equal, we display a message | ||
|- | |- | ||
− | |04 | + | |04:10 |
| '''incompatible dimension of A and b.''' | | '''incompatible dimension of A and b.''' | ||
− | |||
− | |||
|- | |- | ||
− | | 04 | + | | 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.''' | ||
− | |||
|- | |- | ||
− | |04 | + | |04:23 |
||This matrix '''C''' is called '''augmented matrix. ''' | ||This matrix '''C''' is called '''augmented matrix. ''' | ||
− | |||
|- | |- | ||
− | |04 | + | |04:28 |
|The next block of code performs '''forward elimination.''' | |The next block of code performs '''forward elimination.''' | ||
Line 270: | Line 244: | ||
|- | |- | ||
− | | 04 | + | | 04:32 |
| This code converts the '''augmented matrix to upper triangular matrix''' form. | | This code converts the '''augmented matrix to upper triangular matrix''' form. | ||
− | |||
− | |||
|- | |- | ||
− | | 04 | + | | 04:39 |
|Finally, we perform '''back substitution.''' | |Finally, we perform '''back substitution.''' | ||
− | |||
− | |||
|- | |- | ||
− | | 04 | + | | 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 262: | ||
|- | |- | ||
− | | 04 | + | | 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. | ||
− | |||
|- | |- | ||
− | | 04 | + | | 04:59 |
||Thus the system of '''linear equations''' is solved. | ||Thus the system of '''linear equations''' is solved. | ||
− | |||
− | |||
|- | |- | ||
− | | 05 | + | | 05:03 |
||Let us save and execute the file. | ||Let us save and execute the file. | ||
|- | |- | ||
− | | 05 | + | | 05:06 |
||Switch to '''Scilab console''' to solve the example. | ||Switch to '''Scilab console''' to solve the example. | ||
Line 318: | Line 285: | ||
|- | |- | ||
− | | 05 | + | | 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.''' | ||
− | |||
|- | |- | ||
− | | 05 | + | | 05:17 |
|So we enter the values of '''matrix A.''' | |So we enter the values of '''matrix A.''' | ||
− | |||
|- | |- | ||
− | |05 | + | |05:20 |
− | + | ||
− | + | ||
− | + | ||
+ | |Type: '''square bracket three point four one space one point two three space minus one point zero nine semi colon ''' | ||
|- | |- | ||
− | |05 | + | |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 ''' | ||
− | |||
− | |||
− | |||
|- | |- | ||
− | | 05 | + | | 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.''' | ||
− | |||
− | |||
− | |||
|- | |- | ||
− | |05 | + | |05:53 |
− | + | ||
− | + | ||
− | + | ||
+ | ||Press '''Enter'''. The next prompt is for '''matrix b.''' | ||
|- | |- | ||
− | | 05 | + | | 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 | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | | 06 | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
| Then we call the function by typing | | Then we call the function by typing | ||
− | |||
|- | |- | ||
− | | 06 | + | | 06:16 |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | | '''naive gaussian elimination open parenthesis A comma b close parenthesis ''' | ||
|- | |- | ||
− | | 06 | + | | 06:24 |
− | + | ||
− | + | ||
− | + | ||
+ | | Press '''Enter'''. | ||
|- | |- | ||
− | | 06 | + | | 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 | + | | 06:32 |
− | |Next we shall study the '''Gauss- Jordan method.''' | + | |Next we shall study the '''Gauss-Jordan method.''' |
|- | |- | ||
− | | 06 | + | | 06:36 |
− | | In ''' | + | | In '''Gauss–Jordan Method''', |
|- | |- | ||
− | | 06 | + | | 06:38 |
− | | | + | | the first step is to form the '''augmented matrix.''' |
|- | |- | ||
− | | 06 | + | | 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.''' |
|- | |- | ||
− | | 06 | + | | 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 383: | ||
|- | |- | ||
− | | 06 | + | | 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. | ||
− | |||
|- | |- | ||
− | | 07 | + | | 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 395: | ||
|- | |- | ||
− | | 07 | + | | 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 401: | ||
|- | |- | ||
− | | 07 | + | | 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 407: | ||
|- | |- | ||
− | | 07 | + | | 07:27 |
− | |Let us solve this example using '''Gauss- Jordan Method.''' | + | |Let us solve this example using '''Gauss-Jordan Method.''' |
|- | |- | ||
− | | 07 | + | | 07:33 |
|Let us look at the code first. | |Let us look at the code first. | ||
Line 485: | Line 419: | ||
|- | |- | ||
− | | 07 | + | | 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 425: | ||
|- | |- | ||
− | | 07 | + | | 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 431: | ||
|- | |- | ||
− | | 07 | + | | 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 437: | ||
|- | |- | ||
− | | 07 | + | | 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. |
|- | |- | ||
− | | 08 | + | | 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 449: | ||
|- | |- | ||
− | | 08 | + | | 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 | + | | 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'''. |
|- | |- | ||
− | | 08 | + | | 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 466: | ||
|- | |- | ||
− | | 08 | + | | 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 472: | ||
|- | |- | ||
− | | 08 | + | | 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 478: | ||
|- | |- | ||
− | | 08 | + | | 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.''' |
|- | |- | ||
− | | 08 | + | | 08:52 |
|Once we have the diagonal form, | |Once we have the diagonal form, | ||
Line 556: | Line 490: | ||
|- | |- | ||
− | | 08 | + | | 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 | + | | 09:04 |
|We store the value of each variable in '''x.''' | |We store the value of each variable in '''x.''' | ||
Line 569: | Line 502: | ||
|- | |- | ||
− | | 09 | + | | 09:08 |
|Then we return the value of '''x.''' | |Then we return the value of '''x.''' | ||
Line 575: | Line 508: | ||
|- | |- | ||
− | | 09 | + | | 09:11 |
|Finally, we '''end''' the function. | |Finally, we '''end''' the function. | ||
Line 581: | Line 514: | ||
|- | |- | ||
− | | 09 | + | | 09:13 |
|Now let us save and execute the function. | |Now let us save and execute the function. | ||
Line 587: | Line 520: | ||
|- | |- | ||
− | | 09 | + | | 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 526: | ||
|- | |- | ||
− | | 09 | + | | 09:22 |
− | |So we type | + | |So we type '''open square bracket zero point seven comma one seven two five semi colon''' |
|- | |- | ||
− | | 09 | + | | 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 538: | ||
|- | |- | ||
− | | 09 | + | | 09:41 |
− | + | ||
− | + | ||
+ | |Press '''Enter'''. | ||
|- | |- | ||
− | | 09 | + | | 09:43 |
|The next prompt is for '''vector b. ''' | |The next prompt is for '''vector b. ''' | ||
Line 625: | Line 550: | ||
|- | |- | ||
− | | 09 | + | | 09:45 |
− | + | ||
− | + | ||
− | + | ||
+ | |So we type '''open square bracket one seven three nine semi colon''' | ||
|- | |- | ||
− | | 09 | + | | 09:51 |
− | + | ||
− | + | ||
+ | |'''three point two seven one close square bracket'''. | ||
|- | |- | ||
− | | 09 | + | | 09:55 |
− | + | ||
− | + | ||
+ | |Press '''Enter'''. | ||
|- | |- | ||
− | | 09 | + | | 09:58 |
|Then we call the function by typing | |Then we call the function by typing | ||
Line 653: | Line 574: | ||
|- | |- | ||
− | | 10 | + | | 10:01 |
− | + | ||
− | + | ||
+ | |'''Gauss Jordan Elimination open parenthesis A comma b close parenthesis ''' | ||
|- | |- | ||
− | | 10 | + | | 10:08 |
− | + | ||
− | + | ||
+ | |Press '''Enter'''. | ||
|- | |- | ||
− | | 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 592: | ||
|- | |- | ||
− | | 10 | + | | 10:15 |
|Let us summarize this tutorial. | |Let us summarize this tutorial. | ||
Line 679: | Line 598: | ||
|- | |- | ||
− | | 10 | + | | 10:18 |
|In this tutorial, we have learnt to: | |In this tutorial, we have learnt to: | ||
− | |||
|- | |- | ||
− | | 10 | + | | 10:21 |
− | |Develop '''Scilab''' code for solving system of '''linear equations''' | + | |Develop '''Scilab''' code for solving system of '''linear equations'''. |
|- | |- | ||
− | |10 | + | |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 | + | |10:32 |
− | | Watch the video available at the link shown below | + | | Watch the video available at the link shown below. |
|- | |- | ||
− | | 10 | + | | 10:35 |
− | + | ||
− | + | ||
− | + | ||
+ | | It summarizes the Spoken Tutorial project. | ||
|- | |- | ||
− | |10 | + | |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. |
|- | |- | ||
− | |10 | + | |10:43 |
− | ||The spoken tutorial project Team | + | ||The spoken tutorial project Team: |
|- | |- | ||
− | |10 | + | |10:45 |
− | + | ||
− | + | ||
+ | ||Conducts workshops using spoken tutorials. | ||
|- | |- | ||
− | |10 | + | |10:48 |
− | + | ||
− | + | ||
+ | ||Gives certificates to those who pass an online test. | ||
|- | |- | ||
− | |10 | + | |10:52 |
− | + | ||
− | + | ||
+ | ||For more details, please write to conatct@spoken-tutorial.org. | ||
|- | |- | ||
− | |10 | + | |10:59 |
− | + | ||
− | + | ||
− | + | ||
+ | |Spoken Tutorial Project is a part of the Talk to a Teacher project. | ||
|- | |- | ||
− | | 11 | + | | 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 | + | | 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. |
|- | |- | ||
− | | 11 | + | | 11:21 |
− | |This is Ashwini Patil signing off. | + | |This is Ashwini Patil, signing off. |
|- | |- | ||
− | |11 | + | |11:23 |
| Thank you for joining. | | Thank you for joining. |
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. |