 So, we have been looking at differential algebraic systems or DAEs and in my last class I gave some examples of semi implicit DAEs. We also defined what is called as index of a DAE. So, we have been looking at semi implicit differential algebraic systems. So, these can be written as dx by dt. So, these equations are typically written by this coupled differential and algebraic system of equations. So, this is 0 vector and x typically we call as differential variables and z we call as algebraic variables. So, these are differential equations which have to satisfy certain algebraic constraints and not all the variables appear with their derivatives ok. Very very common situation in chemical engineering models in chemical engineering unit operations. So, you have algebraic constraints which typically define the phenomena which are occurring at a very fast time scale whereas, the differential equations would represent phenomena which are at a slow time scale. So, in a distillation column for example, this would be thermodynamic equilibrium and this would represent dynamics of compositions temperature on each tray ok. So, we also looked at what is called as index of a semi implicit DAE. So, index is minimum number of times you have to differentiate this equation to get into minimum number of times you have to differentiate to get into a system of pure ordinary differential equations. Now, remember this is G here and I am writing another symbol here S which means that when you differentiate and get a new system of equations this would be different ok. The new system will not will be some function of G of course, but it will be different. Now, we will look at a specific example and then understand this. Last time I talked about a mixing tank example. So, this was a simple mixing tank ok. So, this was the example that we looked at dc by dt is equal to c naught minus ct by tau and c of t is specified that means, beta t is a known specified function ok. So, this is my G of Z and G of Z and X. Now, note one thing here this the first equation contains both algebraic and differential variable that means, see what is the differential variable here c ok. Algebraic variable by you know it is a semi implicit di algebraic variable will be c naught t right algebraic variable will be c naught t. Now, the second equation does not contain does not contain the algebraic variable and this can be a troublesome part. The second equation does not contain the algebraic variable you can get into difficulties while solving. Because, ct the algebraic constraint is an implicit is a function of you know is an implicit function of c naught t and the first derivative here with respect to c naught t is not equal to is not is equal to 0. So, is not non 0. So, we have a problem what is the problem I will just elaborate that. So, this simple example actually turns out to be an index 2 system ok. Let us go and see why this is a index 2 system. So, what is G X G? G X G corresponds to ct minus beta t right. Now, if I if I differentiate this ok if I differentiate this with respect to time then I will get dc by dt minus d beta by dt is equal to 0 ok, but beta is a specified function what is dc by dt? dc by dt if I substitute from here I will get c naught t minus ct by tau beta prime t is equal to 0 this is still an algebraic equation we have not got a differential equation yet. Because, I could substitute for dc by dt in terms of this ok I could substitute and. So, I still have an algebraic equation I want a differential equation ok to get a differential equation I will further differentiate this ok. So, from this what we get is c naught t is equal to tau beta prime t plus ct. So, I just rearrange c naught t is tau beta prime t plus ct and then I can now differentiate this I want an algebra I want another differential equation which is now look at this equation I finally, have eliminated algebraic constraint I have one differential equation in c another equation differential equation in c naught t ok. So, now this this is my this is my S of x z in fact, S of x z and t of time because beta double prime comes ok. So, this is my system with index 2 I had to differentiate twice to get to get a set of consistent differential equations first order differential equations. So, how will you use this index business will come to that soon ok. Now, what is the problem why do we have to worry about why why is it important to have index now let us look at this particular problem well when you have a high index system there are two difficulties one difficulty is that it is difficult to specify or it is tricky to specify I would say the initial condition what you will notice is that c naught t cannot be arbitrarily specified for a pure differential equation which is not coming from an algebraic differential equation ok. You can specify initial condition arbitrarily and see evolution in of course, the initial condition should make sense from the physics, but once you specify initial condition with that makes from sense from the physics you have a unique solution as long as dou f by dou x is differentiable and. So, we had talked about this continuity right in the beginning about existence of solution those things are not true here because of the algebraic constraint particularly for index higher index systems there is a problem. So, there are two problems now let us see where this the problem come from let us look at let us look at solving this particular set of equations using implicit Euler. So, implicit Euler would mean that you know x n plus 1 is equal to f x n plus 1 I am just dropping for the sake of convenience the time argument and sorry this is my implicit Euler would be this is my implicit Euler this is my I have to solve these two equations simultaneously or rearranging this you know you can write 0 equal to. So, you have to solve these two equations simultaneously if it is implicit Euler and if you are solving it using Newton Raphson for example, if you are solving it using Newton Raphson then you will get this matrix Jacobian matrix when you are trying to solve this using Newton's method these two coupled algebraic non-linear equations using Newton's method you will get this matrix this is Jacobian matrix that you know that you that you have to compute during each iterations if you rearrange and then differentiate you will get this now the trouble is with this dou g by dou z if dou g by dou z if this is equal to 0 then you have trouble solving this problem when h goes to 0 for small h if this is 0 you can land up into trouble. So, this the nice thing about index 1 systems is that dou g by dou z is not equal to 0 ok we saw that flash example in flash example if you write algebraic constraints and if you differentiate then you can show that dou g by dou z is not equal to 0 and then you can solve that problem simultaneously and get the get the solution without a difficulty in this particular case dou g by dou z 0 because if you look at here if you look here this is g of this is my g of x z that the differential variable only appears in g of x z algebraic variable does not appear. So, dou g by dou z is equal to 0 and then because this is a high index problem here this is my this is my g of c t c 0 t and obviously, c 0 t does not appear here. So, dou g by dou c 0 t is 0 and then that is why that is why you have a problem here. Now, what is very very important is that when you have a high index system this dou g by dou z should be when you have index one system dou g by dou z is not equal to 0 you can solve it for high index system ok. If you want to solve it it becomes very very crucial then to be able to specify the initial condition properly if you are not going to give the initial condition properly your solutions can diverge ok. So, I will just continue with the same example ok yeah we have to use. So, the solution is when you have high order system high index system ok you should actually differentiate multiple times go towards and then you solve simultaneously all the I will come to that. So, but now you realize there is one more thing you should realize now you should be able to find that thing using automatic differentiation. See now for simple 2 variable 3 variable thing ok I can find the index of the system by you know by hand differentiation and I can say this is order second index 2 system index 3 system index 5 system may be up to 5, 6 variables, 10 variables you will do lot of hand calculations and do it. If you have 1000 equations which is the case when you are simulating a chemical dynamics of a chemical plant section of a chemical plant you have trouble right because how will you decide the index you should automate if you want just given a set of equations you are not able to see what is the index. So, you should have a procedure that automatically differentiates and calculates the index and then does appropriate initialization ok. So, unless you do that you are going to get into trouble ok. So, I will illustrate this and then give the solution which is he has very rightly guessed that you know you should use those differentiated equations to develop what is called as consistent initial condition. But just to show what can happen if the initial condition is not consistent see this is. So, c 1 minus c 0 I am just using for this particular system I am just using the implicit Euler let us say my h is my this is the way I will use implicit Euler for this particular system on the right hand side at time 1 right I am going from 0 to 1 at time 1 ok and then other equation that I have is c 1 is equal to beta 1 right 1 is 1 is you know 1 here means t is equal to h that is what we mean by 1 in our notation of time we have taken t n is equal to n h. So, we use n right to denote the time it is a shorthand notation that we have. So, this c 0 is actually c h minus c 0 ok. So, these are the equations at the first iteration the very first iteration these are the equations ok. So, after you rearrange this you will get c naught 1 is equal to ok. Now, what happens for this equation to be consistent see what will happen with when when h when h goes to 0 this beta 1 will actually tend to beta 0 because h is you know step time from you know ahead of time 0 if h goes to 0 ok what we require is that if h goes to 0 for this equation to be consistent ok we will require that beta 0 is equal to c 0 we have to make sure when you start solving the equation that initial condition for c 0 is given as beta 0 ok. If you do not if you do not obey this constraint and start your integration ok integration can blow up ok. So, giving a consistent initial condition is very very important for a differential algebraic system extremely crucial ok particularly the high index DAE systems ok. Now, what do you do to deal with how do you deal with this problem for high index systems how do you generate consistent initial condition for a high index system no no no see beta 1 will tend to 0 as h tends to 0 as h tends to 0 ok 1 will tend to 0 right because see what is what is the meaning of 1 see this is actually t equal to h as h tends to 0. So, the initial value has to be given correctly you cannot arbitrarily see in a normal differential equation you can arbitrarily give c 0 and it will work here the constraint has to be obeyed that c 0 is equal to beta 0 if it is not obeyed you get into difficulty ok. Generation of consistent initial condition for a differential algebraic system now this is a key thing particularly for the high index systems ok. So, what you do is you write this so we define a variable y or vector y which is actually the x and z stacked up and then we translate this to some h of y y prime t equal to 0 ok. We translate this to y y prime t equal to 0 let p correspond to the index of d a e ok then we differentiate this p times which means. So, this is this is f y y prime t equal to 0 then d f by d t which will which will obviously have y y prime y double prime equal to 0 and so on up to you differentiate this up to p times ok and these are known as derivative array equations y p plus 1 p here means the order of the derivative f prime yeah p plus 1 sorry p plus 1 not p minus 1. So, these are these have up to p plus 1 derivatives of y ok. So, these are called as these are called as derivative array equations and to generate consistent initial conditions we have to solve these equations simultaneously ok. So, higher index system why it becomes difficult to deal with is because you have to solve these equations together to come up with a consistent solution. In fact, if you solve it at time t equal to 0 you will get consistent initial condition if you solve it any time in future at t equal to h t equal to 2 h t equal to 3 h if you solve these equations together you will get solution of the d a e ok. So, if you know the index of the system you can differentiate stack the equations together and then solve the stacked set of equations to come up with a consistent set of initial conditions as well as you can solve them in time and then you will get consistent solution of the d a e high index d a e ok to summarize. So, I think what Vishal was you had guessed right that you have to solve them together that is the solution you have to solve this differentiated equations together to get a consistent initial condition and of course, there is one more way you can go on eliminating high order you can go on eliminating high order derivatives and finally, you can convert it into a form which is called as pure od plus state n variant I will just mention the form and then solve that that is another way of doing it. But solving it at t equal to 0 will give you consistent initial condition ok. So, derivative array equations you have to solve you can you can see that why doing this automatically becomes difficult. So, developing dynamic simulators even though we have very very advanced computers and even though we have lot of knowledge now about solving large scale equations dynamical systems it is still something which is a difficult task because you have to do this business automatically if you look at some of these commercial dynamic simulators they do not ask you to specify what is the index of your differential algebraic equation. Obviously, when you are giving all kinds of constraints on the you know a heat transfer mass transfer thermodynamic equilibrium and the dynamics associated with each of the units you are not expected to know as a chemical engineer what is index whether this is high index system or so you have to automatically internally find out what index it is differentiate and create a stacked set of equations which you can solve. So, generating consistent initial conditions or use some other way of generating consistent initial conditions generating consistent initial conditions such that in consistent solutions is a is a big task is a difficult task and if you make a mistake there things can go wrong. The other approach is to reformulate I think I will again move there because I want these equations. So, the other approach is that you know other approach is that this derivative array equations then can be written in this form this is a pure ODE and this is a algebraic constraints. So, you can reduce by eliminating higher derivatives you can go on eliminating higher derivatives now this business might be pretty difficult for a very large system of equations, but for some simple systems you can obviously do this by eliminating derivatives we just now did this for the you know this mixing tank example we eliminated higher derivatives and so on. So, you can reformulate it like this and then solve it using a DAE solver which is so these are called as state invariants these are called as state invariants and and then you then you try to solve this set of equations using a DAE solver. So, with this I want to just close this very very brief introduction to differential algebraic systems my intention was to give you a flavor of what it is beyond you know just differential or just algebraic systems in reality you get always a mixture and then solving it simultaneously is a difficult task it is not that easy ok. So, you need to develop expertise in solving these and beyond the point as I said working with numerical methods and solving a problem becomes an art it is not just the mathematics it is you learn lot of tricks of the trade which everything is not written in a book and cannot be written in a book. So, for example, you know when you start solving problems you will learn that making variables dimensionless or scaling the variables all the variables helps improving the numerical accuracy or stability of the algorithms. If I have set of let us take a distillation column you know you may have pressure composition temperature appearing in one huge vector ok pressure might be you know Newton per meter square 10 to the power 5 something temperature is in you know Kelvin's 300 and concentration is in fractions mole fractions then you know you have a trouble in numerical integrating such things because the vector has imbalanced you know numerical values. So, it helps to scale them on a similar scale and then work with the scale variables and these things are something which you have to learn by experience ok these things unless you are hit by a situation where everything is fine and you do not get a good solution and you have to start thinking about now what to do. So, that is where you start thinking making dimension defining dimensionless variables and all kinds of other tricks. So, you just it is not enough just to know the mathematical background it is also important to know all these tricks which you can learn only through experience and as I keep saying in every of my instance of teaching this course is that the good part is that it cannot be automated you know that is why we are in business we keep getting jobs you know because you have to know some tricks and that is where the that is where you know you can still otherwise you know MATLAB or some software would be sufficient to solve all these problems. But even though you have very very sophisticated solvers and softwares and you still need chemical engineers who know numerical analysis to go and you know make fixes or make things work that is because everything is still you cannot automate it you have to have some kind of human intervention tweaking or chemical engineer intervention just make the problems solvable. So, let us have a quick look at what all things that we have done in this course I would like to summarize this course by saying that it is not a course on computational or numerical methods but it is a course on numerical analysis. We learn to do analysis here than just learning the methods if the aim was just to make you learn methods I could just go on writing recipes and you know you will not see the threads that connect them and then it just becomes you know you memorize it and forget about it after some time. The reason for developing it as a analysis course is that you should remember the you should understand the fundamentals behind how numerical recipe is concocted or is cooked or is developed and then you should have this confidence of coming up with a new recipe if you are encountered with a new problem. Every problem will be different every problem would require different way of thinking which will not be given in any of the numerical methods book because real problems are very very complex you will have partial differential equations differential equations you will have algebraic equations all coming together it could be partial differential equations in time and space some algebraic equations because you are lumping and saying that the spatial variation is not important okay you know and some algebraic equations because of some constitutive laws or thermodynamic equilibrium and so on. So you have very complex system of equations which you have to solve and solving mathematically modeling and solving it is becoming very very popular in industry in academics in research everywhere because you know you can do an experiment without actually having to go to the you can do a virtual experiment you can develop a model play with it understand how the model behaves hopefully the model at least represents in a respectable way the reality and then if you learn something from the model you know when you go and design your experiments or design your equipment or do control of a system you will have some a priori knowledge about how to go about doing it okay that is what we hope when we do modeling and so modeling is becoming very very important tool and then to develop models you should be able to solve them and get some reasonable solutions which make sense now most of the models that we encounter in chemical engineering cannot be you know the solutions for under different situations cannot be constructed analytically though we do study a lot of methods for analytical constructions of solutions that is more to look at some idealized problems simple situations okay and of course analytical solutions typically which you can find for linear differential equations or linear partial differential equations they give you a lot of insights they help you understanding how things behave they also help you numerical analysis to benchmark your approximate solutions to see whether approximate solutions are close to the two solutions so there are different ways where you can use analytical solutions and in some simple situations analytical expressions can be generated but even if the differential equations partial differential equations are linear not that every time you can generate analytical solutions if the geometry is nice okay if you have cylindrical you know some thing more which can be modeled as a cylinder or it can be modeled as a perfect you know sphere or some cube some nice geometry then you know it's easy to solve those problems but if you have some weird geometries even if you are linear partial differential equations you still have to go for numerical solutions you cannot construct analytical solutions with some weird geometries and the real problems are with weird geometries okay so computational modeling or computational fluid dynamics very very important part nowadays in design of chemical systems now the way we looked at it the difference about this course and most of the other books which present a course on numerical methods for engineers is that we did not we did not look at the methods based on the types of equations we looked at methods from the viewpoint of tools okay so the basic idea was that you have from a real system you develop a mathematical model this mathematical model typically would be you know algebraic equations or non-linear algebraic equations or ODE or PDE some kind of some kind of you know some kind of algebraic differential partial differential or their combinations that kind of an equation typically for the situation for which we would like to study this this coupled set of differential algebraic partial differential equations cannot be solved analytically unless very very rare situations okay so then we said that this we have to transform the problem so we spend a lot of time in understanding how to do problem transformation so using approximation theory you get a transform computable form this transform computable form in terms of its structure could be completely different from what you started with you may have started with a partial differential equation you might get you know algebraic equations non-linear algebraic equations so what the transform problem could have completely different structure from a mathematical viewpoint than the original problem okay what you end up solving is the transform problem typically and not the original problem except for some very very rare situations where analytical solutions can be constructed okay now then we said that to solve this transform computable form we only have you know three or four tools so one tool that we said is solving linear algebraic equations so solving ax equal to b this is one tool so this tool is used then the other equation or other other tool which is very commonly used is solving non-linear algebraic equations so this is f of x equal to 0 okay then the fourth tool third tool is the third tool is ODE IVP solver so this is my third tool and the fourth tool that we did not discuss would probably form part of a advanced course stochastic methods okay random sampling based methods so we have three or four tools it's like you know it's like you are a doctor with you only have three or four tablets with you and you have to create a concoction you have to create a recipe that will cure the patient so you have to use some combination of these four tools okay and then what you get finally is approximate now is it sufficient that these four tools are with you it is not okay you also have to give inputs if I think in terms of another input that goes is to solve a problem you have to have some engineering insights insights from physics chemistry thermodynamics whatever because you have to give good initial conditions which make physical sense okay so this component cannot be ignored this is in fact the most vital component it is not enough to have these four tools you should know limits of these four tools you should know about you know things like stiff differential equations you should know about you know ill conditioned problems and well conditioned problems and condition number and eigenvalues and a relationship to convergence and so all this all this analysis that we looked at should be there in the back of your mind when you are solving these problems one of the focus of this course was analysis we looked at how to do convergence analysis how to use eigenvalues particularly for solving linear algebraic equations iteratively we could use you know the theory of behavior of difference equations linear difference equations and understand under what conditions the error will go to 0 same same you know theory of linear difference equations qualitative behavior of linear difference equations based on analysis of eigenvalues also came to our help when we looked at you know different numerical solvers for OD IVP we looked at convergence of error between the true solution and approximate solution when with it and how do you choose integration step size all that was you know analyzed using linear difference equations okay so these are these are tools that help us well for Newton's method I just touched upon contraction mapping principle no we could not go deep into it so the idea was to give you flavor okay I it is not possible for this this is a course that would prepare you for research it is a course that is between your undergraduate course and an advanced course really advanced course it is somewhere in middle okay what we are doing is a course which is pitched in middle where you know you are introduced to various things like sparse matrices sparse linear systems then how you can speed up your calculations finally we came to you know combine things like differential algebraic systems together and what are the complications okay now things like solving partial differential equations boundary value problems all was dealt by approximation theory okay if I if I go back and see what is what plays most crucial role in this is how do you approximate what are the tools for approximation Taylor series approximation then collocations or interpolation polynomials okay or interpolating functions in general and these squares polynomials or v square functions v square approximations now what is the origin origin comes from we are Starr's theorem that any any continuous function can be approximated with arbitrary accuracy using a polynomial function of a suitable order okay so so this this one idea which was discovered more than a century back you know it actually forms the seed of what has happened later on okay entire structure actually critically depends upon this fundamental idea so basically we cannot really solve most of these problems exactly we have a real system there is a level of approximation when you develop a mathematical model a lot of simplifications when you approximate reality using mathematical model okay the mathematical model that you construct and situations that you develop again you know you cannot solve them exactly you have to further approximate if you want to compute numerically when you are computing them numerically there are further difficulties there is an error committed when you go from reality to the mathematical model from mathematical model to the computable form because typically you we looked at these different spaces associated and we said that the original problem is typically in the infinite dimensional space you are approximating using a finite dimensional approximation so you have limitations so there is a lot of error committed when you approximate problems in infinite dimensions with problems in finite dimensions because finite dimension problems are computable further when you solve using computer computer has limitations you cannot represent every number in the computer it has a finite precision whatever bits you use 128 or 256 you have a limitation at some point and then that's where there are errors coming because of limitations of your computer okay so what you actually want to do and what you finally see there is a lot of difference you have to use this part this is the most crucial part which i cannot teach in the class this you have to develop by solving many problems using all these theory using the analysis which i taught you unless you start using it you know it's like you have been given tools if you don't keep using them then they don't remain sharp you know and then you will not understand why so hopefully you know you understood why behind most of these methods and then you'll be able to carry it with you and so it was enjoyable teaching this course for your class and i hope you have learned something so with this i would like to close this course on numeric analysis just remember this entire diagram and don't forget what is most important is your engineering insights and physics which you cannot forget all these are tools which will help only if you give correct initial guesses only you make correct choices there is no unique way of solving a problem okay each one will come up with a different recipe or different concoction you should have confidence to make a new bilpuri when or a new concoction okay when a new problem comes that is important that's what i wanted to learn through this course