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

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with '{| Border=1 || Time || Narration |- | 00.01 |Dear Friends, |- | 00.02 | Welcome to the Spoken Tutorial on '''“Solving System of Linear Equations using Iterative Methods”…')
 
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
{| Border=1
 
{| Border=1
  
|| Time
+
|'''Time'''
 
+
|'''Narration'''
|| Narration
+
 
+
|-
+
| 00.01
+
|Dear Friends,
+
  
 
|-
 
|-
| 00.02
+
| 00:01
| Welcome to the Spoken Tutorial on '''“Solving System of Linear Equations using Iterative Methods” '''
+
|Dear Friends, Welcome to the Spoken Tutorial on '''Solving System of Linear Equations using Iterative Methods'''.
  
 
|-
 
|-
| 00.10
+
| 00:10
 
| At the end of this tutorial, you will learn how to:   
 
| At the end of this tutorial, you will learn how to:   
  
 
|-
 
|-
|00.14
+
|00:14
 
|Solve system of '''linear equations''' using '''iterative methods'''  
 
|Solve system of '''linear equations''' using '''iterative methods'''  
  
 
|-
 
|-
|00.18
+
|00:18
|Develop '''Scilab code''' to solve '''linear equations'''
+
|Develop '''Scilab code''' to solve '''linear equations'''.
  
 
|-
 
|-
| 00.22
+
| 00:22
 
|To record this tutorial, I am using  
 
|To record this tutorial, I am using  
  
 
|-
 
|-
|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  
  
 
|-
 
|-
|00.38
+
|00:38
|'''Scilab'''
+
|'''Scilab''', and '''solving linear equations'''.
  
 
|-
 
|-
|00.39
+
| 00:42
| and '''Solving Linear Equations'''
+
 
+
|-
+
| 00.42
+
 
| For '''Scilab,''' please refer to the relevant tutorials available on the '''Spoken Tutorial''' website.  
 
| For '''Scilab,''' please refer to the relevant tutorials available on the '''Spoken Tutorial''' website.  
  
 
|-
 
|-
| 00.50
+
| 00:50
 
| The first '''iterative method''' we will be studying is '''Jacobi method.'''
 
| The first '''iterative method''' we will be studying is '''Jacobi method.'''
  
 
|-
 
|-
|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'''.
 
+
  
 
|-
 
|-
  
|01.27
+
|01:27
  
 
|Then we substitute the values in the equations obtained in the previous step.
 
|Then we substitute the values in the equations obtained in the previous step.
Line 79: Line 68:
 
|-
 
|-
  
|01.34
+
|01:34
  
 
|We continue the iteration until the solution converges.  
 
|We continue the iteration until the solution converges.  
Line 85: Line 74:
 
|-
 
|-
  
| 01.39
+
| 01:39
  
|Let us solve this example using '''Jacobi Method'''
+
|Let us solve this example using '''Jacobi Method'''.
  
 
|-
 
|-
  
| 01.44
+
| 01:44
 
||Let us look at the code for '''Jacobi Method.'''  
 
||Let us look at the code for '''Jacobi Method.'''  
  
 
|-
 
|-
  
| 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.'''
  
 
|-
 
|-
  
|01.56
+
|01:56
  
 
|| Here '''e''' denotes the answer should be in '''scientific notation.'''
 
|| Here '''e''' denotes the answer should be in '''scientific notation.'''
Line 107: Line 96:
 
|-
 
|-
  
|02.01
+
|02:01
  
 
| 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  
 
 
   
 
   
 
|-
 
|-
  
|02.10
+
|02:10
  
 
|'''the matrices coefficient matrix,'''  
 
|'''the matrices coefficient matrix,'''  
Line 125: Line 112:
 
|-
 
|-
  
|02.12
+
|02:12
  
 
||'''right hand side matrix,'''  
 
||'''right hand side matrix,'''  
  
 
|-
 
|-
|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'''.
  
 
|-
 
|-
  
|02.22
+
|02:22
  
 
||Then we use '''size''' function to check if '''A matrix''' is a '''square matrix.'''
 
||Then we use '''size''' function to check if '''A matrix''' is a '''square matrix.'''
Line 152: Line 137:
 
|-
 
|-
  
|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.  
  
 
|-
 
|-
  
|02.34
+
|02:34
  
 
| We then check if '''matrix A''' is '''diagonally dominant.'''  
 
| We then check if '''matrix A''' is '''diagonally dominant.'''  
Line 165: Line 149:
 
|-
 
|-
  
| 02.40
+
| 02:40
  
 
|| The first half calculates the sum of each row of the '''matrix.'''  
 
|| The first half calculates the sum of each row of the '''matrix.'''  
  
 
|-
 
|-
| 02.45
+
| 02:45
 
| Then it checks if twice the product of the '''diagonal element'''  is greater than the sum of the elements of that row.  
 
| Then it checks if twice the product of the '''diagonal element'''  is greater than the sum of the elements of that row.  
  
 
|-
 
|-
|02.54
+
|02:54
| If it isn't, an error is displayed using ''' error function. '''
+
| If it isn't, an error is displayed using '''error''' function.
  
 
|-
 
|-
|03.01
+
|03:01
 
| Then we define the function '''Jacobi Iteration''' with input arguments  
 
| Then we define the function '''Jacobi Iteration''' with input arguments  
  
 
|-
 
|-
| 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.'''
 
+
  
 
|-
 
|-
| 03.19
+
| 03:19
 
|We check if the size of '''A matrix''' and '''initial values matrix''' are compatible with each other.  
 
|We check if the size of '''A matrix''' and '''initial values matrix''' are compatible with each other.  
  
 
|-
 
|-
|03.28
+
|03:28
 
| We calculate the value for '''x k p one''' and then check if the '''relative error''' is lesser than '''tolerance level.'''
 
| We calculate the value for '''x k p one''' and then check if the '''relative error''' is lesser than '''tolerance level.'''
  
 
|-
 
|-
| 03.38
+
| 03:38
| If it is lesser than '''tolerance level''', we break the iteration and the solution is returned.  
+
| If it is lesser than '''tolerance level''', we '''break''' the iteration and the solution is returned.  
 
|-
 
|-
  
| 03.45
+
| 03:45
 
+
|Finally we end the function.
+
 
+
  
 +
|Finally we '''end''' the function.
  
 
|-
 
|-
  
| 03.48
+
| 03:48
 
|| Let us save and execute the function.  
 
|| Let us save and execute the function.  
 
  
 
|-
 
|-
  
|03.51
+
|03:51
  
||Switch to '''Scilab console. '''
+
||Switch to '''Scilab console.'''
  
 
|-
 
|-
  
| 03.54
+
| 03:54
 
| Let us enter the values at each prompt.  
 
| Let us enter the values at each prompt.  
 
  
 
|-
 
|-
  
| 03.57
+
| 03:57
  
 
| 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. '''
 
 
  
 
|-
 
|-
  
| 04.10
+
| 04:10
  
 
| Then we type '''open square bracket eleven semicolon thirteen close square bracket'''
 
| Then we type '''open square bracket eleven semicolon thirteen close square bracket'''
 
  
 
|-
 
|-
  
|04.17
+
|04:17
 
+
||Press '''Enter. '''
+
 
+
  
 +
||Press '''Enter.'''
  
 
|-
 
|-
  
|04.20
+
|04:20
  
 
|The '''initial values matrix is open square bracket one semi colon one close square bracket'''
 
|The '''initial values matrix is open square bracket one semi colon one close square bracket'''
Line 270: Line 240:
 
|-
 
|-
  
| 04.28
+
| 04:28
  
 
| Press '''Enter.'''  
 
| Press '''Enter.'''  
 
 
 
  
 
|-
 
|-
  
| 04.30
+
| 04:30
  
 
|The '''maximum number of iterations''' is twenty five.  
 
|The '''maximum number of iterations''' is twenty five.  
 
 
  
 
|-
 
|-
  
| 04.34
+
| 04:34
  
 
| Press '''Enter. '''
 
| Press '''Enter. '''
Line 293: Line 258:
 
|-
 
|-
  
| 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 299: Line 264:
 
|-
 
|-
  
| 04.44
+
| 04:44
 
+
||Press '''Enter. '''
+
  
 +
||Press '''Enter.'''
  
 
|-
 
|-
  
| 04.46
+
| 04:46
  
 
||We call the function by typing  
 
||We call the function by typing  
 
|-
 
|-
  
| 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'''
  
 
|-
 
|-
  
| 05.04
+
| 05:04
  
 
|Press '''Enter. '''
 
|Press '''Enter. '''
 
 
  
 
|-
 
|-
  
| 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.'''
  
 
|-
 
|-
  
|05.11
+
|05:11
  
 
|The number of iterations are also shown.  
 
|The number of iterations are also shown.  
Line 339: Line 299:
 
|-
 
|-
  
|05.14
+
|05:14
  
 
| Let us now study '''Gauss Seidel method. '''
 
| Let us now study '''Gauss Seidel method. '''
 
 
  
 
|-
 
|-
  
| 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 '''
  
 
|-
 
|-
  
|05.26
+
|05:26
 
+
||We rewrite the equations for each unknown
+
 
+
  
 +
||we rewrite the equations for each unknown
  
 
|-
 
|-
  
| 05.29
+
| 05:29
  
 
| 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.  
 
  
 
|-
 
|-
  
| 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.'''
  
 
|-
 
|-
  
| 05.45
+
| 05:45
  
 
|This is done for every given equation.  
 
|This is done for every given equation.  
 
  
 
|-
 
|-
  
| 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 '''.
  
 
|-
 
|-
  
| 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'''.
  
 
|-
 
|-
  
| 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'''.
  
 
|-
 
|-
| 06.21
+
| 06:21
|The first line specifies the '''format''' of the displayed answer on the '''console''' using '''format function.'''  
+
|The first line specifies the '''format''' of the displayed answer on the '''console''' using '''format''' function.
  
 
|-
 
|-
  
| 06.29
+
| 06:29
  
| Then we use '''input function''' to get the values of  
+
| Then we use '''input''' function to get the values of  
  
 
|-
 
|-
  
| 06.32
+
| 06:32
  
 
| '''coefficient matrix, '''
 
| '''coefficient matrix, '''
Line 428: Line 373:
 
|-
 
|-
  
| 06.34
+
| 06:34
  
 
| '''right hand side matrix,'''
 
| '''right hand side matrix,'''
Line 434: Line 379:
 
|-
 
|-
  
| 06.36
+
| 06:36
  
 
| '''initial values of the variables matrix, '''
 
| '''initial values of the variables matrix, '''
Line 440: Line 385:
 
|-
 
|-
  
| 06.38
+
| 06:38
  
 
| '''maximum number of iterations'''  and  
 
| '''maximum number of iterations'''  and  
 
  
 
|-
 
|-
  
| 06.40
+
| 06:40
  
| '''tolerance level'''  
+
| '''tolerance level'''.
  
 
|-
 
|-
  
| 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'''.
  
 
|-
 
|-
  
| 06.58
+
| 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.'''   
+
| 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
+
| 07:10
  
 
|Then we start the iterations.  
 
|Then we start the iterations.  
Line 471: Line 415:
 
|-
 
|-
  
| 07.13
+
| 07:13
  
 
|We equate the '''initial values vector x zero to x k. '''
 
|We equate the '''initial values vector x zero to x k. '''
Line 477: Line 421:
 
|-
 
|-
  
| 07.19
+
| 07:19
  
 
|We create a '''matrix of zeros''' with the same size of ''' x k'''  and call it '''x k p one.'''   
 
|We create a '''matrix of zeros''' with the same size of ''' x k'''  and call it '''x k p one.'''   
Line 483: Line 427:
 
|-
 
|-
  
| 07.28
+
| 07:28
  
 
|We solve for each equation to get the value of the '''unknown variable''' for that equation using '''x k p one. '''
 
|We solve for each equation to get the value of the '''unknown variable''' for that equation using '''x k p one. '''
Line 489: Line 433:
 
|-
 
|-
  
| 07.38
+
| 07:38
  
 
|At each iteration, the value of '''x k p one''' gets updated.  
 
|At each iteration, the value of '''x k p one''' gets updated.  
Line 495: Line 439:
 
|-
 
|-
  
| 07.44
+
| 07:44
  
 
|Also, we check if '''relative error''' is lesser than specified '''tolerance level.'''  
 
|Also, we check if '''relative error''' is lesser than specified '''tolerance level.'''  
Line 501: Line 445:
 
|-
 
|-
  
| 07.50
+
| 07:50
  
|If it is, we break the iteration.  
+
|If it is, we '''break''' the iteration.  
  
 
|-
 
|-
  
| 07.54
+
| 07:54
 
|Then equate '''x k p one''' to the ''' variable solution.'''  
 
|Then equate '''x k p one''' to the ''' variable solution.'''  
 
|-
 
|-
  
| 07.59
+
| 07:59
  
|Finally, we end the function.  
+
|Finally, we '''end''' the function.  
  
 
|-
 
|-
  
| 08.02
+
| 08:02
  
 
|Let us save and execute the function.  
 
|Let us save and execute the function.  
 
|-
 
|-
  
| 08.06
+
| 08:06
  
|Switch to '''Scilab console'''
+
|Switch to '''Scilab console'''.
  
 
|-
 
|-
  
| 08.09
+
| 08:09
  
|For the first prompt, we type ''' matrix A.'''
+
|For the first prompt, we type '''matrix A.'''
  
 
|-
 
|-
  
| 08.12
+
| 08:12
  
 
|Type '''open square bracket two space one semi colon five space seven close square bracket'''
 
|Type '''open square bracket two space one semi colon five space seven close square bracket'''
Line 540: Line 484:
 
|-
 
|-
  
| 08.21
+
| 08:21
  
|Press '''Enter'''
+
|Press '''Enter'''. For the next prompt,
  
 
|-
 
|-
  
| 08.22
+
| 08:24
 
+
|For the next prompt,
+
 
+
|-
+
 
+
| 08.24
+
  
 
|type '''open square bracket eleven semi colon thirteen close square bracket'''
 
|type '''open square bracket eleven semi colon thirteen close square bracket'''
 
  
 
|-
 
|-
  
| 08.31
+
| 08:31
  
 
|Press '''Enter. '''
 
|Press '''Enter. '''
 
  
 
|-
 
|-
  
| 08.33
+
| 08:33
  
 
|We provide the values of '''initial value vector'''  by typing  
 
|We provide the values of '''initial value vector'''  by typing  
Line 572: Line 508:
 
|-
 
|-
  
| 08.38
+
| 08:38
  
|'''open square bracket one semicolon one close square bracket'''
+
|'''open square bracket one semicolon one close square bracket''' .
  
 
|-
 
|-
  
| 08.43
+
| 08:43
  
|Press '''Enter. '''
+
|Press '''Enter.'''
  
 
|-
 
|-
  
| 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.
  
 
|-
 
|-
  
| 08.50
+
| 08:50
 
+
|Press '''Enter. '''
+
  
 +
|Press '''Enter.'''
  
 
|-
 
|-
  
| 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'''.
  
 
|-
 
|-
  
| 09.01
+
| 09:01
  
 
|Finally we call the function by typing  
 
|Finally we call the function by typing  
Line 615: Line 549:
 
|-
 
|-
  
| 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'''
  
 
|-
 
|-
  
| 09.24
+
| 09:24
  
 
|Press '''Enter'''.  
 
|Press '''Enter'''.  
 
  
 
|-
 
|-
  
| 09.26
+
| 09:26
  
 
|The values of '''x one''' and '''x two''' are displayed.  
 
|The values of '''x one''' and '''x two''' are displayed.  
 
  
 
|-
 
|-
  
| 09.30
+
| 09:30
  
 
|The number of iterations to solve the same problem are lesser than '''Jacobi method.'''  
 
|The number of iterations to solve the same problem are lesser than '''Jacobi method.'''  
Line 643: Line 573:
 
|-
 
|-
  
| 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'''.
  
 
|-
 
|-
  
| 09.43
+
| 09:43
  
 
|In this tutorial, we have learnt to:  
 
|In this tutorial, we have learnt to:  
 
  
 
|-
 
|-
  
| 09.47
+
| 09:47
  
|Develop '''Scilab code''' for solving system of linear equations  
+
|Develop '''Scilab code''' for solving system of linear equations.
  
 
|-
 
|-
  
| 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.
  
 
|-
 
|-
  
| 10.01
+
| 10:01
 
+
| It summarises the Spoken Tutorial project
+
 
+
  
 +
| It summarizes the Spoken Tutorial project.
  
 
|-
 
|-
  
|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.
  
 
|-
 
|-
  
|10.09
+
|10:09
  
 
||The spoken tutorial project Team
 
||The spoken tutorial project Team
Line 694: Line 619:
 
|-
 
|-
  
|10.11
+
|10:11
 
+
||Conducts workshops using spoken tutorials
+
  
 +
||conducts workshops using spoken tutorials,
  
 
|-
 
|-
  
|10.15
+
|10:15
 
+
||Gives certificates to those who pass an online test
+
  
 +
||gives certificates to those who pass an online test.
  
 
|-
 
|-
  
|10.18
+
|10:18
 
+
||For more details, please write to contact@spoken-tutorial.org
+
  
 +
||For more details, please write to contact@spoken-tutorial.org .
  
 
|-
 
|-
  
|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.
  
 
|-
 
|-
  
| 10.30
+
| 10:30
  
 
| 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.  
 
|-
 
|-
  
| 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.
  
 
|-
 
|-
  
| 10.49
+
| 10:49
  
|This is Ashwini Patil signing off.
+
|This is Ashwini Patil. signing off.
  
 
|-
 
|-
  
|10.51
+
|10:51
  
 
| Thank you for joining.
 
| Thank you for joining.

Latest revision as of 23:54, 3 January 2018

Time Narration
00:01 Dear Friends, 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, 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. 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