Error Analysis

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome to MATLAB programming for mobility computations we are in V number seven in module 7 we are covering ordinary differential equations initial value on we are in lecture 7.5 this is the last lecture of this module in this lecture we are going to present some error analysis of runge-kutta methods so far we have covered euler's method which can be considered to be first order runge-kutta method we have covered a couple of RK 2 methods specifically Yoon's method and midpoint method and in the previous lecture lecture 7.4 we have covered RK 4 method standard are key for today we are going to present error analysis of our key metrics okay so first let us talk about the local truncation error we will demonstrate this in today's lecture what I will show you is with the global truncation error now if we were to compare global truncation error instead of low presentation error all of the Audis solvers they drop the overall order of accuracy by one power of H what that means is Euler's method the global truncation error is H to the power 1 u n--'s respect to the power to RK 4 is H to the power 4 today's lecture this is what we are going to demonstrate and compare we are going to see how the error of Euler's method compares with that of humans method and RK 4 method specifically we are talking about the global transition F let's now go to MATLAB in order to do this okay what we will do is we will bring up the codes that we had written earlier we had written okay to us method code rk4 standard method code and Euler's explicit method okay so our k2 humans method which uses my fund which we are done in lecture seven point four and this was the function my fun okay and then we have we have the RK for standard method okay which also use my fun but I will do also this open Euler's explicit method okay so this was the Euler's explicit method RK 2 and RK 4 meters Euler's explicit method also we are going to change this Martin instead of minus 2t t x y and then pingas my fun Oh di Pama why I okay exactly in the same way as we had done before as we are done over here that's what we have done again with our Euler's explicit method okay and save this okay and what we will do is we will do a comparison of Euler's explicit or k2 e jones and RK for scandal method and compare movies compare global truncation error of Euler time for meters okay what I will do is I will copy this part 0 is 0 y 0 is 1 let us take TN are equal to let's say 1 also H we are going to keep very so H all let's say this is zero point one zero point zero five zero point zero one zero one zero zero five let's say these are the four H values that we have okay for I equal to 1 to 4 H equal to H all I n equal to what we had earlier PN minus C 0 divided by H okay with this we are going to call Oilers explicit RK 2 e tools and RK 4 Stan so what we are going to do is we will call the RK Oilers and use method what we don't require everything we only require the Y and at the end so why n my oil and we are going to call it with our y 0 p 0 H and so why Tyler is this why you equal to my tune y0 e 0h in and y RT for people to my IQ for y 0 p 0 H so let's go to euler's explicit and convert this into a function you remember what we had said in module 1 when we discussed functions versus scripts scripts are something that we are going to use in order to complete a particular task in MATLAB we are going to use functions if we want to compute something as a function of certain input variables or if we want to repeat a particular task multiple number of times using the parents that is why we are going to convert all of these 300d solvers our euler's method of Jun's method and our key for standard method into corresponding functions get the first function is my I'll endure function y and equal to my Euler sorry compare pudding is my Euler y 0 T 0 H and n y 0 T 0 H and n so we don't need a zero we don't need y 0 we don't need T and don't need H can we don't need n so everything that was in problem definition we did not need Y because the problem definition was given in the compare OD is script so there's just one script which is the compare / ee script my euler my RK 2 and my Zune and my RK 4 are going to be three functions we will need to calculate the end also so TN is going to be T 0 + n multiplied by H so that is something that we have added okay we do not want lot or anything of that sort we want Y n is nothing but Y and that's the only thing that ok likewise we are going to do the same thing with our cocoons and RK 4 standard as well before doing that let's go to compare ODS and see whether this works or not e are r1 o ma I equal to 5 order - abs why - why - and the true value which I will again put it for over here why equal to exp minus e and square okay so let's just run this and see whether this works on certain error why true is undefined let's go and see why we are getting that why okay that's again it's the matter of MATLAB being case sensitive and I was not careful about the cases I need to initialize yeah equal to zero three comma four three methods and we have our four errors okay so let's save and run this so now we have our errors the first flow is the errors in oilless so let's look at ER are we only focus on row number one and these are the errors in Euler's method so let's actually have a charm up to zero point zero zero one as well and let us now do this for you and our k4 and likewise error I is for June why you and I for okay I will quickly go to RK - Hyun and save us my you okay we remove the this part and replaced it with Y and a function y n equal to by yoon let's copy-paste this I'm okay for standard also save as article 4 I'm just paste this over here and delete the spot okay I mean from my owner we will take this T end and paste it in both of these functions okay remember that's what we had done earlier now the next task is going to be to delete the output part and save this and likewise this also will be the same thing okay so what we have done is we have converted the I have gone carefully over how to convert explicit Euler into my Euler a script which was explicit Euler's we have converted into a function that was my euler the function takes the initial conditions step size and number of steps and returns the value at the end point that's what all these functions are intending to do okay we use all of these functions in our compare OD is file for a granite for different values of 8 from 10 to the power minus 1 to 10 to the power minus 3 and lot and what we are going to do is plot law logarithm of age against logarithm of yarra okay and let's run this we have certain error okay I think it should be plot of H on and lot of log of all and log of ear okay so these are the three plots this one is for RK 1 or Euler's method this one is for RK 2 method this one is for RK 4 method all of these are straight lines so we are the way we are going to compute the slopes are l e equal to e RR and L H equal to log of H of H bar okay so our denominator is always going to be denominator is going to be n H n minus L H okay our numerator is going to be L II all the rows last column minus and E all the rows first for the slopes is going to be numerator divided by denominator okay so the slope for RK 2 method joint slope for Euler's method is one point zero slope for RK 2 method is 2 point 0 approximately and the slope for RK 4 method is 4 point 0 so this demonstrates the order of accuracy of 3 RK methods from a global truncation error perspective so we have the three straight lines with slope of 1 slope of 2 and Slow of 4 ok so this was the discussion about global truncation error local truncation is one order greater accurate than the global truncation error just like what we had seen earlier in numerical integration the global truncation error of RK 2 method gives us the method as H to the power 2 accurate RK 4 method is H to the power four Apple what you can do as an assignment is you take the previous example and demonstrate it with the midpoint rule and see for yourself that like the Joon's method midpoint rule also gives us order of n square accurate global truncation error with that I come to the end of this lecture and indeed to the end of modern cell 107 become sidered OD e initial value problem we first started with it I was my third considered both explicit and implicit violence later we said that in this module we are going to focus on explicit methods only in lecture 7.2 we introduce ourselves to runge-kutta second-order method and extended it to practical the fourth or third order method in just seven point four in today's lecture into seven point five we did an error analysis of all the three methods in lecture seven point four we covered OD 45 which is the most popular algorithm that is provided by MATLAB in order to solve the only problem but that I come to the end of this module I will see you in module 8 thank you and
Info
Channel: MATLAB Programming for Numerical Computation
Views: 13,864
Rating: 5 out of 5
Keywords: Lecture, Error, Analysis
Id: JCaPYDgQ1iQ
Channel Id: undefined
Length: 19min 3sec (1143 seconds)
Published: Sun Feb 21 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.