 So, notice that when you say low text requires both columns to be of the same length, what do we mean? The number of lines of data must be the same for both. You cannot have some columns empty for the some rows empty for one column, because it is we noted that arrays are homogeneous data structures. So, it has to be filling every value. So, for that purpose you have to ensure that the data is in the right format. So, are we all comfortable with loading data? This is the most useful probably the most common use case you will do. Read existing information into a file or have an existing information in the form of a file, read that data into variables using low text. We note that low text will directly do the so much of work it is doing. Read one line at a time, convert, parse it, break it into pieces, convert to float then load it into an array. All that is done in worth one line of code. So, unlike primes it is not a simple sequence. So, if you notice I read it into variable called l t the full file name is of not real interest. It is essentially the low text. So, now for this to work both should have the same columns all that we said. Once you have done that what do you get? You get a single array of arrays so to speak. So, that may not be very comfortable. You may have you may be more comfortable saying you know I want two arrays so that one is l, one is t. You can do that. If you say unpack equal to true you will get it nicely unpacked into two things. You can see l is the first column t is the second column. So, whichever way you want you can get it. You can either get it as an array of two arrays which I did in l t. So, l t gives you one pair it gives you a list of pairs of l and t values, but it may make more sense for you to have all the l values in one variable and all the t values in one variable. That is done by using the unpack argument. Let us repeat low text is essentially a convenience which reads a set of data, parses it, converts the data type and loads it. It is almost always what you want. Rare occasion if it is not you have to do stuff the wrong way, but in those cases you are better off using the shell scripting you learn to take the data chop it into pieces reassemble it and then do a simple low text rather than trying to write python code to change it. Supposing there is some text data low text will vomit anything other than numeric data gives low text indigestion. So, the best way is to not write special python code instead write a simple bash script which removes the column and then use that resultant file as input to a low text. Now, we want to plot l versus t square and produce an approximate straight line. So, we have a function called square which we can use we could also iterate over we have done for loops and all that right. We could laboriously go say x equal to something then x equal to x plus t star t for t in t all that you could write, but that is not how scientific computing people like to think you like to write like mathematicians. So, simply write plot l comma tsq like this can even do better and you will get sorry c l f would be preferable. You will get a lovely looking straight line like that if you squint it even looks like a straight line. Obviously, this is not the case for drawing a continuous line correct this is experimental data. So, you should have plotted using points are you in agreement those of you are awake at least are you in agreement sleepers we do not have to worry about. So, this is more like it this tells you that yes there is a linear tendency and that is about it all right. Now, please note that in two lines of code low text plot we have managed to read a whole data file do data conversion and produce a plot. Python is extremely powerful in that sense and you wrote using fairly simple English sounding commands load text does not get more readable than that load text and plot you have got most of the way with those two commands. Experimental data also contains errors you normally do not get you have limits of error in an observation. So, we normally like to do error bar plots rather than plotting a single point you plot a symbol that measures the spread within which the point can exist anywhere all right. So, that we do by the error bar. So, we now have a four column data L t the error in L the error in t is available as four columns we can read it with one line that slash is for continuing a long line across two lines. So, L comma t comma L here equal to load text pendulum error dot text unpack equal to true insures you get four variables rather than and one array of four arrays. So, you can do t s is equal to t and then this instead of using plot you use error bar to plot you will get you do not have a capture. So, this command reads it L t L r t here unpack equal to true reads it into four. Now, we need to instead of plot this is the error bar plot essentially captures the possibility of the error in each of our data points. Effectively when you say error bar you are drawing that many graphical items. So, which is why the screen will be full of mat plot lip objects for each of the 90 points you are drawing one graphical object. And there are different format for how you want to draw them how do you find out what are the formats simply go through the error bar man page. If you do not do error based plots you are not really going to appreciate what is happening, but if you essentially the idea is all experimental data has some range or tolerance or a range of expected error rather plotting a point which is fictitious because your data is not that your data is anywhere between length is L plus delta L plus there minus delta L. Similarly, your time is delta t plus delta minus delta t within that range. So, you should actually say my point allies anywhere within this square. So, the error bar which is essentially a way of seeing graphically showing that this is what is happening. As you can see there is a lot more error in the L side and lot less on the vertical side. The graph is a little any questions error bar is essentially a shorthand for one plot followed by 90 plot or 90 line drawing and you have different format for error bars. Can we move on your other plots? Yes the scatter plot you could do pie charts. In a sense the plot of L versus t square was a scatter plot in the way we did it. Notice the d type equal to int type of int because you do not want years to be shown in the x axis as 2002.0. That would not make sense nothing special about a scatter plot. Even the L by t square plot we did earlier is a scatter plot. You do not have to call it a scatter plot simply say plot L comma t square with O gives you essentially a scatter plot. Here you do not are you are not specifying. In a sense you can think of scatter as nothing but a shorthand for a specific plotting style. It is the same as plot year comma profit comma O. Can we move on? You can do a pie chart, you can do a log log chart each one of which you will avoid the typing practice. I presume if you understand what the various features are you will be able to replicate it. Can we move on? Let us talk about arrays. Like we made a comment earlier arrays are similar to lists but arrays are homogeneous. They are much faster than lists. The slides arrays are faster than arrays in a slightly self referential metaphysical way but ignore it. It is a typo it should be arrays are much faster than lists. Because they are homogeneous and immutable the underlying code can do a lot more of optimization. So, that is why arrays are much faster. So, instead of list instead of simply putting in square bracket 1, 2, 3, 4 you have to use the key word array a 1 equal to array of a list. So, it 1, 2, 3, 4 in square bracket is a list that is converted into an array by the constructor array. You remember both low text also returned arrays, low text returned arrays, lint space returned arrays. So, we have been using arrays till now without drawing too much attention to the fact. They are sort of hand waived around them but essentially arrays are a big business. You can also think of arrays as matrices. You squint in a particular way they are matrices. So, identity 3 gives you a there is a concept of shape for arrays. Concept of length for arrays does not make as much sense as shape because length will only tell you one dimension. So, shape tells you please note unlike length shape is a property. So, array dot property it is not a function. So, identity gives you an array 3 by 3 unit matrix write out identity of 3 try out 0s 4, comma 5. So, what is the idea of 0s like instead of specifying a shape which is what 0s takes please note it is a shape you have to give it a tuple that 4 comma 5 within brackets is required you cannot give it. So, 0s like instead of a shape looks at an existing array and says of the same shape. Why is it better? In a program you may not know the actual shape of an array you are getting. For example, if you have read through using low text you do not know what shape it is, but you may want an identity matrix of the same shape for some mathematical matrix operations. So, in that case 0s like or 1s like will become useful you do not have to check for the shape and then create another. Is that idea clear? There is a similarly 1s like and 1s empty empty and so on and operations on arrays I will use one of the existing arrays I have I have an array. So, what do you mean by operations on arrays? L star 2 gives me a new array where each element is multiplied by 2. This is what a mathematician would like would write with a matrix 2 a means a scalar multiplication of a matrix and so on. So, you can also write a star a which will result in not matrix multiplication element wise multiplication the corresponding element will be multiplied. So, this is one of the biggest advantages of using arrays your whole code becomes very very simple. How many of you are teaching computer science particularly CS 101? I am sure one of your biggest lab exercises is multiplying two matrices. We do not do any such thing we simply write a star b. We do not have to worry about indices as keeping track incrementing the index variables none of that. So, this is the power of the idea of using arrays. One of my students in an earlier batch used a phrase which I have started using myself I carry it think wholesale do not think retail. I like that expression in python you think wholesale you use the array in wholesale rather than one element at a time. So, and please remember arrays are immutable. So, you cannot say a equal to a star 2 and things like that that is not recommended. Similarly, when you say a 1 star 2 a new array is created which is each element is twice the previous one. So, you want to use it you say b equal to a 1 star 2 and so on. You are going to have a little bit of a tricky thing with keeping track of the proper what is properly happening a star 2 what is happening a 1 plus 2 what is this supposed to do all the elements remember that think wholesale do not think last element first element some 2 is added some some honor no remember that. Similarly, a 1 star a 2 which is at the bottom again is it is not matrix multiplication all things are element to element. If a 1 plus a 1 is creating a new array whose first element is the sum of the first element. Similarly, a 1 star a 2 is a new array of the same size the first element is a product. If you write a equal to b star c the first element of a is the product of the first element of b and the first element of c. Where is that useful? It is useful in some areas it is not matrix multiplication sir, but I want matrix multiplication you can get it using a function called dot. So, dot a comma b will give you the dot product of a and b which is essentially the a dot b which is the matrix multiplication. In lists you would have seen something called slicing correct same ideas carry over to arrays. Once again think wholesale slices allow you to think wholesale even when manipulating pieces. So, a of 2 is an array if you have c c of 2 comma 3 is another array. So, your code becomes very expressive and very simple. So, here we have an example change the last row into all 0 c of minus 1 you could have simply written c of minus 1 equal to 0 is like. Now, you do not even want to know what is the size you do not want to type that many zeros. This is the most powerful facility given to you to go back to that joke which is in my opinion very useful think wholesale. You manipulate arrays like you write in your maths textbook a star b a plus b you do not take in terms of elements in terms of keeping tabs of things. You would write it like you write it in mathematical notation. You can ask again c colon comma 2 is another array which array is this is essentially the third column not second column remember indices started 0 minus 1 is the last column and so on. You want to access a row you would set c of 2 because c is a two dimensional array c of 2 will give you the third row c colon comma 2 will give you the third column. If you have done slicing we are essentially extending the idea a little that is all if you have done this slicing. Any questions on how to look at arrays are essentially matrices in a certain manner of speaking if you as long as you remember star is element wise multiplication not matrix multiplication that is a separate function available for you to do matrix multiplication. You can say arrays are matrices which gives us a very powerful way of doing certain classes of image processing. An image is essentially an array how image has a certain size so many pixels by so many pixels and in each pixel position some data is available. What is the data that is all for an image more than 0 or 1 there is an RGB value that is a actually 4 integers are there running from 0 to 255 correct slightly more noise will convince me you are not yet fully asleep yes or no. So essentially an image is a what size star a we can do that by doing this I am read is given available so I am read is a wrapper around reading of graphics file and bringing it up providing it an interface as if it is array data. So do this you should be able to see so if you do this I is an array how do you know that the array 300 by 300 so how do you do this sort of image processing meaning I just want the top left hand quadrant of this image how do I get it we are told this shows this road load the image let us do this I am show so that tells you the colors are a little off but they are red and blue. So given that this is your image and this is loaded into an array which is an array for all practical purposes for us to manipulate how do you do certain image processing namely how do I get back this top left quadrant time to really wake up and start talking 0 0 to 150 150 how do you do that. 0 to 150, I hope you understand this is going up to 0 to 149 which is correct sorry does not give me anything I have to do I am show I am show which is we got 0 to 149 which is essentially what we wanted. So if you remember all the manipulation of array is available to you and the array is loaded as an array a whole class of image processing problems become simple array manipulation problems for example you want to reduce the resolution of an image by picking up every alternate pixel very simple to do you want the center of a picture again simple to do you want to rotate a picture you can think of whatever you want to do do the manipulation on the array and the result as an image gives you what you want we are by no means suggesting this is the way to do image processing in python there is a huge python imaging library till and there is open cv which is computer vision library which is available in python. So those are the ways to go if you are interested in serious image processing but quite often we are looking for some very quick minor manipulation which is more than sufficient for this sort of an approach you want to do serious image processing you are of course point recommended that you pick up the appropriate libraries p i l and open cv come to mind but fairly often what you need is a very simple tweak of an image this approach will give you more than enough to do here is a laundry list of operations just to complete the picture whatever you want to do you can do in one shot think whole sale once again using arrays transpose dot t so you want to transpose an array or do a consider and operate something as a matrix it is an array dot t gives you the transpose of that matrix the product the matrix product or matrix multiplication as noted earlier is obtained by using dot of course inverse and determinant available there is also a rather peculiar sum I do not ever recall requiring to add every element in a matrix but then eigenvalues and eigenvector singular value decompositions all of that is available as a very simple one call function all right once again just think of the matrix composition let us do whole sale you will find one operation to do what you need you do not ever have to code the nuts and bolts of any matrix manipulation because it is all done for you already we nicely so if you look at this essentially the l by t square plot for the pendulum now a straight line does not make any sense if you have to do this does not make any sense does it this line has no relevance meaning it is ridiculous to draw even such a line so what is the correct straight line to draw for these points we know there is a linear trend what is the correct straight line to draw for this the least square fit so least square fit is something which is often useful so you can do a least square fit fairly straight forward do this now comes little bit of heavy lifting we essentially are saying for each t value there is a m and c we have to find and in a sense take the best average of m and c for each l t value there is one m and c which you know can be thought of as existing that is why there are so many different looking lines so if you are able to say in some sense I need to average out this m and c so that I can get a single line that is one way of looking at a least square fit so you have to get used to looking at equations in the matrix form rather than the more traditional form so t squared equal to m and l plus c so t square is this you can think of it as p s q equal to a dot p where dot is the matrix multiplication and p is your m c now if we can find the best m and c then we can plot and that is very easily done now you see the use for once like what do we need once like l that is l by the way it is not once like one it is once like l capital l might be nicer anyway you have a built in function called l s t s q it returns a lot of stuff the first is the m comma c if you do that you can then plot and see a much better line which goes through the middle of this band which is how the best least square fit line would be all right so you have the slides with you I suggest you read this do the least square fit and show it to me if you have any doubts ask you plot the points and the least square line so that you can see how the least square line is somewhere in the middle of the points for some values of the word middle the machinery required is stated as l s t s q then the transpose once like and in order to understand where the once like comes from we have written out the equation here you can see that one column coming so you need once like and this is in this form you know l 1 is a row vector so you need to transpose without even those things you should be transposing but this is why I wanted you to do it because you are now becoming typing you I say something you type without bothering what we are typing please do not stop that just a little bit of extra effort and you can do it so run once like by itself in this type once like question mark once underscore like question mark it will happen there will be many things which we do not cover which you will need to know so go back to the built-in help see we have this this is produced by t square correct this is produced by l this once you require where does it come from why once like otherwise to find this size and then feed it there is a whole idea of once like you do not do two steps find the size and then shape and then say simply this and these are in this form but but actually l 2 and l 1 will be in the other form you need that for multiplication correct that is why transpose I made this point earlier ok the question is related to something we talked about precisely showing this I talked about yes or no I am a very nasty teacher I know exactly when I talked about what showing this I said please note it is a tuple we are giving a shape it is not two arguments it is not two numbers four and five that is being given what we are giving is four comma five matrix of size four into five that is different from two numbers four and five the shape four into five is different from two numbers four comma five right how am I how do I tell you I am passing one shape description rather than two numbers good question but unfortunately it was explained long long ago alright can we move on let me repeat this is recipe based cooking style take this dump you will get it eighty percent reasonable food you will get ok so far if you notice we have not written one line of code he said ok how do I get a plot type plot how do I do x do this this complete this whole session is the recipe based how do I get x done for different values of x we have done it how do I get interactive plotting how do I save to script for each one there is one or two points to remember that is all but real world work requires putting together lot of these things for example a recipe may simply say how to make rasam but if you want to prepare a feast for ten people you have to make seven eight item so in that sense you have to put together many of these tweak them a little once in a while you might consider calling up somebody a without a tomato how do I make this so combination of all of this works but at a simple level this whole session is about you know what it is very easy to do some fairly complicated thing pretty easy to do if anyone has ever generated a chart in say C or any other language as anyone had that misfortune do you know how many lines of code you have to write and how much of debugging you have to do with those libraries here you get it in one shot plot a comma v so that is the whole idea of covering what we are covering so both for your own consumption and when you are training other students please try to focus on how very simply fairly complex things can be done that is a moral of the story you have to focus on do not get lost in all these zeros like ones like commas and full stops the most important thing is you are giving a toolkit for an engineering or a science student which has uncomparable power and ease of use two lines of text a student can read data and get a plot load text followed by a plot I cannot overemphasize how powerful and empowering it is in all this syntax I do not want to us to lose track of why we are doing this program is not for filling up those forms and making them jump through hoops to send a wire transfer that is not the objective of the exercise objective is to provide students of science and engineering courses are very powerful easy to use toolkit in all this hall of we are forgetting that in our own individual struggles with the computer with typing with all the small letters with these new language let us not lose track of that we are here to reveal how easy many important things are for an engineering student with how easy they are to accomplish in the choice of platform we are discussing that is why today's whole approach in this whole advanced python session you do not see write n lines of code to do x you did not have to write more than two lines to do anything yes or no rarely you might have had to do three lines you will see the continuum you want to solve equations you will spend more time typing looking at this slide than actually solving the equation because solving the equation is child's play it takes more time to type the damn setup of the problem solution is half a second it takes lot more donkey's work to set up the problem as usual you are discussing thousand by thousand arrays they can be loaded in by using load text obviously we are showing three by three for showing solve if you are doing large scale optimization problem with matrices of the order of 500 by 500 and their coefficients are in a file once again load text is your friend load it you got the array till the same solve am I communicating let me repeat it takes lot more time to explain than to do these things it takes lots more time to type than to do these things so how do you verify we actually solve you know x this brings us to one interesting problem namely floating point round original is supposed to be one minus two zero but you get some non zero number it is actually what we could call machine epsilon meaning the smallest representable floating point value round of error so the computer decides you know what it is not zero 10 power minus 16 is as good as zero for all practical purposes but we do not know whether it is zero so there is a built in function called all close which allows you to verify if they are different are they different above a significance or below a significance you know there is a built in round off so all close verifies that if there is a difference between a x and b is that worth considering is it significant or is it simply carry over round off type of problem in this case it says all close a x comma b is true in which that means a x is close to b in other words that solution is as good once again think of it as a recipe how do I verify whether it is a solution do not verify by saying a x equal to b instead all close a x comma b because all close has that one bit of extra intelligence built in it checks whether two things are near enough if you want to use mathematical language sufficiently near a minus x less than epsilon for sufficiently small values of epsilon that is the need for all close and when you teach I would also suggest you think about teaching it that way rather than what all close does all close is something you use to ensure you got the solution and this is the purpose once more you will spend more time looking at the slide then solving you want to solve a polynomial equation you will spend more time setting up the polynomial only one bit of thing to remember the highest degree coefficient comes first another half a bit of thing to remember if a term is missing there must be a 0 here if you can remember all this then you can solve polynomial equations simply say roots of that is it now you have obviously this does not draw you are showing you the drawing to see that 3 and 2 is where the roots are so solving polynomial equation is very simple this actually raises a certain class of problems in the pedagogic and academic world you have a paper called numerical methods how many of you have to teach it or have to be around when it is taught any of you numerical methods probably they will teach for whole whole session how to solve using Newton-Raphson iteration and all that obviously we are going to use Python to do numerical methods you have a major problem in fact Tuna University is having that problem they somebody decided oh Python is so lovely so how do you do Newton-Raphson iteration using Python how do you explain that I think this is all you cannot see Newton or Raphson anywhere here so if you are going to use this to teach numerical methods remember it is a bad idea you are better off using a lower language like C if you want to use nr to extract a root go Python way if you want to understand how to implement any of those algorithms going to Python is the wrong idea because if you are going to use built in if you want to write by hand yourself that is fine you can write in Python if you are going to implement re-implement roots yourself that is perfectly okay but do not use the existing library functions to teach any of the algorithms it is a waste of time student will come over it is all of very nonsense we are the wasting so much time teaching this it is simply half a code that is not what you want to leave them there all right this is a what about x squared minus pi x plus 6 obviously known is ever going to use anything like anything like an artificial thing to solve you will probably solve it mentally and say x minus 3 into x minus 2 and be done with it but that is not the point we are trying to explain the method but if I have a solution like this sin z plus cos square z the 0 of that function here now we are discussing non polynomial functions and 0 of such non polynomial functions those require a little bit of extra work what is the extra work you have to import using this particular mantra has to be chanted once and you have to import that f solve and the argument you have to give to that is a function itself has to be given as an argument what you mean by that so I want to solve sin x plus cos squared x near 0 right so f solve takes two arguments the function and an initial value we wanted near 0 so let us say boom it says name z is not defined so we have not really understood how to use f solve not much of a news note carefully we do not declare it is not working we say we have not understood how to use f solve it is very much working it is complaining correctly so how did we solve this typically we had a z or x equal to lin space now z we have not defined that is the problem let us say z equal to we want a solution around 0 so let us define z over minus 1 to plus 1 z equal to lin space minus 1 comma 1 comma 200 now let us run our f solve it is even more angry now that is earlier the message could be understood now it is saying numpy dot indie array object is not callable translated to English it means it expects a callable as the first argument we instead gave it an array y array z is an array so sin z is an array you know that by now right so what we mean by a callable we have to give it a function but f solve is a function how is it supposed to get a function as an argument welcome to the world of modern intelligent languages python is a language where functions are first class objects functions can be passed as arguments to other functions functions can be returned from function as return values functions can return multiple values each one of which will give indigestion to a c programmer and nightmares to a java programmer so what we need to do we need to define an executable function and then give it the way to define a function we already know I presume define f of x is return sin of x star sin of x plus x sorry this is a pure function x is a place holder so now we go back to f solve and say here we cannot give x because z is the only you do not have to give z or anything actually you simply have to give f because f is a function what do you mean f is a function let us see what do you mean by f is a function functions are first class objects in python so I can do this now alpha is a callable it evaluates f all right so we need to say f solve we do not need all the complications simply say f and you get the answer the key the biggest thing we introduced here is the power of the language in that it allows passing a function as an argument another function essentially what is it doing you gave it an initial value 0 so it will evaluate f of 0 and evaluate f of 0 plus some alpha and f of 0 minus alpha how can it evaluate because f is a callable it will give two values on both sides of 0 evaluate then look at it and decide which way it should move in order to go to 0 so it will iterate many steps and go that is all so it requires the ability to evaluate the function f so we need to pass it the function itself in other words we need to follow it pass it a if you are writing this in C what would be the closest equivalent for f anybody if you are trying to write the equivalent in C what will be the closest equivalent for f what is called a pandering value that is a function pointer f is nothing but a pointer to a function made very simple to use inside python no complicated declarations complicated brackets and stars all over not knowing which combines faster nothing you need to know functions are first class objects they get moved around do you understand the idea the function f solve takes two arguments sorry I solved the wrong one I solved sin square z plus cos z that is why I got a different answer but the function f solve takes two argument the first is a function so we have to define it and then pass it note the absence of an argument we are not passing a specific value we are not evaluating the function at a specific point and passing that value you are passing the function itself loosely speaking think of it as we are giving it the function pointer so that the function f solve can repeatedly invoke g and we are giving 0 as the starting point because we want a root near 0 nonlinear solutions are notorious for instability problems so you have to give an initial value which is close to the 0 you want otherwise sometime they may not converge even now they may not in which case python will report the first time for 50 iterations there was no convergence so you have to either change the number of iterations or say that there is no real solution around that place for example it may simply have a point of inflection around that area rather than a function rather than a 0 so multiple evaluations on both side will simply give you a different signs but there is no real 0 there but those are issues only if you are going to solve very complicated equations for the purpose of teaching probably you do not have to worry beyond the important implication is the functions as first class objects in python concept to repeat functions can be passed as argument to other functions functions can be returned as return values from other functions and almost in passing functions can return multiple values every one of which makes for wonderfully easy readable and bug free program writing can we move on ok ODE is same story slightly different chanting to be done this time from sci pi dot integrate instead of optimize import ODE in then this is the differential equation you are setting up once you have done that you can solve a differential equation it suggest you look at it come up with the plot yourself and then also look at the next to two once again you will spend more time typing than doing if you appreciate this is the equation you are trying to solve d y by d t the number of infected people is why so d y by d t measures the rate at which new people are being infected we hypothesize it is the product of infected people and non-infected people and we want to investigate if this is the model of spread if we say the rate of spread is proportional to the product of the number of people and the number of uninfected people and the number of infected people then how does the epidemic spread that is the question we are trying to analyze and so we set up a differential equation of this type and in normal world what do you mean by a solution we are used to a solution is y equal to f of t a function but when we are discussing numeric or scientific computation for as a solution is a set of values for this t value this is the y value for this t value this is the y value essentially two arrays are the solution because we cannot okay we can that is called symbolic and if you remember professor Karnan's lecture there he did talk about symbolic computation in python also sage can do it but we are not discussing symbolic computation regular solution in normal terms means you will produce one set of values for the dependent variable and the corresponding set of sorry one set of values for the independent variable and the corresponding set of values for the dependent variable then you are deemed to have solved the differential equation for this t value this is the y value so if I want I can plot y versus t I didn't I do not attempt to provide a closed form analytical y equal to f of t where f is some complicated function that is not the goal of solution solving of equations in these sort of context agreed for example in the quadratic equation we don't try to apply b square minus 4 ac we arrive at the number directly because that is the purpose of this sort of computation. So once again setting up takes more time orient like notice e p i d is the function we just now set up which is essentially translation from maths to python of dy by dt equal to k into y into l minus y that is maths translated to python the same thing is here so that is e p i d having done that 0 to 12 61 points over that then we are looking at one year's time 12 months 5 points when each month you can think of it as time that is the scale you are looking at so how do I solve in other words how do I get the corresponding number of infected people at each of these points of time at point 0 what is it at the end of one fifth of the month how many people are infected that is the answer I will get in the y array so how do I get it simply type y equal to o d e into e p i d 250 t over where is the 250 coming from that is part of the initial conditions number of infected people at the start is 250 that is it and you will get something like this which is very cheerful it says ultimately everybody will get infected and that is when the infection will stop spreading further because there is no one else to infect not very cheerful but ok that is what the model is here please remember luckily you are not applying for a ph. t in biotechnology no one will give us that this sort of model but the goal was not that either ok but I want you to appreciate this key thing and also convey the same thing to the students what is the idea of solving in a numerical context mean it means arriving at this sort of value that is all not coming up with a close form answer that is something you will have to convey because in my experience students get very confused when they say we have solved it but they would not see a function because traditionally solving is associated with coming up with a close form analytic function when you do your research or your thesis work you are aware of no there is a difference but the average student may not be aware of this distinction. The next bit is about one more more complicated example of ODE here we are showing how we can solve a higher order differential equation by treating as a system of first order differential equations because a system means matrix and we know what to do with matrices you have lot of functions to play around with matrices and that is exactly what the next set of the exercise does set it up and you will arrive at the solution which essentially is the plot of both amplitude and what are the two things we are looking at and angular velocity as over time because that is what the equations were set up for theta and omega we decided to solve it as two differential equations theta and d theta by dt and d omega by dt. So, when solved solved within quotes you will get theta plotted as a function of time and omega plotted as a function of time if you look carefully you will see that when theta is maximum omega is minimum etcetera you know that when it goes to the end of oscillation the angular velocity is minimum, but the displacement is maximum and when it comes to the center the angular velocity is maximum, but the displacement is minimum which is a physical description of a pendulum which is why where it crosses the 0 and where that crosses 0 both of which you can understand looking at it and say yeah this describes a simple pendulum. Let me repeat there is nothing interesting or even remotely intelligent about solving using typing ODE into because there is nothing to it this is the two lines setting it up is again bookkeeping work you simply need to know how to set up your equations which is more of a bookkeeping work that is all having done that solving is typing two lines of course you have chosen a simple problem, but remember more complex problems simply mean more typing to set up solution is still the same online when it is all equal to ODE into this and that that is it you will spend more lot more time typing up this probably am I communicating stop here for a quick review just ran through some of the higher end modules the key observation with those modules is using them is very very simple once again it is simply typing half a word or one and a half words to get anything you want the actual process of using them requires some amount of setup some amount of bookkeeping, but once you do that the actual using for solving polynomial equations for solving linear equations or solving non-linear equations or solving differential equations is ridiculously ludicrously simple. If ever you have struggled with doing any of this for actual computation for any particular work then you will appreciate this lot more this is given more as see what all can be done rather than because we expect your students to be solving ODE is using Python as part of their program I do not know about postgraduate students may be they would be requiring, but chances are low for the others so for the others your goal in teaching these sessions to be to show how powerful and easy to use it is rather than you cannot be taking over the role of teaching them differential equations you have enough trouble as it is that is one piece of trouble we do not need all right.