Difference between revisions of "Scilab/C4/Linear-equations-Iterative-Methods/English-timed"
From Script | Spoken-Tutorial
Line 2: | Line 2: | ||
|'''Time''' | |'''Time''' | ||
− | |||
|'''Narration''' | |'''Narration''' | ||
Line 135: | Line 134: | ||
|- | |- | ||
− | | | + | | 02:17 |
|'''maximum number of iteration and''' | |'''maximum number of iteration and''' | ||
Line 141: | Line 140: | ||
|- | |- | ||
− | | 02 | + | | 02:19 |
||'''convergence tolerance''' | ||'''convergence tolerance''' | ||
|- | |- | ||
− | |02 | + | |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 151: | ||
|- | |- | ||
− | |02 | + | |02:29 |
Line 159: | Line 158: | ||
|- | |- | ||
− | |02 | + | |02:34 |
| We then check if '''matrix A''' is '''diagonally dominant.''' | | We then check if '''matrix A''' is '''diagonally dominant.''' | ||
Line 165: | Line 164: | ||
|- | |- | ||
− | | 02 | + | | 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 | + | | 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 | + | |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 | + | |03:01 |
| Then we define the function '''Jacobi Iteration''' with input arguments | | Then we define the function '''Jacobi Iteration''' with input arguments | ||
|- | |- | ||
− | | 03 | + | | 03:07 |
| '''A, b , x zero, ''' | | '''A, b , x zero, ''' | ||
|- | |- | ||
− | | 03 | + | | 03:09 |
|'''maximum iteration and tolerance level. ''' | |'''maximum iteration and tolerance level. ''' | ||
Line 193: | Line 192: | ||
|- | |- | ||
− | | 03 | + | | 03:14 |
|Here '''x zero''' is the '''initial values matrix. ''' | |Here '''x zero''' is the '''initial values matrix. ''' | ||
|- | |- | ||
− | | 03 | + | | 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 | + | |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 | + | | 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 | + | | 03:45 |
|Finally we end the function. | |Finally we end the function. | ||
Line 218: | Line 217: | ||
|- | |- | ||
− | | 03 | + | | 03:48 |
|| Let us save and execute the function. | || Let us save and execute the function. | ||
Line 224: | Line 223: | ||
|- | |- | ||
− | |03 | + | |03:51 |
||Switch to '''Scilab console. ''' | ||Switch to '''Scilab console. ''' | ||
Line 230: | Line 229: | ||
|- | |- | ||
− | | 03 | + | | 03:54 |
| Let us enter the values at each prompt. | | Let us enter the values at each prompt. | ||
Line 236: | Line 235: | ||
|- | |- | ||
− | | 03 | + | | 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 ''' | ||
Line 242: | Line 241: | ||
|- | |- | ||
− | |04 | + | |04:08 |
| Press '''Enter. ''' | | Press '''Enter. ''' | ||
Line 249: | Line 248: | ||
|- | |- | ||
− | | 04 | + | | 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''' | ||
Line 256: | Line 255: | ||
|- | |- | ||
− | |04 | + | |04:17 |
||Press '''Enter. ''' | ||Press '''Enter. ''' | ||
Line 264: | Line 263: | ||
|- | |- | ||
− | |04 | + | |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 269: | ||
|- | |- | ||
− | | 04 | + | | 04:28 |
| Press '''Enter.''' | | Press '''Enter.''' | ||
Line 279: | Line 278: | ||
|- | |- | ||
− | | 04 | + | | 04:30 |
|The '''maximum number of iterations''' is twenty five. | |The '''maximum number of iterations''' is twenty five. | ||
Line 287: | Line 286: | ||
|- | |- | ||
− | | 04 | + | | 04:34 |
| Press '''Enter. ''' | | Press '''Enter. ''' | ||
Line 293: | Line 292: | ||
|- | |- | ||
− | | 04 | + | | 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 298: | ||
|- | |- | ||
− | | 04 | + | | 04:44 |
||Press '''Enter. ''' | ||Press '''Enter. ''' | ||
Line 306: | Line 305: | ||
|- | |- | ||
− | | 04 | + | | 04:46 |
||We call the function by typing | ||We call the function by typing | ||
|- | |- | ||
− | | 04 | + | | 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 paranthesis A comma b comma x zero comma M a x I t e r comma t o l close paranthesis ''' | ||
Line 318: | Line 317: | ||
|- | |- | ||
− | | 05 | + | | 05:04 |
|Press '''Enter. ''' | |Press '''Enter. ''' | ||
Line 326: | Line 325: | ||
|- | |- | ||
− | | 05 | + | | 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 333: | Line 332: | ||
|- | |- | ||
− | |05 | + | |05:11 |
|The number of iterations are also shown. | |The number of iterations are also shown. | ||
Line 339: | Line 338: | ||
|- | |- | ||
− | |05 | + | |05:14 |
| Let us now study '''Gauss Seidel method. ''' | | Let us now study '''Gauss Seidel method. ''' | ||
Line 347: | Line 346: | ||
|- | |- | ||
− | | 05 | + | | 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 355: | Line 354: | ||
|- | |- | ||
− | |05 | + | |05:26 |
||We rewrite the equations for each unknown | ||We rewrite the equations for each unknown | ||
Line 363: | Line 362: | ||
|- | |- | ||
− | | 05 | + | | 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. | ||
Line 370: | Line 369: | ||
|- | |- | ||
− | | 05 | + | | 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 377: | Line 376: | ||
|- | |- | ||
− | | 05 | + | | 05:45 |
|This is done for every given equation. | |This is done for every given equation. | ||
Line 384: | Line 383: | ||
|- | |- | ||
− | | 05 | + | | 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 392: | Line 391: | ||
|- | |- | ||
− | | 06 | + | | 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 400: | Line 399: | ||
|- | |- | ||
− | | 06 | + | | 06:12 |
|Let us solve this example using '''Gauss Seidel Method''' | |Let us solve this example using '''Gauss Seidel Method''' | ||
Line 407: | Line 406: | ||
|- | |- | ||
− | | 06 | + | | 06:17 |
| Let us look at the code for '''Gauss Seidel Method''' | | Let us look at the code for '''Gauss Seidel Method''' | ||
|- | |- | ||
− | | 06 | + | | 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 | + | | 06:29 |
| Then we use '''input function''' to get the values of | | Then we use '''input function''' to get the values of | ||
Line 422: | Line 421: | ||
|- | |- | ||
− | | 06 | + | | 06:32 |
| '''coefficient matrix, ''' | | '''coefficient matrix, ''' | ||
Line 428: | Line 427: | ||
|- | |- | ||
− | | 06 | + | | 06:34 |
| '''right hand side matrix,''' | | '''right hand side matrix,''' | ||
Line 434: | Line 433: | ||
|- | |- | ||
− | | 06 | + | | 06:36 |
| '''initial values of the variables matrix, ''' | | '''initial values of the variables matrix, ''' | ||
Line 440: | Line 439: | ||
|- | |- | ||
− | | 06 | + | | 06:38 |
| '''maximum number of iterations''' and | | '''maximum number of iterations''' and | ||
Line 447: | Line 446: | ||
|- | |- | ||
− | | 06 | + | | 06:40 |
| '''tolerance level''' | | '''tolerance level''' | ||
Line 453: | Line 452: | ||
|- | |- | ||
− | | 06 | + | | 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 459: | Line 458: | ||
|- | |- | ||
− | | 06 | + | | 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.''' | ||
Line 465: | Line 464: | ||
|- | |- | ||
− | | 07 | + | | 07:10 |
|Then we start the iterations. | |Then we start the iterations. | ||
Line 471: | Line 470: | ||
|- | |- | ||
− | | 07 | + | | 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 476: | ||
|- | |- | ||
− | | 07 | + | | 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 482: | ||
|- | |- | ||
− | | 07 | + | | 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 488: | ||
|- | |- | ||
− | | 07 | + | | 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 494: | ||
|- | |- | ||
− | | 07 | + | | 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 500: | ||
|- | |- | ||
− | | 07 | + | | 07:50 |
|If it is, we break the iteration. | |If it is, we break the iteration. | ||
Line 507: | Line 506: | ||
|- | |- | ||
− | | 07 | + | | 07:54 |
|Then equate '''x k p one''' to the ''' variable solution.''' | |Then equate '''x k p one''' to the ''' variable solution.''' | ||
|- | |- | ||
− | | 07 | + | | 07:59 |
|Finally, we end the function. | |Finally, we end the function. | ||
Line 517: | Line 516: | ||
|- | |- | ||
− | | 08 | + | | 08:02 |
|Let us save and execute the function. | |Let us save and execute the function. | ||
|- | |- | ||
− | | 08 | + | | 08:06 |
|Switch to '''Scilab console''' | |Switch to '''Scilab console''' | ||
Line 528: | Line 527: | ||
|- | |- | ||
− | | 08 | + | | 08:09 |
|For the first prompt, we type ''' matrix A.''' | |For the first prompt, we type ''' matrix A.''' | ||
Line 534: | Line 533: | ||
|- | |- | ||
− | | 08 | + | | 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 539: | ||
|- | |- | ||
− | | 08 | + | | 08:21 |
|Press '''Enter''' | |Press '''Enter''' | ||
Line 546: | Line 545: | ||
|- | |- | ||
− | | 08 | + | | 08:22 |
|For the next prompt, | |For the next prompt, | ||
Line 552: | Line 551: | ||
|- | |- | ||
− | | 08 | + | | 08:24 |
|type '''open square bracket eleven semi colon thirteen close square bracket''' | |type '''open square bracket eleven semi colon thirteen close square bracket''' | ||
Line 559: | Line 558: | ||
|- | |- | ||
− | | 08 | + | | 08:31 |
|Press '''Enter. ''' | |Press '''Enter. ''' | ||
Line 566: | Line 565: | ||
|- | |- | ||
− | | 08 | + | | 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 571: | ||
|- | |- | ||
− | | 08 | + | | 08:38 |
|'''open square bracket one semicolon one close square bracket''' | |'''open square bracket one semicolon one close square bracket''' | ||
Line 578: | Line 577: | ||
|- | |- | ||
− | | 08 | + | | 08:43 |
|Press '''Enter. ''' | |Press '''Enter. ''' | ||
Line 584: | Line 583: | ||
|- | |- | ||
− | | 08 | + | | 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 590: | Line 589: | ||
|- | |- | ||
− | | 08 | + | | 08:50 |
|Press '''Enter. ''' | |Press '''Enter. ''' | ||
Line 597: | Line 596: | ||
|- | |- | ||
− | | 08 | + | | 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 | + | | 08:58 |
|Press '''Enter''' | |Press '''Enter''' | ||
Line 609: | Line 608: | ||
|- | |- | ||
− | | 09 | + | | 09:01 |
|Finally we call the function by typing | |Finally we call the function by typing | ||
Line 615: | Line 614: | ||
|- | |- | ||
− | | 09 | + | | 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 paranthesis A comma b comma x zero comma M a x I t e r comma t o l close paranthesis''' | ||
Line 623: | Line 622: | ||
|- | |- | ||
− | | 09 | + | | 09:24 |
|Press '''Enter'''. | |Press '''Enter'''. | ||
Line 630: | Line 629: | ||
|- | |- | ||
− | | 09 | + | | 09:26 |
|The values of '''x one''' and '''x two''' are displayed. | |The values of '''x one''' and '''x two''' are displayed. | ||
Line 637: | Line 636: | ||
|- | |- | ||
− | | 09 | + | | 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 642: | ||
|- | |- | ||
− | | 09 | + | | 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 650: | Line 649: | ||
|- | |- | ||
− | | 09 | + | | 09:43 |
|In this tutorial, we have learnt to: | |In this tutorial, we have learnt to: | ||
Line 657: | Line 656: | ||
|- | |- | ||
− | | 09 | + | | 09:47 |
|Develop '''Scilab code''' for solving system of linear equations | |Develop '''Scilab code''' for solving system of linear equations | ||
Line 663: | Line 662: | ||
|- | |- | ||
− | | 09 | + | | 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''' | ||
Line 669: | Line 668: | ||
|- | |- | ||
− | |09 | + | |09:58 |
| Watch the video available at the following link | | Watch the video available at the following link | ||
|- | |- | ||
− | | 10 | + | | 10:01 |
| It summarises the Spoken Tutorial project | | It summarises the Spoken Tutorial project | ||
Line 682: | Line 681: | ||
|- | |- | ||
− | |10 | + | |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 688: | Line 687: | ||
|- | |- | ||
− | |10 | + | |10:09 |
||The spoken tutorial project Team | ||The spoken tutorial project Team | ||
Line 694: | Line 693: | ||
|- | |- | ||
− | |10 | + | |10:11 |
||Conducts workshops using spoken tutorials | ||Conducts workshops using spoken tutorials | ||
Line 701: | Line 700: | ||
|- | |- | ||
− | |10 | + | |10:15 |
||Gives certificates to those who pass an online test | ||Gives certificates to those who pass an online test | ||
Line 708: | Line 707: | ||
|- | |- | ||
− | |10 | + | |10:18 |
||For more details, please write to contact@spoken-tutorial.org | ||For more details, please write to contact@spoken-tutorial.org | ||
Line 715: | Line 714: | ||
|- | |- | ||
− | |10 | + | |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 723: | Line 722: | ||
|- | |- | ||
− | | 10 | + | | 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 | + | | 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 734: | Line 733: | ||
|- | |- | ||
− | | 10 | + | | 10:49 |
|This is Ashwini Patil signing off. | |This is Ashwini Patil signing off. | ||
Line 740: | Line 739: | ||
|- | |- | ||
− | |10 | + | |10:51 |
| Thank you for joining. | | Thank you for joining. |
Revision as of 18:00, 10 July 2014
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 practising 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 paranthesis A comma b comma x zero comma M a x I t e r comma t o l close paranthesis
|
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 paranthesis A comma b comma x zero comma M a x I t e r comma t o l close paranthesis
|
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 summarises 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. |