 Hopefully it won't happen. And I should be available after class, on and off. Sometimes I have to run, pick up my kids. But if I'm here, then you can come, stop by, we can chat. Also, I mentioned there's a MATLAB tutor available pretty much every day of the week, Terry Spence and the MLC. So that would be helpful. Let me mention I still left this first chapter homework due on Wednesday. But for those of you that still get warmed up with programming and stuff, I can take homework, say, by the end of the week if you still need a little bit of extra time. But typically, I'd like to keep this at a pace where we can move forward. So anyway, if you need a little bit extra time for the first assignment, turn it to me or to my office by Friday. Chapter two homework, I pushed it back to next Wednesday. So let's see. I get started. Any questions from the little thing we talked about last time? Yeah, I should have mentioned that I'm posting the notes here so you can, most of the time, I'm not going to add anything, but if you go there, then I'm going to see the notes. Sometimes I add a little bit of awarding to the end. But basically, I've just added a few comments about the features of MATLAB that I showed last time in class. Felt like yesterday, my gosh. OK, so let's see. I'd like to start talking about the first, if you want, optimization problem. So one-dimensional optimization, and along the way, introduce what's known as the process of modeling, the five-step method. So we're going to start by one-day optimization problem. Why is my cursor a win? We'll see. Hopefully it's going to work. So I'm going to leave this space here for what we call a five-step method for what's pretty general for setting up a problem. You have some sort of physical application that you want to develop a mathematical model, and a property mathematical model, solve it, draw conclusions. And we're going to kind of identify the five steps for each of those. But so the first example we're going to talk about, I'm going to label the same in the book. So this is called a peak form problem. And probably many of you have already looked at it. So I'll just say briefly that in an economy like the US, there are lots of things that need to be optimized. And you'd be surprised how diverse this type of problems you might encounter. So if you're in a mass agriculture or something, you want to do some not just raise one pig, but you want to raise lots of livestock for sale or for meat or whatever purposes, then you're going to encounter some costs, and you're going to hopefully get some revenue. So you'd like to optimize on sort of, say in this case, a profit. But the profit will depend on, I mean, the profit, the revenue, and the cost will depend on the number of the size of your farm. So let me see here. So in this first example, let's talk about just such animal. So a pig weighting 200 pounds. So one pig weighs 200 pounds. All right, gains five pounds per day and costs 45 cents. So $0.45 per day. It's kind of ironic. I was yesterday at this Denver stock show. Anybody was there? It was very crazy. Absolutely crazy. But anyway, so I kind of see lots of pigs, lots of animals. Guess it's nice for kids. All right, so the market price is $0.65, so $0.65 per pound, and it's falling at $0.01 per day. Per pound per day, right? All right, so if your life depends on the revenue that you get, on the profit that you get on this, then the following question might seem relevant. That is, should you sell the animal right away, so to be able to get the most price or the most revenue for whatever you have, or should you wait some time to get more weight because it gains a certain amount per day, but at the same time, risking to get a decrease in the revenue because of the price per market price. And it may not be absolutely clear that there's going to be a balanced balance, so there's going to be some trade-off. You're going to have to wait some time, but not too long to maximize the profit, right? So the question is, when should the pig be sold? And of course, keep in mind that in order to maximize, OK. So it's kind of a very simple type of problem. But still, unless you get your hands dirty or do something, you won't be able to tell, right? I mean, of course, you could start doing, OK, if I wait a day, what's going to happen? If I wait two days, I mean, you could do that the very long way, right, tabulating. But the question is, how can we do it in a more systematic fashion? So here's the first step in this method is, first, disformulate the model, OK, which if you want to think about it, we pretty much did it. The only thing is, at this stage, is we'd like to identify what are certain things that we know, what are things that we kind of know about this, what are the assumptions that we have to make to move forward, right? So here, I'll just say, so basically, I want to have to ask the question and our own interpretation. So it's pretty much with everything, regardless of what field you are talking about, or it's just getting your head around this problem and getting comfortable with it. If it's a long descriptive problem, try to synthesize what is the essential information and drop everything that's not essential. So pretty much we did the step one here, right? Step two is to select the modeling approach, OK? So this actually can be sometimes fairly tricky because, as I said last time, you may run out into a situation where you've just never dealt with before, right? And you may not have the mathematics behind to be appropriate to describe the problem or model, right? So of course, if you can frame the situation in some sort of, for instance, in our optimization type problems, right? So if somebody says, or if it's obvious, right? Maximizing profit. It means you have to maximize something. So it's an optimization problem, right? Then you can kind of narrow it down to the tool, to the methods that you know. So anyway, so in this case, it is an optimization problem. Do we know it's one-dimensional or not? Well, that's, again, part of interpreting the situation and realizing what is the decision that we have to make, right? The decision we have to make is a number of days that we keep that before selling. And pretty much everything else, once you decide on the number of days, everything else is known, right? Everything else meaning the weight, the cost, the market price, the revenue and the cost, right? So in this case, modeling approach would be one dimensional optimization problem, right? The next step is to actually build the model, OK? Well, the mathematical model. So this obviously is the most important one. And again, everything may seem sort of trivial, but two weeks from today, when you're going to face a problem that you feel lost, this comes really handy. So just kind of breaking it down in this steps. OK, so now it gets more serious. Remember I said in step one, we've kind of said what should be the things that we're certain about? What are things that we're sort of not so certain? So what are the assumptions? And finally, what are the decision variables, right? So we're going to formalize this in a second. Based on that, we're going to be able to build a model. In other words, knowing we want to find an optimization problem, a function that we need to optimize, is right that function in terms of the variables that we have, OK? Step four, and obviously there's going to be one more. Step four is to solve the model. And I want to make it clear here is that computers may help here. That's pretty much the only step where you should really heavily involve or involve some sort of computational tool. So there is some prep time. There is some preparation in the previous steps that you want to do before you go to a computer, OK? Last step is to interpret the results, the results of the model in lay terms. So it's only when you can communicate whatever you did to the farmer, that's when you can say, well, I've accomplished this modeling task, OK? All right, so I'll go very quickly for this problem. So in the first step, for this example, OK? So in first step, the goal is to maximize the profit. So it helps to start from the bottom, right? Of your problem description, typically the setup is there and you're asked, what's the question? What do you want to accomplish, OK? So the profit is revenue minus cost. If you're in economics, you have some economics background, this is all you do there. Revenue minus cost. And this is going to be the most important thing in this first step, because when you wrap your mind around this model, you want to label, you want to kind of identify what are the things that, on which this profit depends, right? So what are the variables on which the profit function depends? Well, for this example, as I said, let me just call t, because that's natural. Time left before selling in days. As I said, if somebody says, I mean, it doesn't give you an option of keeping it longer or shorter. It just says, from now, in five days, you sell it, right? And assuming everything else is correct, in other words, the assumptions hold, everything else that was listed in that initial description of the problem are correct, then you will know what the profit will be, right? So from that point of view, there is only one variable on which this model depends, right? So we're going to stay with this for now. But now there are things that we like to call parameters and think about them as these are the things that are not so certain, right? But that to move forward, you have to make some sort of choice of their values. So you assume some values or you assume some parameters, the parameters to have certain values, and then you keep them fixed. So for instance, c, a little c is cost to raise the peak per day, right? And the assumed value is 45 cents, right? So that's what I mean by we make this as an assumption. And there are other things, like what's another parameter? Can somebody tell me? The growth of the weight at which the growth rate at which the weight is growing, right? So the growth rate of the peak, so let's call it a little g. So that's going to be the growth rate of the pig per day. And that is assumed to be five pounds. What else is right here? The original is not really assumed as no, right? So that's not uncertain at all. It's just given. So there will be a separate list that I'm going to call it to be the constants, OK? But there was another value that was the price drop per pound per day, so price drop per pound, market price, right? And that was 0.01. And as I said, there's going to be things that are certain. And I don't even bother giving them a name. So I'm just going to call the weight at present time. It is 200 pounds. And market price at present time, what was it? 65 cents per pound. So again, you will say, well, what's the difference between these values and these values? Why do we separate them as two separate things here? Well, maybe you run the model with these numbers, right? And then somebody comes back to you and says, oh no, I made a mistake in that assumption. It wasn't really 45 cents. It was different value, right? And let's think this is a complicated code that takes days to compute, which is not. But then you have to go and compute everything altogether, right? Now, so in a way, when we build our model, we'd like to build it in such a way that it's friendly to change in these variables, right? Because they're fixed for each run of the model, right? We run the model with a fixed value, but we'd like to kind of distinguish between this set of constants and this set of constants, right? I mean, you've seen probably, I mean, you've seen, I'm not sure in what context you've seen this denomination of parameters versus constants, but certainly parameters gives this connotation of they may actually change, right? And then you would have to figure out what happens if you change those constants, right? OK, so step two is done, right? There's one day optimization. So in this class, there's going to be little doubts about what, I mean, the examples will come with the corresponding kind of optimization approach. So we won't have to think about too much about how to use it. But of course, step three is the most important one. So let's do it here. So build the model, right? OK, so it's not too hard because it's the revenue minus cost, OK? And now the revenue is going to be fairly simple. It's the number of pounds times the price per pound, right? So let me call this price per pound times the weight, right? That's the revenue minus, and the cost is, well, cost per pound times the weight. Hold on a second. No, no, that's not true. The cost is not given per pound, right? The cost is given per day, thank you. So it's just going to be price cost per day times the number of days, right? All right, so it's not too hard. Do this combination. So the price is 0.65 minus 0.01t. And not using the parameter values, but I'm just, excuse me, the names, I'm just teaching the values of the parameters, times the weight is 200 plus 5t. That's each day is five more, so t's in days. Did I say that? So t days, OK? Minus the cost per day, what was it? 0.45, and the number of days is t, OK? So that's it. So a few things here is you see this is a quadratic function in t with not so nice coefficients, right? But clearly, so this is quadratic. So this will have a maximum, right? Because quadratic and the leading coefficient is negative, so it's going to be a parabola upside down. So kind of checking that we're building a model that will be reasonable when we get a conclusion. Of course, if you came up with some sort of model where it was obvious that it would never be achieved or some sort, it would always be achieved at the beginning, right? Then maybe there's something to double check. Maybe the assumptions are not right and something like that, right? OK. One more word of caution I would like to point out is if you and your colleague are basically solving the same problem, modeling the same object, right, and the same problem, if you start with a different kind of variables or different, if you call things differently, then when you build the model, the model will look different, right? Not in essential ways, but it will be somewhat different, right? So the comparison becomes difficult if you make different choices of your variables, because you can make a little bit different choices, not substantial. But then pretty much the comparison becomes at the very end. At the very end, when you interpret your results, is it the same? Did you get the same conclusions or not? But in between, it's kind of dependent on what your choice of variables of parameters are, right? So I think one of the Homer problems, number one, right? It's already, if you've read that it has an auto dealer shape or something, they sell cars. And they talk about making a profit per each car that's being sold, right? Sort of a fix, because we know that's what happens if we sell it like this. What we don't know is how many cars will be sold, right? In fact, that's going to depend on incentives, other market conditions, and something like this, right? So the problem basically talks about, what if you give rebates? Is that going to increase the number of cars being sold, right? And so the variables, what will be the variable? Is it still a one-dimensional one? There's going to be one variable. The number of rebates, for instance, right? It could say the number of rebates of a certain size, right? So if I say $100 rebates or $200 rebates, that would be twice the number of two $100 rebates and something like that, right? So one could make that choice as the variable, or one could make just a dollar amount to be the variable, right? Well, you can imagine, I mean, it will just look a little bit different. It won't be dramatically different, right? But it will be somewhat different function that needs to be maximized or minimized. All right, so let's finish this up, because get to some more interesting stuff here. So the model says to maximize p as a function of t, because now you see it's as a function of t, right? Subject to, I would say, there's not a real constraint, but it's just saying, we want to maximize it in the future. We don't want to maximize it in the past. We want t to be positive. So all right, so that being said, what is the step four that is solve the model? Just have to take the derivative, set equal to 0, find the maximum of the vertex of that, right? And you can already see that it kind of becomes to be ugly if you do it by hand, right? And not only that, but as I said, if then you have to change that 0.01, that is the market price drop that's assumed to be 1 cent per day, right? What if you have to put 0.02 or something, right? Then if you had it done by hand, now you have to redo it by hand. Different numbers, pretty ugly, right? So that's where you need some sort of computer program to do it. So there's one thing that may be a little bit not clear why it's useful, but at this point is when you get to a computer program, you would like to have some sort of standardized names or the variables for the function. So x is pretty standard for a name or variable. So we're just going to write our code in terms of x as it being the variable. So x is going to stand for the time in days. And f of x is going to be the profit, right? So profit when the peak is sold after x days. OK? So the function that needs to be optimized is simply 200, 0.65 minus 0.01 x, excuse me, 200 plus 5x minus 0.5 x. OK? And now you go to your computer and let's see if I have the code here. So I posted, I showed you last time, this is the code. Copy, select all, copy, paste in your editor, right? So you're creating a new call m file, right? Now this is a whole file that talks about many things. So let's say you, well, I'm just going to copy the whole thing. And so first time when I run it, I have to save it. Remember? So let's call it peak one. Somehow my keyboard doesn't like when I type on it. Type on it, A, D, Y, P. OK. No, I just want to type something. No, no, no. It's like it happened in the beginning of the class. I think there's something running in the background I'm trying to get rid of. I think this thing might be it. This is very interesting. I'll try this. Now this is going to be very slow, so let me see. No, it does the same thing. I cannot even type something. Let's see. No, it's not a MATLAB. It's just whatever. If I open a browser and I want to type something, I kind of suspect there is something that, sorry about this, there's something that I installed, but here's the studio. Very interesting. So OK, now it seems to take it. OK, so let's try it now. I'm just going to override this again. OK. So I'm going to organize this a little bit better. So I have, remember, I can, ooh, OK. So I'm running it already, the whole thing, which I shouldn't have done. OK, so this code, as I said, just starts with, it's organized in cells, so every time I put a double percentage, it's going to define the new cell. So I'm running the first cell just says, well, it clears all the previous figures, and it defines X, right? So remember, it's not T, so it's X. Then I use Y instead of F, but I define the function and I plot it, so I see this. And notice it took a little bit of time, and I'm going to put it here. So I use a big font so you can see. So we plotted this function. It took a little bit of time because it's symbolic, right? And MATLAB is not the best symbolic computations, but it does the job. What's the next thing is, the next thing is it takes the derivative of that function, right? And you can display it if you want. And you can see it's linear. So it was quadratic and now it's a linear function, right? And the next step is solve it. And I'm sorry to, it goes to the next cell. So this is what I solved. Now, I didn't see the solution, right? But the first time you write the code, you want to see the solution because there may be more than one solution, right? Like we did last time. Some may be complex. So again, this is kind of the code at its best, right? After it was all run. So this code is ready to be published and to be displayed as a report. But as you develop the code, it's gonna take some steps, some experimentation. And then I just want to display this in a numerical format, right? So that's what double means. So I see it as number eight. You can see it on the picture. Number eight is where you have the max. And all you have to do is find the profit by plugging in. And the command to plug in is, I'm not displaying it, all right? I should display it if you, okay? But again, you can just, every time you go to the command window, you just say, type the name, it just calls the value, okay? Now, obviously this code is not really friendly at modifying any of these parameters, right? So you can say, okay, now, let's see, what's the next thing is to kind of perturb these and say maybe it's not 0.1 cents, maybe it's not 1 cent per day that the market price drops. In fact, you don't know, right? It's a future thing, it's uncertain, right? This was just an assumption. But you could say, okay, I'm gonna change this value to 0.2, right? And then see what happens. But then you have to run the whole thing. And that was already bad, right? So the change from 0.1 to 0.2 was kind of too dramatic, right? But anyway, so that's what happens. Looks like the minimum occurs, so you should sell it right away, right? If the price drops, if the forecast is the price is gonna drop at that rate, it's better off to just sell it immediately, right? So it's kind of a, it's helpful, but it's not perfect, right? It's not a great way of doing things. So instead of that, but anyway, so the next thing we're gonna be doing is, so we're right here, right? So, oh, actually I didn't plot this, so let's plot this. So let's finish this so we can go and tell to our farmer. So I would say this is kind of the end, is plot, you know, you plot the profit function and you plot the maximum that you found. I mean, it's just a way of plotting, it doesn't, it's just a way of plotting, right? So hold on, kind of keeps the same figure and you plot on top of it, okay? And you plot the maximum point. Now notice, we use plot rather than easy plot. I didn't talk about the command plot. Easy plot is for plotting symbolic things, okay? Plot is actually to plot is for plotting numerical things. So everything that's, this is just a point, right? A point with these two coordinates and then this is an attribute of that plot. So this is, says a red circle, red circle, right? You can, so you can kind of beautify this quite a lot. That's a nice thing about math lab. So that your graphical kind of result can look, you know, professional grade if you want, if you spend enough time, all right? So that's sort of the end and that's step four, right? And I'm not gonna attempt to copy anything, but so using math lab, we get that x max is eight days. And f of x max is 133 days. Point two dollars, right? Something like that, okay? All right, so now comes the issue of what if those assumptions are not accurate, right? So we talked about what's called sensitivity analysis and it's a very important method or piece of the math modeling. It basically says pick a parameter in the model, say r, r was the market price drop rate, yep. We said it's 0.01 per day, that was the assumed value. But take that as a parameter and perform what's called a sensitivity analysis to that parameter. So the question is, how sensitive is the conclusion of our model, of our modeling process to this parameter? So whenever we talk about sensitivity analysis, we talk about sensitivity to some parameter, okay? So meaning that it's gonna be very sensitive to a parameter if, if what? If by changing the parameter just a little bit, the conclusion is gonna be dramatically different, right? Or it's gonna be not sensitive, not very sensitive if changing the value parameter by some by a little bit won't change the value of the conclusion, right? Yes, one dimensional. Then it becomes variables or parameters. If you have several parameters like we do have in this problem, we still kind of focus on one at a time. We focus on one parameter at a time. The reason for that is in the end you'll have to make an assumption on those things, okay? And we're gonna, depending on how sensitive the model is to each individual parameter, we're gonna be more careful when we make assumptions on the parameters to which the model is more sensitive, right? The ones for which the model is not so sensitive, we're gonna care less. I mean, we're gonna be less careful about making the assumption, right? So what's the least sensitive that a model can be to a parameter? If there's no change, right? In which case, it would absolutely matter, it wouldn't matter what the parameter is chosen to be, but that's rare, right? But a lot of the time says there's a bunch of the parameters that are sensitive, the model is sensitive to those parameters and there's a bunch where it's not so sensitive, right? So in running the model, we're gonna be more careful in picking the parameters where the model is more sensitive to, okay? So how do we quantify this, how sensitive it is? Well, this is actually not the only way. So we're gonna talk about sensitivity, you know, maybe a month later, and we're gonna mean slightly different, but that is in quantifying that sensitivity, right? But one way to kind of identify how sensitive it is is to introduce the so-called sensitivity to this parameter, sensitivity, well, sensitivity, okay? So, and it's gonna be denoted like this, it's gonna be denoted by, so to the parameter, the parameter, parameter in question. So it's just gonna be a number, right? So the number is gonna be, let's say we're gonna have r is the parameter and x max is the conclusion, is the number of days, that's our conclusion, right? So that's the conclusion of the model is figuring out what is the number of days to be optimal, right? So then we're gonna use what's called s of x max and r, I don't know, you wanna put semicolon, just comma, doesn't matter, right? This is gonna be a number that's gonna quantify that sensitivity. So maybe let me just write it down and explain a little bit, explain. So, all right, so now I cannot write, it looks like x max, all right, hopefully one is that we're gonna have a better tablet on the market. So what have I done here, I just defined a weird formula, right? Where, what is this? Well, this is just the derivative of x max with respect to r, right? But I don't know what, I mean I didn't, so what is x max as a function of r? Well, I said that if you change that 0.01 to some other value, it's gonna give possibly a new x max, right? So that dependence is this function. Now, we'd have to figure out an explicit dependence in order to take the derivative, right? So we're gonna use a computer for that if we can. Then I'm multiplied by, this is multiplied by the reciprocal of x max over r. So where does this come from? This comes from, so the idea is s is relative change, it's a ratio of relative changes. So it's a relative change of x max that is obtained when a certain relative change in the primary is made. So relative change is the change you're making divided by the value that you started with. So for instance, if r is 0.01, we said x max is eight, right? And I wanna make a 10% relative change in this value. So 10% relative change corresponds to what? Well, 10% of it is 0.001, so I can add or I can subtract that, right? Or you agree with that? So this changing that value, I mean, now it becomes questionable is, I mean, this was 1 cent, so now it's 1.1 cents, but think about it in relative terms. So let's say the drop happens at this rate or at this rate, then you run the model and you're gonna get some values, right? And the question is what's gonna be the x max then? And what's gonna be the x max then? Okay, well, we can run the model like this. It won't be the best way to do it, but let me just show you. So I put 0.0101 and I run this. Now it's good always if you can to clear things. Let me just, okay, so you see x max shifted to be 5.45, so five days, right? So the drop is faster by 10% causes the number of days to shift to decrease, right? From 8 to 5.45, okay? And do you remember that value? And let's do 0.09 run again. I wasn't very careful when I started, but again, when you run this again, this is not a good way to do it, but you wanna make sure that you don't use values that were used in the previous run, so it's best to start by clearing everything. But anyway, so it looks like 11 sounds right. So if the drop was actually slower by 10% than one cent per day, then it's better to keep three more days, right? So it's better to keep three more days or about three more days or about three fewer days, right? When you have a 10% change in that value of the parameter. So what's three in eight? Because eight was the number of days to be kept, right? The optimal number of days. So this is 5.45 and this was 3.11. So what is about the relative change here? Well, three in eight is whatever three in eight is, right? Oh yeah, thank you. So the relative change is, I'm gonna use the power of MATLAB, 0.375, right? Now it's about that much, right? So that's point, sorry. So that's 37% relative change, okay? So what is S gonna be in this? Well, S is the ratio between these two relative changes. So it's 37 in 10, so it's 3.7, right? It's about 3.7. Now, the number 3.7 in its own is not accurate because the 10% relative change is actually quite large, right? When you make an assumption, you wanna try smaller, maybe 1%. If you do 1% and you redo this computation is gonna be probably gonna be different, right? So in fact, our sensitivity is gonna be the limit of those, the limiting value of that process. By taking the relative change in, in R, smaller and smaller, right? Then the ratio is gonna become, what? It's gonna become exactly this derivative times R over X, right? Okay? Because delta X over delta R becomes DXDR and R over X becomes that, right? Okay, so that's where this formula comes from. And again, this is not the only way to define a sensitivity, right? It's just a number to quantify it. If this number is very small, it means it's insensitive, right? If it's very large, if a 10% causes a 50% change, right? That's significant, right? If a 10% relative, it depends on what 10% means in terms of the parameter, right? The price. Is that parameter able to change that by 10% or, I mean, what is the range in which that parameter can change? And then you can tell what's the effect on the model, okay? So with MATLAB, you can actually do this sensitivity as follows. So you have to hold the X variable as being a symbolic variable, right? But you have to introduce another variable, so you call it R, and I plug it in here, right? It's fairly easy, just copy and paste, replace 0.01 with R. And now you do the same thing, but every time you do things, there's gonna be a dependence on R, right? For instance, when you take the derivative, you have to specify that it's derivative with respect to X and not with R, okay? You'll get an error if you get just derivative of Y because it's gonna ask with respect to what, okay? Actually, no, I take it back. If you don't put X here, I think MATLAB is gonna assume that it's always X. So the rule is go to the back of the alphabet and that's the priority, right? So if, but to be very explicit, you wanna say it's derivative of Y with respect to X, right? So let's see what that comes up to. And you see it here, okay? And I did it already, I solved it, right? Again, you have to say with respect to what you're solving, right? So you solve with respect to X. And you see the answer is no function that depends on R. So the maximum, the optimal X is a function of R, right? Well, perfect, nice and explicit. So now you can do it even by hand, take the derivative, but why do it by hand? What we like or would like to use the same code to solve it? I mean, not to solve, but to find the sensitivity, right? So I do this in two steps. So I think this is not really necessary, but I'm just displaying a few of these times, optimal times, for various values of R. So here are the values of R that I take. This is in the middle, right? And then I take 10% relative change to the other side. And so 20% here, right? 20% relative change. Now notice the syntax here. What I do is I have X, the notation becomes kind of dependent on on the person writing the code. But if I call X max R, this depends on R, right? This is just a name, right? Which is this function. Then in this expression, I replace R with these values, right? And you see I do it all at once. So I take, if I have what's this is called an array of values, right? A list of values, then it's gonna substitute and it's gonna compute those values. So let's do this here. And then I display the R values and the X values. Remember, I call X values this. So you can see, right? Much better than running it five times, right? Okay. And of course, this is not really necessary for the computation of the sensitivity that as we have it. But it's just, well, it doesn't cost too much to plot these things so you can see. So what do you see? You see for each R, well, for these values of R, for these five values of R, I plot the values of X. X max. Okay, the maximum, the optimal values. And what do you see? You don't really see them as in a line, right? Why should they be in the line? There's no reason to expect anything looks like linear, right? In fact, you saw that the function was not linear in R. So now when we take the derivative, you know, that derivative at this point, because we wanna take derivative at the point where we wanna test that assumption, 0.01, is that sensitive around that assumption or not? So when you take the derivative, it's not gonna be exactly, right? 3.7 or 37 on one side and 37 on the other side. 37% on one side, 37% on the other side, right? That's why you have a little bit of variation there, right? So is it this one already? I think I already did this one. Yeah, okay, so we do this and it actually computed, so I differentiate X max with respect to R, and then I multiply by that because, so this thing comes up because you have that definition of the relative change, sensitivity in terms of relative changes. Later on, we may use something that's not relative changes, just exact changes. So delta X over delta R or dx dr. But here you have that term extra. And then he evaluated this value and here's what you get. Negative point point five. So it wasn't 3.7, right? 3.7 was just side balling. When I said three goes on either way between, instead of eight, it's 11 or five, but it wasn't really 11 or five. So in that limiting, as the relative change in R goes to zero, you get negative point 35. So the important thing is negative says what? It's decreasing, right? So with increasing the value of the parameter, the conclusion, I mean the value, that optimal time is decreasing, right? Make sense? Should make sense, right? So the value 3.5, as I said, is depending on the situation, it says in this case it would say it's relevant, right? Again, if it's possible for the price to drop or to change by 10%, then the number of days is gonna change by 30%, right? Which makes a huge, okay, and let's see, I think I've run it again. Oh, and I have also a sensitivity to growth rate, which was five pounds, it seems to be five pounds, right? But now notice that I went back to this value to be point 01. So I'm doing sensitivity only to this parameter, G, right? Now we can talk about what happens if you start varying things simultaneously, but right now I just do sensitivity to one parameter. Then you do the same thing all over again and you will see what, that it's actually now growing and the sensitivity is, I mean, this value is three, with respect to G is three. So it's positive, right? Meaning that if the growth rate is not five, but 5.5, right? So if the food, if you are able to give food that makes the animal grow faster, right? I know it sounds, especially if you're not a pork eater, then it won't be pretty, but then it makes sense to wait some more time, right? Okay, so this kind of little things that you can draw from this code, right? And I never managed to say here, but at the bottom here is step five, interpret in words. In fact, it wouldn't be wrong to say, do the step five after you've performed sensitivity because when you have to go and tell your results to somebody that has no clue about what you did, it may not make, here's a very next question, if you say, okay, keep it eight days is, well, but who knows what's the market price gonna do in the next eight days, right? Or who knows that the animal is gonna grow at that rate? Or any of the other, what about the cost? You said the cost per day is whatever it was, 45 cents, right? What if the cost of the food supply is gonna change? Something like that, yeah, that too. So that brings up another question of robustness of this model is, well, this model, besides the fact that it assumes certain values for the growth, right? It also assumes that the pig would grow at the constant linear increase, right? The weight would increase as a linear increase, but in reality it's not happening, right? So the question is, what happens if, I mean, you know for sure that the pig is gonna have some sort of nonlinear behavior of the growth, what's the best way to do? Well, probably is do a rough assumption on the linear growth for a few days, right? See how many days is reasonable for you to re-evaluate the whole model, right? So you could kind of go on an assumption, say, okay, it's gonna grow linearly for the next five days, right? Then in five days, you re-evaluate the weight, you re-evaluate the growth rate, right? And you predict a few more days. Now in the end, the end of this modeling exercise is what? You will get a somewhat accurate optimal value, but you may never get, I mean, nobody will say, well, you got the absolute best deal or the best profit you could ever possibly do, right? So this will never actually achieve because there's so many uncertainties, right? So, but it will be better than nothing, right? In fact, for somebody that has no kind of tools except guessing, right? This might seem invaluable. I mean, it might seem like this is the best that's gonna happen in their lives if they can see in the future. So use this as predictive tools, but with some cautionary tales. Please, I mean, look at the problems. As I said, you have till Friday to hand it in, but I hope that you can start working on them. If you feel lost, try to look at those five steps, okay, interpret them in your minds, all right? And we'll see you on Wednesday.