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

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 10: Line 10:
 
|-
 
|-
 
| 00:02
 
| 00:02
| Welcome to the Spoken Tutorial on '''“Solving System of Linear Equations using Iterative Methods” '''
+
| Welcome to the Spoken Tutorial on '''Solving System of Linear Equations using Iterative Methods'''.
  
 
|-
 
|-
Line 22: Line 22:
 
|-
 
|-
 
|00:18
 
|00:18
|Develop '''Scilab code''' to solve '''linear equations'''
+
|Develop '''Scilab code''' to solve '''linear equations'''.
  
 
|-
 
|-
Line 31: Line 31:
 
|00:25
 
|00:25
 
|'''Ubuntu 12.04''' as the operating system  
 
|'''Ubuntu 12.04''' as the operating system  
 
  
 
|-
 
|-
 
| 00:28
 
| 00:28
|and '''Scilab 5.3.3''' version  
+
|and '''Scilab 5.3.3''' version.
  
 
|-
 
|-
 
| 00:33
 
| 00:33
| Before practising this tutorial, a learner should have basic knowledge of  
+
| Before practicing this tutorial, a learner should have basic knowledge of  
  
 
|-
 
|-
Line 47: Line 46:
 
|-
 
|-
 
|00:39
 
|00:39
| and '''Solving Linear Equations'''  
+
| and '''solving linear equations'''.
  
 
|-
 
|-
Line 59: Line 58:
 
|-
 
|-
 
|00:56
 
|00:56
|Given a '''system of linear equations, with n equations and n unknowns'''  
+
|Given a '''system of linear equations, with n equations and n unknowns''',
  
 
|-
 
|-
 
|01:02
 
|01:02
| We rewrite the equations such that ''' x of i k plus one is equal to b i minus summation of a i j x j k from j equal to one to n divided by a i i''' where ''' i''' is from '''one to n'''   
+
| we rewrite the equations such that ''' x of i k plus one is equal to b i minus summation of a i j x j k from j equal to one to n divided by a i i''' where ''' i''' is from '''one to n'''.  
  
 
|-
 
|-
 
|01:24
 
|01:24
|We assume values for each '''x of i'''  
+
|We assume values for each '''x of i'''.
 
+
  
 
|-
 
|-
Line 86: Line 84:
 
| 01:39
 
| 01:39
  
|Let us solve this example using '''Jacobi Method'''
+
|Let us solve this example using '''Jacobi Method'''.
  
 
|-
 
|-
Line 96: Line 94:
  
 
| 01:48
 
| 01:48
|| We use '''format''' method to specify the format of the displayed answers on the '''Scilab console. '''
+
|| We use '''format''' method to specify the format of the displayed answers on the '''Scilab console.'''
  
 
|-
 
|-
Line 109: Line 107:
  
 
| And '''twenty''' specifies the number of digits to be displayed.  
 
| And '''twenty''' specifies the number of digits to be displayed.  
 
  
 
|-
 
|-
 
|02:06
 
|02:06
 
|Then we use '''input''' function to get the values for  
 
|Then we use '''input''' function to get the values for  
 
 
   
 
   
 
|-
 
|-
Line 131: Line 127:
 
|02:14
 
|02:14
 
|'''initial values matrix,'''  
 
|'''initial values matrix,'''  
 
  
 
|-
 
|-
 
| 02:17
 
| 02:17
 
|'''maximum number of iteration and'''  
 
|'''maximum number of iteration and'''  
 
  
 
|-
 
|-
  
 
| 02:19
 
| 02:19
||'''convergence tolerance'''
+
||'''convergence tolerance'''.
  
 
|-
 
|-
Line 152: Line 146:
  
 
|02:29
 
|02:29
 
  
 
| If it isn't, we use '''error function''' to display an error.  
 
| If it isn't, we use '''error function''' to display an error.  
Line 182: Line 175:
 
|-
 
|-
 
| 03:07
 
| 03:07
| '''A, b , x zero, '''
+
| '''A, b , x zero,'''
+
  
 
|-
 
|-
 
| 03:09
 
| 03:09
|'''maximum iteration and tolerance level. '''
+
|'''maximum iteration and tolerance level.'''
 
+
 
+
  
 
|-
 
|-
 
| 03:14
 
| 03:14
|Here '''x zero''' is the '''initial values matrix. '''
+
|Here '''x zero''' is the '''initial values matrix.'''
 
+
  
 
|-
 
|-
Line 212: Line 201:
  
 
|Finally we end the function.  
 
|Finally we end the function.  
 
 
  
 
|-
 
|-
Line 219: Line 206:
 
| 03:48
 
| 03:48
 
|| Let us save and execute the function.  
 
|| Let us save and execute the function.  
 
  
 
|-
 
|-
Line 231: Line 217:
 
| 03:54
 
| 03:54
 
| Let us enter the values at each prompt.  
 
| Let us enter the values at each prompt.  
 
  
 
|-
 
|-
Line 238: Line 223:
  
 
| The '''coefficient matrix A is open square bracket two space one semi colon five space seven close square bracket '''
 
| The '''coefficient matrix A is open square bracket two space one semi colon five space seven close square bracket '''
 
  
 
|-
 
|-
 
|04:08
 
|04:08
 
| Press '''Enter. '''
 
| Press '''Enter. '''
 
 
  
 
|-
 
|-
Line 251: Line 233:
  
 
| Then we type '''open square bracket eleven semicolon thirteen close square bracket'''
 
| Then we type '''open square bracket eleven semicolon thirteen close square bracket'''
 
  
 
|-
 
|-
Line 257: Line 238:
 
|04:17
 
|04:17
  
||Press '''Enter. '''
+
||Press '''Enter.'''
 
+
 
+
  
 
|-
 
|-
Line 272: Line 251:
  
 
| Press '''Enter.'''  
 
| Press '''Enter.'''  
 
 
 
  
 
|-
 
|-
Line 281: Line 257:
  
 
|The '''maximum number of iterations''' is twenty five.  
 
|The '''maximum number of iterations''' is twenty five.  
 
 
  
 
|-
 
|-
Line 294: Line 268:
 
| 04:36
 
| 04:36
  
| Let the '''convergence tolerance level be zero point zero zero zero zero one '''
+
| Let the '''convergence tolerance level be zero point zero zero zero zero one '''.
  
 
|-
 
|-
Line 300: Line 274:
 
| 04:44
 
| 04:44
  
||Press '''Enter. '''
+
||Press '''Enter.'''
 
+
  
 
|-
 
|-
Line 312: Line 285:
 
| 04:48
 
| 04:48
  
||'''Jacobi Iteration open paranthesis A comma b comma x zero comma M a x I t e r comma t o l close paranthesis '''
+
||'''Jacobi Iteration open parenthesis A comma b comma x zero comma M a x I t e r comma t o l close parenthesis'''
 
+
  
 
|-
 
|-
Line 320: Line 292:
  
 
|Press '''Enter. '''
 
|Press '''Enter. '''
 
 
  
 
|-
 
|-
Line 327: Line 297:
 
| 05:06
 
| 05:06
  
|The values for '''x one''' and '''x two''' are shown on the '''console. '''
+
|The values for '''x one''' and '''x two''' are shown on the '''console.'''
 
+
  
 
|-
 
|-
Line 341: Line 310:
  
 
| Let us now study '''Gauss Seidel method. '''
 
| Let us now study '''Gauss Seidel method. '''
 
 
  
 
|-
 
|-
Line 348: Line 315:
 
| 05:19
 
| 05:19
  
| 'Given a '''system of linear equations,''' with '''n equations''' and ''' n unknowns '''
+
| Given a '''system of linear equations''' with '''n equations''' and ''' n unknowns '''
 
+
 
+
  
 
|-
 
|-
Line 356: Line 321:
 
|05:26
 
|05:26
  
||We rewrite the equations for each unknown  
+
||we rewrite the equations for each unknown  
 
+
 
+
  
 
|-
 
|-
Line 365: Line 328:
  
 
| by subtracting the other variables and their coefficients from the corresponding right hand side element.  
 
| by subtracting the other variables and their coefficients from the corresponding right hand side element.  
 
  
 
|-
 
|-
Line 371: Line 333:
 
| 05:37
 
| 05:37
  
| Then we divide this by the '''coefficient a i i of the''' unknown variable' for that variable. '''
+
| Then we divide this by the '''coefficient a i i of the''' unknown variable' for that variable.'''
 
+
  
 
|-
 
|-
Line 379: Line 340:
  
 
|This is done for every given equation.  
 
|This is done for every given equation.  
 
  
 
|-
 
|-
Line 385: Line 345:
 
| 05:49
 
| 05:49
  
|In '''Jacobi method,''' for the computation of '''x of i k plus one,''' every element of '''x of i k''' is used except '''x of i k plus one '''
+
|In '''Jacobi method,''' for the computation of '''x of i k plus one,''' every element of '''x of i k''' is used except '''x of i k plus one '''.
 
+
 
+
  
 
|-
 
|-
Line 393: Line 351:
 
| 06:03
 
| 06:03
  
| In '''Gauss Seidel method,''' we over write the value of '''x of i k''' with '''x of i k plus one'''
+
| In '''Gauss Seidel method,''' we over write the value of '''x of i k''' with '''x of i k plus one'''.
 
+
 
+
  
 
|-
 
|-
Line 401: Line 357:
 
| 06:12
 
| 06:12
  
|Let us solve this example using '''Gauss Seidel Method'''
+
|Let us solve this example using '''Gauss Seidel Method'''.
 
+
 
+
  
 
|-
 
|-
 
| 06:17
 
| 06:17
| Let us look at the code for '''Gauss Seidel Method'''
+
| Let us look at the code for '''Gauss Seidel Method'''.
  
 
|-
 
|-
Line 442: Line 396:
  
 
| '''maximum number of iterations'''  and  
 
| '''maximum number of iterations'''  and  
 
  
 
|-
 
|-
Line 448: Line 401:
 
| 06:40
 
| 06:40
  
| '''tolerance level'''  
+
| '''tolerance level'''.
  
 
|-
 
|-
Line 454: Line 407:
 
| 06:43
 
| 06:43
  
| Then we define the function '''Gauss Seidel''' with '''input arguments A comma b comma x zero comma max iterations''' and '''tolerance level''' and output argument solution  
+
| Then we define the function '''Gauss Seidel''' with '''input arguments A comma b comma x zero comma max iterations''' and '''tolerance level''' and output argument solution.
  
 
|-
 
|-
Line 523: Line 476:
 
| 08:06
 
| 08:06
  
|Switch to '''Scilab console'''
+
|Switch to '''Scilab console'''.
  
 
|-
 
|-
Line 529: Line 482:
 
| 08:09
 
| 08:09
  
|For the first prompt, we type ''' matrix A.'''
+
|For the first prompt, we type '''matrix A.'''
  
 
|-
 
|-
Line 541: Line 494:
 
| 08:21
 
| 08:21
  
|Press '''Enter'''
+
|Press '''Enter'''.
  
 
|-
 
|-
Line 554: Line 507:
  
 
|type '''open square bracket eleven semi colon thirteen close square bracket'''
 
|type '''open square bracket eleven semi colon thirteen close square bracket'''
 
  
 
|-
 
|-
Line 561: Line 513:
  
 
|Press '''Enter. '''
 
|Press '''Enter. '''
 
  
 
|-
 
|-
Line 573: Line 524:
 
| 08:38
 
| 08:38
  
|'''open square bracket one semicolon one close square bracket'''
+
|'''open square bracket one semicolon one close square bracket''' .
  
 
|-
 
|-
Line 579: Line 530:
 
| 08:43
 
| 08:43
  
|Press '''Enter. '''
+
|Press '''Enter.'''
  
 
|-
 
|-
Line 585: Line 536:
 
| 08:45
 
| 08:45
  
|Then we specify the ''' maximum number of iterations''' to be twenty five  
+
|Then we specify the ''' maximum number of iterations''' to be twenty five.
  
 
|-
 
|-
Line 591: Line 542:
 
| 08:50
 
| 08:50
  
|Press '''Enter. '''
+
|Press '''Enter.'''
 
+
  
 
|-
 
|-
Line 598: Line 548:
 
| 08:52
 
| 08:52
  
|Let us define '''tolerance level'' to be zero point zero zero zero zero one  
+
|Let us define '''tolerance level'' to be zero point zero zero zero zero one.
 
|-
 
|-
  
 
| 08:58
 
| 08:58
  
|Press '''Enter'''  
+
|Press '''Enter'''.
 
+
  
 
|-
 
|-
Line 616: Line 565:
 
| 09:04
 
| 09:04
  
|'''G a u s s S e i d e l open paranthesis A comma b comma x zero comma M a x I t e r comma t o l close paranthesis'''
+
|'''G a u s s S e i d e l open parenthesis A comma b comma x zero comma M a x I t e r comma t o l close parenthesis'''
 
+
 
+
  
 
|-
 
|-
Line 625: Line 572:
  
 
|Press '''Enter'''.  
 
|Press '''Enter'''.  
 
  
 
|-
 
|-
Line 632: Line 578:
  
 
|The values of '''x one''' and '''x two''' are displayed.  
 
|The values of '''x one''' and '''x two''' are displayed.  
 
  
 
|-
 
|-
Line 644: Line 589:
 
| 09:37
 
| 09:37
  
|Solve this problem on your own using '''Jacobi''' and '''Gauss Seidel methods'''
+
|Solve this problem on your own using '''Jacobi''' and '''Gauss Seidel methods'''.
 
+
  
 
|-
 
|-
Line 652: Line 596:
  
 
|In this tutorial, we have learnt to:  
 
|In this tutorial, we have learnt to:  
 
  
 
|-
 
|-
Line 664: Line 607:
 
| 09:52
 
| 09:52
  
|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'''.
 
+
  
 
|-
 
|-
 
|09:58
 
|09:58
| Watch the video available at the following link
+
| Watch the video available at the following link.
  
 
|-
 
|-
Line 675: Line 617:
 
| 10:01
 
| 10:01
  
| It summarises the Spoken Tutorial project  
+
| It summarizes the Spoken Tutorial project.
 
+
 
+
  
 
|-
 
|-
Line 683: Line 623:
 
|10:04
 
|10:04
  
||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 695: Line 635:
 
|10:11
 
|10:11
  
||Conducts workshops using spoken tutorials  
+
||conducts workshops using spoken tutorials,
 
+
  
 
|-
 
|-
Line 702: Line 641:
 
|10:15
 
|10:15
  
||Gives certificates to those who pass an online test  
+
||gives certificates to those who pass an online test.
 
+
  
 
|-
 
|-
Line 709: Line 647:
 
|10:18
 
|10:18
  
||For more details, please write to contact@spoken-tutorial.org  
+
||For more details, please write to contact@spoken-tutorial.org .
 
+
  
 
|-
 
|-
Line 716: Line 653:
 
|10:25
 
|10:25
  
|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 729: Line 664:
 
| 10:37
 
| 10:37
  
|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 735: Line 670:
 
| 10:49
 
| 10:49
  
|This is Ashwini Patil signing off.
+
|This is Ashwini Patil. signing off.
  
 
|-
 
|-

Revision as of 09:11, 2 March 2015

Time Narration
00:01 Dear Friends,
00:02 Welcome to the Spoken Tutorial on Solving System of Linear Equations using Iterative Methods.
00:10 At the end of this tutorial, you will learn how to:
00:14 Solve system of linear equations using iterative methods
00:18 Develop Scilab code to solve linear equations.
00:22 To record this tutorial, I am using
00:25 Ubuntu 12.04 as the operating system
00:28 and Scilab 5.3.3 version.
00:33 Before practicing this tutorial, a learner should have basic knowledge of
00:38 Scilab
00:39 and solving linear equations.
00:42 For Scilab, please refer to the relevant tutorials available on the Spoken Tutorial website.
00:50 The first iterative method we will be studying is Jacobi method.
00:56 Given a system of linear equations, with n equations and n unknowns,
01:02 we rewrite the equations such that x of i k plus one is equal to b i minus summation of a i j x j k from j equal to one to n divided by a i i where i is from one to n.
01:24 We assume values for each x of i.
01:27 Then we substitute the values in the equations obtained in the previous step.
01:34 We continue the iteration until the solution converges.
01:39 Let us solve this example using Jacobi Method.
01:44 Let us look at the code for Jacobi Method.
01:48 We use format method to specify the format of the displayed answers on the Scilab console.
01:56 Here e denotes the answer should be in scientific notation.
02:01 And twenty specifies the number of digits to be displayed.
02:06 Then we use input function to get the values for
02:10 the matrices coefficient matrix,
02:12 right hand side matrix,
02:14 initial values matrix,
02:17 maximum number of iteration and
02:19 convergence tolerance.
02:22 Then we use size function to check if A matrix is a square matrix.
02:29 If it isn't, we use error function to display an error.
02:34 We then check if matrix A is diagonally dominant.
02:40 The first half calculates the sum of each row of the matrix.
02:45 Then it checks if twice the product of the diagonal element is greater than the sum of the elements of that row.
02:54 If it isn't, an error is displayed using error function.
03:01 Then we define the function Jacobi Iteration with input arguments
03:07 A, b , x zero,
03:09 maximum iteration and tolerance level.
03:14 Here x zero is the initial values matrix.
03:19 We check if the size of A matrix and initial values matrix are compatible with each other.
03:28 We calculate the value for x k p one and then check if the relative error is lesser than tolerance level.
03:38 If it is lesser than tolerance level, we break the iteration and the solution is returned.
03:45 Finally we end the function.
03:48 Let us save and execute the function.
03:51 Switch to Scilab console.
03:54 Let us enter the values at each prompt.
03:57 The coefficient matrix A is open square bracket two space one semi colon five space seven close square bracket
04:08 Press Enter.
04:10 Then we type open square bracket eleven semicolon thirteen close square bracket
04:17 Press Enter.
04:20 The initial values matrix is open square bracket one semi colon one close square bracket
04:28 Press Enter.
04:30 The maximum number of iterations is twenty five.
04:34 Press Enter.
04:36 Let the convergence tolerance level be zero point zero zero zero zero one .
04:44 Press Enter.
04:46 We call the function by typing
04:48 Jacobi Iteration open parenthesis A comma b comma x zero comma M a x I t e r comma t o l close parenthesis
05:04 Press Enter.
05:06 The values for x one and x two are shown on the console.
05:11 The number of iterations are also shown.
05:14 Let us now study Gauss Seidel method.
05:19 Given a system of linear equations with n equations and n unknowns
05:26 we rewrite the equations for each unknown
05:29 by subtracting the other variables and their coefficients from the corresponding right hand side element.
05:37 Then we divide this by the coefficient a i i of the unknown variable' for that variable.
05:45 This is done for every given equation.
05:49 In Jacobi method, for the computation of x of i k plus one, every element of x of i k is used except x of i k plus one .
06:03 In Gauss Seidel method, we over write the value of x of i k with x of i k plus one.
06:12 Let us solve this example using Gauss Seidel Method.
06:17 Let us look at the code for Gauss Seidel Method.
06:21 The first line specifies the format of the displayed answer on the console using format function.
06:29 Then we use input function to get the values of
06:32 coefficient matrix,
06:34 right hand side matrix,
06:36 initial values of the variables matrix,
06:38 maximum number of iterations and
06:40 tolerance level.
06:43 Then we define the function Gauss Seidel with input arguments A comma b comma x zero comma max iterations and tolerance level and output argument solution.
06:58 We check if matrix A is square and the sizes of initial vector and matrix A are compatible using size and length function.
07:10 Then we start the iterations.
07:13 We equate the initial values vector x zero to x k.
07:19 We create a matrix of zeros with the same size of x k and call it x k p one.
07:28 We solve for each equation to get the value of the unknown variable for that equation using x k p one.
07:38 At each iteration, the value of x k p one gets updated.
07:44 Also, we check if relative error is lesser than specified tolerance level.
07:50 If it is, we break the iteration.
07:54 Then equate x k p one to the variable solution.
07:59 Finally, we end the function.
08:02 Let us save and execute the function.
08:06 Switch to Scilab console.
08:09 For the first prompt, we type matrix A.
08:12 Type open square bracket two space one semi colon five space seven close square bracket
08:21 Press Enter.
08:22 For the next prompt,
08:24 type open square bracket eleven semi colon thirteen close square bracket
08:31 Press Enter.
08:33 We provide the values of initial value vector by typing
08:38 open square bracket one semicolon one close square bracket .
08:43 Press Enter.
08:45 Then we specify the maximum number of iterations to be twenty five.
08:50 Press Enter.
08:52 Let us define 'tolerance level to be zero point zero zero zero zero one.
08:58 Press Enter.
09:01 Finally we call the function by typing
09:04 G a u s s S e i d e l open parenthesis A comma b comma x zero comma M a x I t e r comma t o l close parenthesis
09:24 Press Enter.
09:26 The values of x one and x two are displayed.
09:30 The number of iterations to solve the same problem are lesser than Jacobi method.
09:37 Solve this problem on your own using Jacobi and Gauss Seidel methods.
09:43 In this tutorial, we have learnt to:
09:47 Develop Scilab code for solving system of linear equations
09:52 Find the value of the unknown variables of a system of linear equations.
09:58 Watch the video available at the following link.
10:01 It summarizes the Spoken Tutorial project.
10:04 If you do not have good bandwidth, you can download and watch it.
10:09 The spoken tutorial project Team
10:11 conducts workshops using spoken tutorials,
10:15 gives certificates to those who pass an online test.
10:18 For more details, please write to contact@spoken-tutorial.org .
10:25 Spoken Tutorial Project is a part of the Talk to a Teacher project.
10:30 It is supported by the National Mission on Eduction through ICT, MHRD, Government of India.
10:37 More information on this mission is available at http://spoken-tutorial.org/NMEICT-Intro.
10:49 This is Ashwini Patil. signing off.
10:51 Thank you for joining.

Contributors and Content Editors

Gaurav, PoojaMoolya, Pratik kamble, Sandhya.np14