 Okay. Well, welcome to Math Modeling. My name is Rauro Cascaval. I'm faculty in the Math Department, and I'm glad to see some of you that I know, and I'm anxious to see you to learn to meet everybody else. So, let's see. I'm going to start with a few things about the course, general things, and then hopefully quickly start talking about what Math Modeling is and why do we learn it. I have a website that I'm going to post everything pertinent to the course. There's also going to be a lecture archive, so the video of the course, as well as the notes. So, hopefully you're going to have everything in your hands to succeed. I want to say a few words about the syllabus. So, everybody got a copy. So, there's going to be a required textbook. I want to make this clear. That is the third edition of Meershard. In addition, I list, I think, two other or maybe three other courses, three other books, actually, two only, that I will use during the semester to bring more examples or more problems. Now, they're not required in the sense that you can actually download them for free, chapter by chapter, and I don't know if you're familiar with this Springer website that you can download. You have to be on the campus network. But if you are or if you're at home and you're VPN, then I think you can access these. So, the first one is called mathematical modeling case studies and projects. Again, if you don't see this recognized as, it means you're not on the campus network. So, if you're in Honolulu in Spring Break, make sure you need a chapter of this book. Hopefully, you won't, but make sure you get to the VPN. So, what you do here is you can actually download individual chapters. So, for instance, and one thing that I should say is that you shouldn't rush immediately and download everything because I think this is here to stay for the semester. But regardless, you can go and kind of browse. We're going to start talking today about optimization problems, but these problems do not actually apply yet. So, we're not going to use it, but I just wanted to show you. You can download these and I don't know why this happens, but because my browser doesn't like this. Anyway, second time it works, I don't know why. But basically, you have the chapter in your hand, print it, keep it on your computer. If you print it, I recommend you take all the trees. So, you print only like double-sided, two pages or four pages probably too small. So, that's about these books that I list here. I specifically look for books that won't cost anything, but the funny thing is about this first one is actually, if you look through the format, I think it's identical. The authors must have talked to each other with the book that we use or what's more likely is these people use this book and then they came up with more examples. So, anyway, it will be almost identical. The second book is, again, it's also free downloadable. You can also buy a copy. The nice thing about this second book is you can, if you go here, some of these books on Springer Link, you can actually buy a print copy for $25, $24.95, including shipping. Anyway, so that's for convenience. This is not advertisement for Springer Link, but I think it's extremely useful, but you can print again chapter by chapter. Okay? I should say the second one contains some things that we're going to be talking about. Maybe more. Graddy students will use some of the chapters. So, we'll talk about this later. But anyway, so the important thing is we're going to use this extensively, so make sure you have a copy. And this is not free downloadable but anywhere. If you find it, lucky you. Okay. So, any questions about the textbook? Okay. Now, even on the front page, I kind of make this clear that we're going to be using computer software for solving this problem. So, you probably know already. I mean, my preference is to use MATLAB. So, I'm going to be using MATLAB. I don't expect that you guys have had exposure to MATLAB. So, we'll talk about a little bit about what it does and how you can use it. But it won't be the focus of this course. It won't be to become experts in MATLAB. Okay. I'm going to show you basically the way we're going to use it is we're going to learn three examples. So, I will post things on the website. So, here's one. I already posted like a first exercise, I mean, an example in the book. So, I give you basically, I give you the code. What you need to learn is how to use it, how to modify it. I mean, you have to learn what it does and how to modify it. Okay. Never seen MATLAB before. This might look strange. Okay. But that's how you, you know, make the computer do what you want it to do. So, I'll talk about the format. Keep in mind, all it is is a text file, the text. But it has an extension dot m. Okay. And so, anyway, so we'll learn how to run it, how to, you know, modify it and get the output. I want to say from the beginning, so that once you write a code or you use my code or you use a code, a MATLAB code, you run it, you can actually write a report or you can write a code in a way that it gives you a report. So, a report is in HTML format or it can, well, then you can PDF it or whatever. But that's sort of how I would expect the part of the homework to be turned in. Okay. And again, it's, it will be really quick to explain this thing. So, I just wanted to show you, okay. Now, here I talk about basically what it is and why we use it. It is available for free in the computer labs. In fact, I think in all, throughout campus now, we have a side license. So, it should be installing the library when the new computers come, which should be convenient. You can also access it remotely. How many of you have heard of remote access to, okay? So, if you, if you have not, there is, there are some instructions here how to get access to MATLAB remotely. But again, if it, if you're at a computer that has MATLAB installed, you know, that's, that's all you, all you need. Well, you, for convenience, if you need it at home, you can, you can purchase it on your laptops. You can purchase a student version, but for most part, you can do it on remotely or, well, you can do it remotely period, or you can do it in a lab. Okay, so I'm going to make a plug for a course here that's kind of shameless advertisement, passes around. So, this is a syllabus for another course, which is not a required course. There's not a prerequisite to this course. But it is, it is a course that we offer. It's a one-carat hour course, Math 265. And you've probably got an email about this. So, the only thing I want to say is, is got a quote from a student that took it last, last year together, you know, at the same time as Math 448. And that's, that's what it is. So, if I could read it, it says, I found the MATLAB course invaluable in taking modeling last year. There are only a few of us from the modeling class at Tuke, the MATLAB course, and we became the go-to individuals in the modeling class. For providing help to those that do not know MATLAB. Mathematical modeling is B, and I would highly recommend it, that if a student does not know MATLAB, they take Math 265. The fact that it's a challenging course, I live, this is a personal opinion. So, well, everything is a personal opinion of this particular student. And, but the, there is sort of a truth to this. And I wanted to mention it here is that if you, if you have never seen MATLAB, or if maybe you've seen it, but you'd really like something. Thank you. More systematic, we offer this course. And it is surely before this class. So anyway, end of, end of, end of advertisement. Regardless, I think the point, the point that I want to make sort of from the beginning is, it may not, this class may not be the, how you've, you know, done calculus, or if you've done ODE's, you know, differential equations, or lean algebra, or what not. Because it really requires that you use a computer. I mean, you cannot, you cannot just sit with a pen and pencil, and a pen and paper, and expect to, to do it. Okay? So, if you're very proficient maybe in a different language, you know, you can, and say, I'm totally against this, this, you know, software. Okay? Maybe you can go by, you know, the first few assignments. But then it gets to a point where, you know, what I show you in MATLAB may not be, you know, easily doable in another language. Okay? And then it becomes, it becomes kind of difficult to communicate with each other, and it, and that's, you know, or maybe at some point you decide, oh, I can use three of them at the same time. That's fine. That's fine. But the point is you want to make sure that you can communicate the outcome of your work to me. And I cannot use five different languages to explain the same concept. Okay? The book actually has somehow, if you read through the book, it has an example in Mathematica, an example in Maple, and then an example in, but not something derived, which I honestly don't know much about it. Okay? You will, you will very soon, I mean, unless you are proficient in all of them, you will soon realize that, okay, well now, what am I using to, you know, to solve a problem? Okay? So please keep that in mind. If you have doubts and, you know, feel free to come talk to me or about this, this aspect of the course. Okay? It's not like you sit, you know, somewhere and you take a derivative and set it equal to zero and you get the answer. I mean, or use your graphing calculator for this. Okay? Now, that being said, the choice that I made for MATLAB is because MATLAB is sort of the standard software language in this field. Okay? It's, it has evolved over the years. I mean, it was sort of started by mathematicians. Then the engineers picked it up and they developed it a lot. And in the past 10 years, it came back with a lot of capabilities that we need as, you know, in mathematics, one of them being symbolic computations. Okay? So we'll talk about those. But MATLAB is primarily used for numerical computations that is with numbers rather than with symbols. Okay? So that kind of distinguishes different computer algebra systems. Is it really powerful in a symbolic computation world? By symbolic, I mean, what's the derivative of x squared? Well, a symbolic software with symbolic capabilities would tell you it's 2x, right? And numerically, it's, well, you tell me the point where you want to take the derivative and I'll tell you the number, right? So it just takes a little bit of, it makes this distinction. And for most of what we need is numerical computations are essential. Certainly symbolic are useful, too. So anyway, so that's sort of a reason behind MATLAB. Don't just say anything else. So you have everything printed there. One thing on the home page here I made a link to a MATLAB resource page, which lists a bunch of things you can explore. I mean, you can do everything nowadays pretty much. You can find lots of resources, free resources on the web. There are whole books. There are two books by actually the inventor of MATLAB that he made available online. Lots of codes. The best way to learn MATLAB is look at the code, see what it does, modify it, okay? Use the help. So I'll show you in a second. Okay, so there are a bunch of tutorials. Maybe one that I found, again, the best way to learn is take the math to 65. Okay, you'll hear me say this first two weeks a lot. But short of that, again, there are lots of them. MathWorks, who's the company behind MATLAB has lots, a list of tons of tutorials, tons of video. I don't know how efficient they are. I mean, certainly it depends on the personal taste, personal learning style. You can take advantage of one or the other. But the one I found kind of useful is almost like a cheat sheet. I must say that no single tutorial will actually cover what you need, okay? That is to say, if you've done it, okay, you invested time, you spend an hour, two, three, go through what the tutorial says, and then, yes, I know it, right? So every time you kind of run into a math problem and you need to use something, there's probably something you need to learn about the computer function or some, okay? But just to give you this example is it goes through sort of how to start, you know, how to operate with MATLAB and other things. I will show you a little bit of this myself without a formal tutorial. But again, if you need, we actually have even the UCCS website has a few tutorials down here. The web is full of tutorials. I wouldn't recommend that you go and start hunting for the one that works for you. I mean, to spend days and days and then get frustrated. There is a huge resource this semester, a MATLAB tutor. His name is Terry Spence. You might not know him, a graduate student. He will be available nine to one every day, actually. So if you need questions about MATLAB and assuming he's available, he'll answer them to you. I was thinking to actually block a few hours of his time just to, you know, so you have sort of priority, but it's up to you. I mean, you're the drivers. I would say, see how it works. If you need, you know, if he's extremely busy with other things, maybe we can block some of his time. But, okay. So, again, lots of resources. At the end of the day, halfway in the course, if you, I mean, I'll just tell you this from experience of other students, is if you feel like, oh my gosh, it takes me, you know, 50 hours a week to just do things in this course, something's not right. Okay. I mean, we're not, as I said, I will give you kind of the sample codes. I'll give you the, you know, the codes that solve the problems we're talking about. Maybe in your homework, you're going to have some change, something change, something slightly different. You can, I mean, you should be able to just modify it and do it and report and go forward. Okay. The goal here is not to learn everything in MATLAB. Okay. And again, I'm repeating myself, but the goal is to solve math problems and math modeling problems. And use it at some stage in that process, use MATLAB in that process. Okay. Let me say anything. I will post the homework here. So the first homework, I say it's going to be due next week from today. So that means we have to start talking about something fairly soon in chapter one. And I mentioned the exams, so there's going to be a midterm and a final. So that's, and the graduate students, I think, will have some sort of projects on top of that. So I think it's all in the syllabus. The lectures are going to be available on the website here. If you're not familiar with this, first time you visit the lecture page, you might be asked to do something, but, well, okay, we know who to blame this, right? Anyway, you're probably familiar about the video archive page. And it should be also an iTunes, so anybody knows iTunes? If you, yeah, you can play with me. I mean, just, no, but I mean, the point is that you can subscribe to the feed, sort of, so you get, it downloads automatically on the computer. It's not perfect, but anyway. All right, so finally, so here you just register if you've never done it before. Otherwise, just sign in with your name and email address, okay? All right, I'm really done, I think. Any questions? Yes, no, none? I have a tentative schedule here. It's kind of on the conservative side, but meaning that we might actually, we hopefully will be ahead of it, but if not, hopefully won't be too much behind it. But the important thing is to almost forget about that print copy of the syllabus and always refer to the website, okay? All right, so let's, no questions? Yeah, that's, as long as you don't do other things with it, that's fine. Yeah. Any other questions? Yeah, okay, I said it's not perfect. It's going to happen in a week or two, yeah. Yeah, I actually had it before spring break, but then it's kind of set. There might be an in-class and a take-home portion, so I'm saying, you know, the in-class should be set, okay? And so don't plan on not coming back from spring break. Okay. Anything else? Yeah. Considering this is done, what's the difference in work-like homework? Homework is the same project. So it's going to be a project that the grad students will have to do. And I did not, I talked about it in the syllabus. I haven't given the details yet. I will talk about this in the next two weeks, two weeks. Yeah, I don't think so. I think you have to be enrolled in, yeah. But yeah, you're welcome to. So again, this is, okay. So let me start talking a little bit about nature of this course. And then one thing that's nice about modeling is that it appeals to lots and lots of fields. I mean, it is sort of what math can do in all the science and all the fields, right? So probably some of you are not necessarily math majors. And everywhere you go, you see, oh, I want a math model, right? So you can be very powerful. Not at the end of the course, but if you become, if you have an expertise in modeling, you can have a career in it, right? Now, a course is not going to give you the full expertise, right? In fact, it's going to actually just prepare you or expose you to what it takes when you are in an environment where math modeling is required to actually do something, okay? So even though here we are working on baby models, baby, I mean, in examples, textbook examples, right? That's how they say it, right? We're not solving a problem that the company in Woodland Park would like us to solve, right? Or some very extremely concrete problem that if you solve it, whether you solve it or not, it depends on the existence of that company, right? So we're going to learn about aspects of what it takes to set up a model, what it takes to validate a model, what it takes to solve it, you know, and actually what's extremely important is what it takes to communicate what you've done in the model with the people that have no clue about mathematics, okay? So those are sort of the main goals. The examples we're going to cover, I mean, are by no means exhaustive. So these are the two kind of resources that I gave, two other books, just complement, you know, add to those list of examples, but even those are not going to be comprehensive. So if you have an interest in some whatever, right, it would be actually nice, you know, certainly come talk to me, see if we have the tools, okay, or if we'll ever learn the tools for that particular situation, we may not, right? So one other thing that I should say, like, in both the books that I mentioned, not the required one, there are a lot of models that require partial differential equations. And, you know, many of you have not, you know, taken those those courses, so, but that certainly opens up, you know, a huge pool of problems that you can model, okay? So the more math you know, the sort of the broader the coverage of your, you know, expertise can be in terms of math modeling, okay? So I'm not saying anything fancy here, I'm just pointing, you know, sort of, if you have an interest in a certain direction or a certain, you know, maybe you work in some company or maybe you will work in some company, I'd like to hear about it, okay? And I'll be happy to, you know, look at other references, you know, other things. You might be doing a project, you know, even if you're not grad students. And all I want is that you have a rewarding experience. At the end of the day is you finish the course, not because you had to take it, but because you really, you know, fit your interests, okay? So there are three main kind of motives that we're going to be touching in this course. So sorry for my handwriting, but it's going to get better hopefully. So the first kind of big pool of problems are going to be label optimization problems. Because they're in practice, you end up with many questions that where you want to optimize some, you want to maximize some profit, you want to minimize some cost, you know, the things going on in different fields. In all the fields, you can actually set up a problem where you need to, you can set it up so it's an optimization problem. So we'll start with those, and that's going to, you know, lead us to a lot of the applications. They're going to talk about dynamical systems, models, problems, and as a subset sort of of those, we're going to be talking about control problems, and sort of the last one, sorry for the, it's actually here, the last kind of class would be probability models. Now, if we had all the time in the world and we would really go into details in all of them, I will probably talk least about, I mean, spend least amount of time on the probability models simply because, you know, you can spend a whole course on those. There's a, of course, we offer another course, a casting model, modeling that really, you know, discusses those, but we'll talk about some of this. Okay, so, and by the way, I should say, I like when the class is very quiet, but if you really have, you know, if you have any questions, just don't be shy, just interrupt and ask because, you know, I mean, then that's pretty much how you learn. I mean, being active, not just passively listening to somebody talk about. It would be ideal if you all had computers or if we were in a computer lab, but, you know, that is not the main, you know, as I said, that's not everything that we'll do, so there will be some paper and pencil part in each of the problems. So, let me talk about optimization a little bit. Start talking about what is optimization? Well, in one dimensions, so, what do I mean by one dimensions? Basically, I mean that I'm looking at a function, you know, some variable that depends on another variable, right, just one. One variable, you know, real numbers, X, and I have a function that depends on that X. And what I want is I want to maximize that, right? I want to find the maximum. So, this is Y equals F of X. Okay, then you graph it and you look at it and say, oh, I see maximum, that's the maximum, right? Well, sort of, in practice, what do you, you know, typically what you do is you have, you know, you don't just have a function, I mean that's not the starting point, right? The first part of the problem is find the function that, you know, has an expression that you can deal with, right? Well, graphing may not be too difficult once you have that function, right? But graphing is not the end of it because you may have a maximum that you don't really see on a graph, right? It could be, the scale could be so huge that you may, you know, you may not see a maximum or you may see lots of maximum and so forth. So, of course, theoretically on paper, what do you do? Today's derivative and the first thing is see the critical points, right? So, you say that we're equal to zero and then, hopefully, then you can decide, you know, is it maximum, is it minimum, is it inflection, is it neither or so forth, right? So, that's calculus one. In reality, coming, you know, problems coming from, or functions coming from models from mathematical models of a realistic problem is taking the derivative maybe impossible, right? Let's say you're lucky that you have a function that you can just write down very symbolically. Then, okay, maybe you can take the derivative. The next hurdle is finding the solution of f' equals zero, right? That's not always possible to rule it explicitly, right? So, you really need a computer for every single step of this and you have to deal with these situations where you may not get an exact answer for each, right? So, you probably know, I mean, you know that even if you have some, I don't know, some function like this, I don't know if this is a maximum or not, but I don't know, let me put a minus here or something. Then, the derivative, so this isn't the case where you have the function. You can take the derivative by hand, but now you are facing the task of setting this equal to zero, right? And what do you do? You need a calculator, right? Okay, so you can do this with a graphing calculator. No big deal. But because of the nature of the things, it's probably better now to use one of these computer algebra systems. So, I will show you very, very briefly how to solve this in MATLAB. And then we're going to move to a baby problem that actually you have to start from the very beginning to even say what X is, what is F, and so forth, right? So, set up a model. So, we're going to set up a model. Let me just open MATLAB since I've talked so much about it. I'll show you really quick how to use this to solve this. No, I do have it locally on my machine. But if I don't have it on my local machine, I can remote desktop to what's called RADS, R-A-T-S, dot-E-S, dot-U-C-C-S-I-T-D-U, and use your U-F-P credentials. And what you do is you just go on this remote machine that you have access to lots of software, not just MATLAB, just lots of software, okay? I don't know how long it's going to take. But anyway, so I have access to... I get MATLAB, and I've never seen it before. And what you're probably going to see and the first time you open it is kind of cluttered, have all this kind of stuff, right? So, for the most part, I'm not going to be using the folder. I'm not going to be using the command history. Let me leave this what's called a workspace. I have these two windows, which I can play with. I have some garbage there. I'm going to clear it. CLC clears it. Okay, so this is how you start fresh, okay? So I simply want to solve that optimization problem, right? Okay, so how do I do? Well, many ways you can do it. But the one way I want to start with this is do it symbolically, okay? Remember, that's not the strength of MATLAB. Okay, but it's convenient that it has this capability. And by the way, if those of you that have used RATS before to connect remotely, now, even remotely, you can do symbolic computations. In the past, you were not able to do it because of, I don't know, 64-bit compatibility and so forth. But anyway, so right now, everything that I show you, you can do it remotely as well. Okay, so the first thing that I do is... And this is kind of unusual for MATLAB to have to define that I'm going to work with X, okay? But again, we're living in this symbolic, you know, we're working with the symbolic objects. So, I mean, that's the price of prey, which have to define, we have to say, we're going to work with X, okay? All right, the next thing is I'm going to define the function, okay? And you can see it, I mean, it's obvious, right? The way you define it is just equal, okay? It's not like other software, it's just simply equal, okay? Now, this is a command window, and MATLAB is just waiting for your next command, okay? Yeah, is that what it was? X squared is the derivative, yeah, yeah. Right, so when I take the derivative, it's going to be 2X, let's see. All right, now, let me clear this. I'm going to start fresh again. I mean, I'm not really starting fresh. If you look in the workspace, you can see those two objects are already defined there, right? So X and F. And they're symbolic, right? So that's what it says, it's symbolic, and it's a one by one. So the big thing you have to know about MATLAB is MATLAB thinks of everything, every thing that it works with is a matrix. So if it's just a one thing, I mean, if it's just a one scalar or not one number or one object, well, object is wrong, it's just a one by one, right? So number three would be thought as a matrix, but a one by one matrix, right? So here it's a one by one symbolic. So you can see it can make a two by two matrix with each entry a symbolic variable. Okay, but anyway, so I've defined X. I didn't have to do it again, but I'm just trying. And the next thing I'm doing is a semicolon, meaning it goes through that command, but it doesn't display something as a result, okay? Just to keep it kind of short. Okay, so that's that's that. What's the next thing to do? You can differentiate, you know, and there's going to be commands that you probably don't know if you haven't worked with MATLAB. And the best way to do it is, well, I want to say most of all the commands, well, all the commands, I want to say all, but probably it's not true. All the commands that you will ever need in this course, you would have seen prior to you having to work on the problem. But if you ever kind of need something, you can always go to help. In fact, this FX here has a list of all the functions categorized, so you can, I don't know, probably mathematics. Actually, yeah, they can go mathematics or it can go to, one thing I should say here is one peculiar feature of MATLAB is it has a core set of functions, and then it has functions that are very specialized for, let's say, control systems or image processing, right? So each of these has a very specialized set of functions. Now, the one where you have symbolic capabilities is called symbolic math toolbox. So if you don't have this listed, you cannot do symbolic computations, and you would get an error when you type SYMS, okay? Would you be able to get all those to rats? Yes, no. Okay. Which is a big, okay. So anyway, I don't want to go through much of this. I just want to show you how it works. So you can find things like that there. It does display the answer, right? Symbolically, right? And if you ask me how I did it, I don't know. It's just magic, right? Just took a Calc 1. This computer took a Calc 1 class. You recall, right? When you learn about derivatives, you just know the rules, right? So I imagine that these rules were kind of embedded in this, but anyway. But notice that I have a new variable called ANS, which I didn't call it that way, right? So one thing that you can always do just to make sure that you keep track of what you've computed is to call it somehow, right? So I call it DFDX, but you can call it whatever, right? You can give it a name, right? You can Fx, or I don't know. Let's call it Fx, okay? So now it has created the Fx, and it kept it there, right? And it's this function. It's still symbolic. Well, okay. So we're wondering how do you... I keep deleting so you don't have to scroll. I guess you can do it. You can see on the bottom there, too. But anyway, everything's still there, right? I just cleared the screen here, but... So let me plot this function. Easy plot, Fx, okay? So I'm just showing you the real basic commands. Sorry if you're familiar with this. But all right, so now you see it, okay? But it's hard, right? It's hard to say if you have a minimum or a maximum, right? Well, it's not hard to see. I mean, in this, by the way, why negative 6 to 6? Well, easy plot uses negative 2pi to 2pi as by default. So it's 6.28, right? But you don't really want that. Now, here's one thing that's going to happen. You see this window here that pop up here? Now if I want to go and do something else, the window disappears. Okay, it's kind of frustrating, okay? Don't spend hours to find that, okay? Just listen to me here to find that figure, right? So where did it go? Well, it didn't go anywhere. It's just somewhere here. Okay, and this is window 7, which is a great thing that I can find it, right? But I, you know, I didn't have to wait for window 7 to show up to find this figure. What I can do is I can actually, what we call dock, right? So I can dock this. So I still have everything on full screen, and I just want to keep it, right? So I've docked it. Dock is this thing here. I want to have every single window to be on the same screen. Okay, so, okay? So hopefully everything is going to stay there. And now, let's say our x is only positive, 0 to, I don't know, you see, 6 is kind of big, right? Let's do 4. Now, if you put, instead of square parenthesis, if you put, you know, just parenthesis, I think it's going to give an error. So there's going to be stuff that you're going to be frustrated initially. Okay, what do I do, you know? Don't spend too much time on this. Just kind of look at the help, or whatever, right? Gosh, so hard to see. Do I have a minimum? Oh, I have to go. Well, I can see that between 0 and 1, if there is a minimum, that's going to be the minimum, right? Hey, and there's the minimum, right? I have to say I'm very lucky, because I just picked that at random, but... Okay, so, you know, it's a big issue here. How do you get to the thing that you want to conclude, right? Well, plotting has a lot of limitations, okay? Because you don't know what the window size should be, and so forth, okay? And this is an easy example. We're doing the calc 1 stuff, okay? So, we have not a maximum but a minimum. Okay, so, well... Oh, thank you so much. We're dealing with a derivative. Huh, I'm not plotting... Yeah, I'm plotting the derivative. Thanks. I should have looked at... Well, okay, so I'm not so lucky then. Let's go back. Okay. All right, so what should I do? Let me go back to 0 and 1 here, right? Well, so, I'm not looking at a maximum, thank you. But I'm looking at what? Zeroes of this function. All right. Okay, so the zero of this function is... It doesn't look like it's in this interval, right? It doesn't look... But it looks like there is somewhere. That's the other thing. You should keep things in perspective, right? Don't change the problem. I've changed the problem, right? I was looking at other things, right? I'm looking at the maximum or minimum of the function. So I'm looking at zeroes of the derivative. Okay, so, well, being a cubic function, I know there is a zero, right? Okay, so that wasn't random, but where the zero is is still not very clear, right? So I have to ask the computer, how does... Okay, so I have to solve fx equals zero. And what do you know about cubic functions? The difficult to solve, it's not impossible, but you're going to get cubic roots, all kinds of stuff. There are some formulas, but you don't even want to know. I see some complex numbers here. So, in fact, it's a big mess. In fact, if you look at the answer, I didn't call it anything. You see it's three by one, so I have three solutions, right? It found all three solutions, but they're not all real, right? So they found one and two complex. Where are those complex roots on the graph? So there's only one x-intersect, right? Of f prime with x-axis. So it's not easy. Well, okay. But first of all, let's... Let me give it a name here, x-crit. I don't know, x... This is the... Believe me, this becomes challenging. How should you call something? X-crit, take all whatever, okay? All right, well, now, at least I don't have that ANS, but I have this. It's too long. I should have called something shorter. But anyway... Now, here's where Matlab comes in handy. You can actually, of course, see the same but in a better way, right? Not symbolically. This is almost like... It's a symbol, yes. You could almost see the square roots or something, right? I think you can... Well, you don't see them here, but you can... Well, okay. I just want to see the solutions. So I use this double command, double, and it converts. You see the answer now? It's something you can visualize, right? Almost negative one, but not quite. This double command... Does anybody know what it does? Yeah, but not just that. Right, double precision. But the one thing that everybody has to understand is we were doing our computation in a symbolic world, right? Double brings it into the numerical world, okay? It's a big... Okay, so now it's like a... It's a huge change, okay? You may not show like this, but it is... Now it's a number that Matlab is really happy to work with, okay? These complex numbers are... Matlab is very comfortable with, okay? All right. What else should I say? Of course, I didn't give any name to this, so I should call it somehow, right? I don't know. You can even call it the same thing, as long as you didn't... Well, right? You can call it... If I use this name, right? I made a conversion, but it's... It just changed that nature of the... Yeah. Right, so if... Yeah, so that's a computer science question, and I only know a little, but I know that the variables that are stored, so the things that are in this workspace have some memory allocated, right? And as long as the size of that variable doesn't increase, it just used the same memory allocation. Sometimes what will happen is that we will increase the size of... You know, we could call the same variable, but increase its size, then it becomes... There are some flags that show up. They say it's not very optimal. Anyway, so optimizing the memory usage and so forth is an interesting thing, but not really mathematical. Okay, so final thing. Remember, I told you that MATLAB comes, has this... Everything MATLAB deals with is a matrix. Okay? So this thing now is a matrix. It's a three-by-one matrix, right? But you don't care about those two last two ones, right? So you can just extract only the one you need. So that's... Let me change... Well, let me change the name. And you extract it by saying... By putting this in parenthesis is a one, you know, the first entry in that matrix, right? Well, the matrix is three-by-one, so it's clear what the first entry is that, right? If it were a two-by-two matrix, you would better say it's a first row, first column, right? But here it doesn't make any difference, right? So you've... Give it a different name. Of course you could... It doesn't matter. Names is something... You have lots of choices, right? So you can... If this is a little bit confusing to you, always give it a new name, okay? All right? Anyway, so that's the answer. Well, okay, that's the... Max or minimum? We still don't know if it's a max or minimum, right? The derivative was negative and then positive, so the function was decreasing and increasing, so it is a minimum for the function f. And you can see it if you plot f, not fx, and you... Minus one... One, let's say... So it's right here, right? Right down here. Okay. All right, so thanks again for pointing that out. I mean, it is important, right? And if you do this in your homework, I'll say, you know... Don't do it. So I'll say it now. You know, every time you have to keep things in perspective. The one thing that modeling helps is actually... When you get to the end of your computation, of your model, of your solving the model, of your using the computer to solve the model, you have to translate everything into words and say, you know, again, tell your brother or sister, mother or father, something that has, you know, scared of math, say what you've found, okay? And that's a check that helps you catch, hopefully, most of this, you know, possible errors that are done in the process. Okay? Let's... Well, let me say two more things before I close this. This way of doing business with Matlab is not efficient because it asks for a command at a time, right? And yes, you can go back and recall a command, but that's not very efficient. Most efficient is to use what's called a script. Okay? And notice that I've opened what's called an editor. And in this editor, you can actually... And now it's gone, right? Where'd it go? Window 7 is good. I found it. So now, before I lose it again, I'm going to dock it. Now, it went above the figure. I don't really like that. I want that to be like, you know, window here, right? And you can play with this. Okay? And let's say I want to redo everything that I've done but now in one stroke. So what I do is I go to... Well, I go to command window history just because I'm lazy to rewrite everything. Wait. Okay. I think I needed to do something else to record this as a diary. But since I haven't done it, let me just say the following. That you can... Oh, that's another thing. You can click this little thing here. So this is not on docking. Well, this is on docking, right? This just takes it a separate window, which you may lose again. So instead of on docking, you can do... Maximize the error. So it just kind of goes on top of everything else but it's not on dock, right? You can put it back in and find the other. Okay. So I'm just going to focus on this for now. So what did I say f was? x4 minus x squared plus x. fx was different. The derivative of f. By the way, derivative, you don't have in this case to say with respect to x, but some other times will be also useful. And the last thing is solve. xc solve f. No, x, right? fx, right? Remember? Yeah. You know, you may be able to, in the newer versions, I don't know the answer. The point is we're not really doing the most efficient coding, okay? We just want to do some coding that gives us the answer. Then we can, that's a separate process, right? Optimizing the code itself, right? But I don't know. It's possible. A lot of the things that I do are either redundant or really slow or something, right? But we're not looking at speed at this point, okay? So remember we did this. What was the last thing we did? And the one thing that we didn't do is solve it f at this value, right? And this is going to be fmin. Well, it's of course a minimum in whatever interval it is, right? So now you have this nothing but what's called a text file that you just wrote, right? I wrote it fairly quick. How did I know to write all of this? Well, I've kind of went one step and I saw what it does, right? So if you, right? The first time you write it, you're not going to know how to do this. So what you're going to do? Well, I'll tell you. Practice, I mean experiment. Okay, so let me just do this. Well, you can run this thing. If it wasn't saved, it will ask you to save. So let's save it as the first one. It has to be .m to be recognized. Cool, already exists. I don't care, okay? So now it not only saved but it also run, but nothing happened. Well, because I wasn't watching the command window. So that was, again, that was just a focus on that, but of course you can do it here and it gave the value, right? In fact, let me do it again. So I'm going to clear this. I'm going to run this and you see the answer, right? Now, you only see this because everything else was commented out, not commented out, but suppressed. The display was suppressed, right? Okay, of course you can do and see everything, every single thing, but then it's going to be painful. Okay, so then you have to kind of scroll up and down, right? So that's not, and I think you can control Z to undo things. Okay, so it is a text editor, nothing else, okay? Which is good because you're going to go and take my codes or any codes. So, look, we're going to talk about this problem, specific problem in class, but if you have no idea what it is, but you want to see what it does, you just copy this text, right? There's no special formatting. Just text, right? And you're going to open a new one, paste it here. You can save it and then run it. You know, let's save it pig1. So we're talking about some pigs here, which is kind of funny, but that's the first example. And then you run it, right? And there's a bunch of commands that create all these figures, right? Which I just closed because it becomes, again, it becomes quite clever, right? So you don't know what it did. That's why I'm saying, well, you can see some of these numbers, right? But again, it's an ugly thing to scroll up and down, right? So when you're done with a code, again, I haven't showed you how to develop the code, but when you're done with this code, you want to just run it. There are two things to do. One thing is go and do one at a time. See what the code does one at a time. And that's done with this double percentages. So in your code, everything that has this percentage is ignored by Matlab. So it's just for you to see, right? So with one single percentage, what has two percentages is what's called a cell. So I don't know if you can see, but it gives a different color. If you're in this cell, this cell is from here to here, right? And you can run it one at a time. And that's done up here, if you can see my cursor. So you can run the cell and stay in that cell. So let me clear this so you can see. So if I run this, the first cell, well, it did it, but of course, there's nothing to display. Just define that variable, right? Therefore, I should go either to an Excel, or this is more useful, of course. So now I'm in the next cell. Well, take a look at this. I have this new function, which is a function of x. And now I can just evaluate this. And what's going to happen? It's going to plot something, which I don't see. Why do I don't see? Because it's... No, but it's hidden here. Actually, you know what? So my column for plotting is not... It doesn't have any effect. Yeah. But it was somewhere in a figure in a place where I couldn't see it, right? But it did. It did something, right? So this is the function that you have to maximize, right? Forget what it comes from. It comes from a maximization problem of profit. But now I can go forward and see, well, the next thing is find the maximum, find the derivative, but don't show me the derivative, right? Of course, you can see, but it will be ugly. The next thing is solve the derivative equal to zero. And you see I doubled... Immediately, I want to get into numeric format. Compute the maximum of... Well, x max was found that I showed. And now you can see what happens. I'm sorry if this is too small, but it found the maximum. It even plotted. It's kind of nice visually. OK. And then it goes into other things, which we'll have to talk about theoretically, OK? All right? And the last thing is when you're done with this code, what do you do with it? OK, you cannot... So this is one way to kind of see what it does step by step. Of course, it's also useful for debugging. Like if something is not right, you can go in that cell and modify what you need. When everything's working nice and fine, you can publish this. So this is another feature which is very useful. It just gives you a report of everything. And first, it goes through the computation. And you have an HTML file, which is already on your computer that is nicely organized. Of course, the formatting, we should worry about this later. The important thing is there is text, which is comments. There is commands, which are MATLAB commands. And there is output, which is graphs and values, OK? So you don't have to look and scroll up and down and look in different... OK? This thing you print and give it to me. But, of course, OK? So Monday we're going to talk about how we start with simple models and get to a code like this and then interpret. Thank you.