1 00:00:14,969 --> 00:00:23,849 Hi, so we have discussed in the last class, about the finite difference schemes and the 2 00:00:23,849 --> 00:00:31,570 corresponding error estimates. So, let us proceed further little bit on that, with respect 3 00:00:31,570 --> 00:00:36,350 to the stability aspects. So, and then we generalise 4 00:00:36,350 --> 00:00:41,260 the second order method. . 5 00:00:41,260 --> 00:00:59,409 So, stability, consider so this equation so which we have derived 6 00:00:59,409 --> 00:01:03,650 so where A is the corresponding tri diagonal matrix and E is 7 00:01:03,650 --> 00:01:10,450 the error and error, global error matrix and then, this is the local truncation error matrix. 8 00:01:10,450 --> 00:01:26,580 So, this can be, this can be rewritten as A h, 9 00:01:26,580 --> 00:01:39,060 E h so this is just to know that for a specific h. 10 00:01:39,060 --> 00:01:58,790 So, definitely the matrix A h so this is with h equals to 1 by and plus 1 for 0 1 case and 11 00:01:58,790 --> 00:02:31,310 the dimension of Ah, grows as this happens. Let Ah inverse exists, this implies Eh is 12 00:02:31,310 --> 00:03:14,490 then, the nor is equals to, but we have this, as order of h square. Therefore, we expect, 13 00:03:14,490 --> 00:03:32,340 we expect the same for. But, from this if you see for 14 00:03:32,340 --> 00:03:44,950 this, to have this order, this must be bounded by a constant. 15 00:03:44,950 --> 00:03:45,950 .. 16 00:03:45,950 --> 00:04:10,010 So, for this to behave in this order, this be 17 00:04:10,010 --> 00:04:20,220 independent of h as h goes to 0 say, less than 18 00:04:20,220 --> 00:04:54,440 or equals to c, for sufficiently small h then, we get. So, this suggests a definition that 19 00:04:54,440 --> 00:05:00,810 means so global error is bounded so we know local error is order of h square and global 20 00:05:00,810 --> 00:05:18,860 error is also bounded like that. Hence, the stability is ensured. Suppose a finite difference 21 00:05:18,860 --> 00:05:59,800 method, for a linear boundary value problem gives a sequence of matrix equations 22 00:05:59,800 --> 00:06:52,740 where, h is mesh width. We say that, the method is stable if this exists for all sufficiently 23 00:06:52,740 --> 00:07:20,550 small h so that is say h less than h naught say. And if there exists constant c, independent 24 00:07:20,550 --> 00:07:31,990 of h such that is less than equal to c, for every h. This 25 00:07:31,990 --> 00:07:39,270 is, this will suggest the stability condition. 26 00:07:39,270 --> 00:07:56,190 So, once stability is done we need to, consistency so we have all talked before in the 27 00:07:56,190 --> 00:08:21,949 context of multi-step methods. So, we say that a method is consistent with the difference, 28 00:08:21,949 --> 00:08:48,060 method is consistent with the differential equation and boundary conditions, if the local 29 00:08:48,060 --> 00:09:04,790 truncation error goes to 0. As h goes to 0 and in general, this is order h power p, p 30 00:09:04,790 --> 00:09:20,910 greater than 0 then, then certainly consistent then 31 00:09:20,910 --> 00:09:25,549 what next, convergence. 32 00:09:25,549 --> 00:09:26,549 .. 33 00:09:26,549 --> 00:09:35,379 So, since we talked on, with respect to multi step method I do not want to repeat just 34 00:09:35,379 --> 00:09:55,639 consistency plus stability implies convergence. So, with this we have some idea of really 35 00:09:55,639 --> 00:10:03,160 how a particular approximation is giving you sensible results. Because, you have taken 36 00:10:03,160 --> 00:10:05,550 a differential equation and then pick up the 37 00:10:05,550 --> 00:10:11,300 derivatives, approximate and then we try to solve system and get the corresponding solutions. 38 00:10:11,300 --> 00:10:17,259 But what kind of errors are introduced locally and then whether, really these errors 39 00:10:17,259 --> 00:10:21,149 are bounded so that globally the error is bounded. 40 00:10:21,149 --> 00:10:30,100 So, they are not magnified so that, the method is stable. So, these on the conditions, on 41 00:10:30,100 --> 00:10:38,040 the matrix are really necessary. Now, let us we discussed earlier for a simple second 42 00:10:38,040 --> 00:10:45,100 order, that is y double prime equals to f of x. So, now let us generalise little bit 43 00:10:45,100 --> 00:10:50,220 more, where we have a general set up of linear second 44 00:10:50,220 --> 00:11:02,230 order boundary value problem. 45 00:11:02,230 --> 00:11:03,230 .. 46 00:11:03,230 --> 00:11:34,970 Second order BVP so we consider 47 00:11:34,970 --> 00:11:50,189 so this is our BVP, then the approximations. So, the 48 00:11:50,189 --> 00:12:17,410 first derivative is done with the central derivative approximations. 49 00:12:17,410 --> 00:12:18,410 . 50 00:12:18,410 --> 00:13:17,670 So, in view of this 1 becomes 51 00:13:17,670 --> 00:13:33,579 so y0 is gamma 1 and y n plus 1 is gamma 2. Now, we 52 00:13:33,579 --> 00:13:50,779 collect the coefficients of similar terms, so y i plus 1, 1 plus, 1 plus so if you multiply 53 00:13:50,779 --> 00:13:54,170 by h square there so h, h gets cancelled, so 54 00:13:54,170 --> 00:14:09,720 1 h by 2 and p so we get plus minus 2 and y i, h 55 00:14:09,720 --> 00:15:02,939 square q 1 minus h by 2. So, this implies where so I started with y i minus 1 so this 56 00:15:02,939 --> 00:15:07,110 will come here. 57 00:15:07,110 --> 00:15:52,910 .Now with this set up we expect a tri diagonal system where, A is B1, C1. Because, when 58 00:15:52,910 --> 00:16:07,399 we run the system, when i is 1 y0 so A1 does not exist because, y0 is known to us. So, 59 00:16:07,399 --> 00:16:33,979 A1 gets transferred to the right hand side therefore, we have this. And similarly, when 60 00:16:33,979 --> 00:16:53,040 we run for i n so we have, when we run for i equals to n, we have n plus 1. So, this 61 00:16:53,040 --> 00:17:00,119 term gets transferred to the right hand side so 62 00:17:00,119 --> 00:17:35,200 we have, this is Bi so we have A and B. So, and b bar look at that, when we run this 63 00:17:35,200 --> 00:17:44,570 for i equals to 1, h square r1 and y0 is gamma 1 so A1 gamma 1 gets transferred to 64 00:17:44,570 --> 00:17:59,380 the right hand side. So, we have h square r1 65 00:17:59,380 --> 00:18:27,980 minus then we have h square r2, h square r3 then h square r n minus 66 00:18:27,980 --> 00:18:40,009 so i equals to n. So, this will be y n plus 1 so we have c n times 67 00:18:40,009 --> 00:18:46,320 gamma t. . 68 00:18:46,320 --> 00:19:01,919 So, this will be the tridiagonal system and the corresponding 69 00:19:01,919 --> 00:19:24,690 local truncation error. So, this will be the corresponding local truncation 70 00:19:24,690 --> 00:19:38,620 error so we have system like this. So, 71 00:19:38,620 --> 00:19:58,899 which is a tridiagonal system and the same can be solved solving the... So, generally 72 00:19:58,899 --> 00:20:15,100 it is an elimination process, but for this particular 73 00:20:15,100 --> 00:20:19,320 case since it is a tridiagonal. So, there is an 74 00:20:19,320 --> 00:20:28,440 algorithm called Thomas algorithm. So, let us look at it so let the given system be in 75 00:20:28,440 --> 00:21:04,830 this form. So, which means b1 y1 plus c1 y2 equals 76 00:21:04,830 --> 00:22:12,850 d1 star then a2 similarly, a3 y2 then n minus 1. So, this will like our tridiagonal 77 00:22:12,850 --> 00:22:15,010 system expansion. 78 00:22:15,010 --> 00:22:16,010 .. 79 00:22:16,010 --> 00:22:39,080 Then, assuming b1 is non-zero eliminate naturally y1, assuming b1 non-zero 80 00:22:39,080 --> 00:22:51,539 we eliminate y1, from the 81 00:22:51,539 --> 00:22:59,040 second equation. So, we get b2 prime that is modified b2 is no 82 00:22:59,040 --> 00:23:49,799 longer b2, where b2 prime is b2 minus this. Next, assume b2 prime non zero 83 00:23:49,799 --> 00:24:01,049 eliminate y2 from the third equation of course, using this 84 00:24:01,049 --> 00:24:36,210 equation. Then we have v3 prime y3, where. . 85 00:24:36,210 --> 00:25:13,179 So, we continue like this, we eliminate y k at step k from k plus 1th equation of course, 86 00:25:13,179 --> 00:26:11,879 assuming this is non-zero, where k is. Now, what we have to do so having obtained up to 87 00:26:11,879 --> 00:26:45,980 .here, we back substitute, back substitution at n, assuming b n prime non-zero, y n is 88 00:26:45,980 --> 00:26:52,840 b n prime. 89 00:26:52,840 --> 00:27:23,590 And then, 1, y k is so these are capital n we are using so this is Thomas algorithm. 90 00:27:23,590 --> 00:27:29,539 So, one can write a nice programme and then try 91 00:27:29,539 --> 00:27:37,309 to solve it so having done a linear system so 92 00:27:37,309 --> 00:27:46,169 the next task is to try out with a non-linear system. So, what is the big deal in it. Well, 93 00:27:46,169 --> 00:27:48,360 for the linear case we have obtained a system 94 00:27:48,360 --> 00:27:53,869 of equations and then it happened to be tridiagonal and then, we have a simple algorithm 95 00:27:53,869 --> 00:27:58,440 called Thomas algorithm. And then one can obtain the solution, even 96 00:27:58,440 --> 00:28:02,490 otherwise using elimination etcetera. But in 97 00:28:02,490 --> 00:28:11,059 case of non-linear, one straight forward thing one could expect is, probably we expect 98 00:28:11,059 --> 00:28:18,499 that the system is non-linear so this is one thing. So maybe it is very trivial guess, 99 00:28:18,499 --> 00:28:21,669 but then the next task is how do we solve corresponding 100 00:28:21,669 --> 00:28:36,029 non-linear system of equations. So, let us look into non-linear system. 101 00:28:36,029 --> 00:28:37,029 . 102 00:28:37,029 --> 00:29:34,900 So, non-linear second order BVP so we consider say so if we discretise, if we discretise. 103 00:29:34,900 --> 00:29:55,960 Now, as far as derivative is concerned it is linear, but we have the right hand side 104 00:29:55,960 --> 00:30:02,690 part is non-linear. So, let us see how this works 105 00:30:02,690 --> 00:30:22,340 out with reference to an example. 106 00:30:22,340 --> 00:30:23,340 .. 107 00:30:23,340 --> 00:30:45,970 Suppose this is the example, I have taken h for simplicity, now the discretised version 108 00:30:45,970 --> 00:31:40,350 because, h is 1. So, this our grid, so essentially so these are the unknowns because, y0 is 109 00:31:40,350 --> 00:32:19,820 2, y4 is minus 1. So, i equals to 1, x 0, i equals to 1 so this will be x 1, x 1 is 110 00:32:19,820 --> 00:32:35,970 0 so unfortunately this is 0. So, this will be 111 00:32:35,970 --> 00:33:05,409 x 2 is 1 so this is 1 and y 2 square, so 112 00:33:05,409 --> 00:33:14,590 because x 3 is 2 so 2 y 3 square plus 2. 113 00:33:14,590 --> 00:33:15,590 . 114 00:33:15,590 --> 00:34:06,990 Now, in this system these are known so the final system we get it as follows. If you 115 00:34:06,990 --> 00:34:17,490 observe I did not put this as a matrix system x equals to b because, this is a non-linear. 116 00:34:17,490 --> 00:34:44,679 .So, let us call this as f of y bar equals to 0, where we have 117 00:34:44,679 --> 00:34:55,950 as components of so that means this is, this is also vector. So, this 118 00:34:55,950 --> 00:35:31,549 is nothing but so these are our f1, f2, f3 and 119 00:35:31,549 --> 00:36:03,410 what is it, is a non-linear system of equations for y1, y2 and y3. So, this is a non-linear 120 00:36:03,410 --> 00:36:19,280 system for y1, y2, y3. So, how do we solve ((Refer time.). So, I 121 00:36:19,280 --> 00:36:26,040 think you have heard for solving nonlinear algebraic equations, we have lot of methods 122 00:36:26,040 --> 00:36:32,760 and one popular method is Newton Raphson method. Now for non-linear system, 123 00:36:32,760 --> 00:36:40,640 we should try Newton Raphson method. So, what is the motive? 124 00:36:40,640 --> 00:36:41,640 . 125 00:36:41,640 --> 00:37:13,680 So, the motive behind so Newton Raphsonâ€™s method for solving non-linear system, so 126 00:37:13,680 --> 00:37:57,500 what we have is this, suppose we expand in Taylors series about y i plus. So, for a vector 127 00:37:57,500 --> 00:38:13,640 equation dau f bar by dau y bar 128 00:38:13,640 --> 00:38:36,660 so this is h square because, second order y minus y i 129 00:38:36,660 --> 00:39:09,220 square. So, y bar is minus f of and this must be approximately 0, so this must be 130 00:39:09,220 --> 00:39:21,950 approximately 0. So, from here y bar I am retaining then, we must transfer these things, 131 00:39:21,950 --> 00:39:29,890 I am transferring this, but then this is a matrix. 132 00:39:29,890 --> 00:40:03,340 So, it becomes inverse there and minus y i becomes this. So, therefore so this is now 133 00:40:03,340 --> 00:40:10,849 what is the inverse so this is the Jacobian dau f 134 00:40:10,849 --> 00:40:17,430 by dau y bar is the Jacobian and hence it is a inverse. 135 00:40:17,430 --> 00:40:18,430 .. 136 00:40:18,430 --> 00:40:50,260 So, accordingly the solution is an iterative method is defined 137 00:40:50,260 --> 00:41:35,430 so where the Jacobian. So, let us look at an example, let us look at 138 00:41:35,430 --> 00:42:06,549 an example, these are the boundary conditions. So, x0 is 0, x1 is one-third, two-third so 139 00:42:06,549 --> 00:42:46,991 the discretised version is. And we have y0 and 140 00:42:46,991 --> 00:42:58,130 y3 so we have y0 is 4 and y3 is 1. . 141 00:42:58,130 --> 00:43:32,700 So, let us run the system at i equals to 1 and i equals to 2 so we have y0 is 4, 1. So, 142 00:43:32,700 --> 00:43:48,862 now it gets simplified, let us put it like this 143 00:43:48,862 --> 00:44:22,740 y0 is 4 so it gets transferred. So, this is our, now 144 00:44:22,740 --> 00:44:58,010 we need to compute the Jacobian. So, this the Jacobian so in this case treating this 145 00:44:58,010 --> 00:44:59,010 as f 146 00:44:59,010 --> 00:45:12,260 .1th and this is f 2. So, this will be and with respect to 2 and here with respect 1, 147 00:45:12,260 --> 00:45:23,520 y1 and here 148 00:45:23,520 --> 00:45:24,520 so this a Jacobian. . 149 00:45:24,520 --> 00:45:40,210 Then, we 150 00:45:40,210 --> 00:46:29,210 need to compute this is, therefore, minus j inverse so where of course D is 151 00:46:29,210 --> 00:47:27,880 given by 2 y1. So, this is the iterative method now we have, we have to obtain y1 and y2 152 00:47:27,880 --> 00:47:46,010 so this is Newton Raphson, need initial guess to start the iteration. So, 153 00:47:46,010 --> 00:48:06,460 let so let this be the initial guess. 154 00:48:06,460 --> 00:48:07,460 . 155 00:48:07,460 --> 00:48:31,359 .Then, f1 this is, our guess was y 1 0, 2 y 2 0 so 156 00:48:31,359 --> 00:49:00,480 this will be 4 plus 2 so y 1 square 2 minus 1 minus 3. So, this is 157 00:49:00,480 --> 00:49:21,329 so this is 8, this is 4 then, this will be y 2 square, this will be minus 158 00:49:21,329 --> 00:49:39,619 y 2, y 2 is 1, that is correct. So, y 2 square minus y 1 so y 2 square y 1 159 00:49:39,619 --> 00:50:06,950 plus 2 y 2 so this will be 1 by 4 and d so d was 160 00:50:06,950 --> 00:50:29,339 so this 4 into 1 plus y 1. So, 1 plus 2 1 plus 1 so this will be 4 into 3 into 2. So, 161 00:50:29,339 --> 00:50:57,340 accordingly y 1 0, y 2 0 minus 1 over D then, we need this terms two times y 2 plus 1 so 162 00:50:57,340 --> 00:51:18,690 2 times y 2 plus 1 is 2 1 1 2 times y 1 plus 1. So, this multiplied by f1, f2 so here 4 163 00:51:18,690 --> 00:51:50,020 and 1 on 4 so this is, so this is 2 1 so you will 164 00:51:50,020 --> 00:52:13,559 get 16 plus and here we get 165 00:52:13,559 --> 00:52:22,990 so we can compute and we get some value. So I guess I have done 166 00:52:22,990 --> 00:52:30,150 it, but this is subject verification. . 167 00:52:30,150 --> 00:53:08,250 So, then we have to iterate further y 1 2. So, in order to compute we need f1 of so this 168 00:53:08,250 --> 00:53:17,859 probably, please verify there could be a mistake in the numerical calculation. Then the 169 00:53:17,859 --> 00:54:01,520 corresponding d and then so the other values 170 00:54:01,520 --> 00:54:16,240 so we may get some value. So, this the next iteration then, we continue further so we 171 00:54:16,240 --> 00:54:24,690 stop when we have decide accuracy. So, essentially with respect to the Newton 172 00:54:24,690 --> 00:54:37,520 Raphson method, we are trying to solve the non-linear system and then, this is just a 173 00:54:37,520 --> 00:54:48,630 solution like this. So, may be while calculating this is 0 so throughout we have to multiply 174 00:54:48,630 --> 00:55:03,690 by the inverse. So, may be I made a mistake so this will come here so this is the linearization 175 00:55:03,690 --> 00:55:14,090 in some sense. So, the guess is correct when you have non-linear equation, remember 176 00:55:14,090 --> 00:55:19,319 the non-linearity is only with respect to right hand side not in the derivatives, so 177 00:55:19,319 --> 00:55:20,319 far. 178 00:55:20,319 --> 00:55:26,960 .So, if that is a case we get system of equations and then, in this case the corresponding 179 00:55:26,960 --> 00:55:32,960 system of equations are non-linear and we use Newton Raphson method to solve these 180 00:55:32,960 --> 00:55:39,599 non-linear system of equations. So, far the stories for a simple boundary conditions 181 00:55:39,599 --> 00:55:47,670 suppose, your boundary conditions involve derivatives. So for example, one can classify 182 00:55:47,670 --> 00:55:54,579 the boundary conditions like, if the function value is given say like, type and derivatives 183 00:55:54,579 --> 00:55:58,349 are type then, a combination is given then robin type. 184 00:55:58,349 --> 00:56:03,859 So, if the derivatives are involved what would happen whether, the same techniques 185 00:56:03,859 --> 00:56:09,970 work well, the same techniques work, but the derivatives need to be discretised right. 186 00:56:09,970 --> 00:56:13,720 So, may be they will bring in little complications 187 00:56:13,720 --> 00:56:22,599 so we have to discuss them with a special care, so until then bye. 188 00:56:22,599 --> 00:56:22,599 .