 see the updated version of the solutions to the first homework. The only difference from the previous version that I gave you is some lines of the code were, remember, you had to solve an equation symbolically. You got two solutions, and only one was relevant. The other one being the externals like negative, and you wanted only the positive solution. It's very important that you pick the positive solution when you do the sensitivity or whatever. So I'm just going to show it here a little bit. So just so you know, just discard the previous one. The reason for that change came from when I wrote this code, I was using an older version of the symbolic toolbox. And I believe or not, when they change this versions, sometimes the, yeah, like take this one. Sometimes the capabilities change just a little bit. Nobody really can predict that. But of course, if you run the code that was written for the old version on the new version, then you might get something. So just point out one such change. For instance, some are like here. OK. So problem number seven, I want to have to solve. Well, once solved, it says the derivative equal to 0 and finds the critical points. And it gives you two values, right? You have to be able to pick the positive one. And I believe in the previous solutions, the code was saying pick the second one. Of course, you can make the code fence here and say, check which one is positive, right? You could write a little two lines so that says pick only the positive ones. But so now how do you realize which one is the positive? Well, you could display them in a numerical mode and then see them or, I mean, in various ways, or if it is, like, take this one here. And see, that's kind of weird, isn't it? When you introduce a parameter and you solve the same kind of optimization problem. But this time you have a parameter in it. I believe that's the same. Yeah, that's the same problem. Now I have a parameter and I solve. I set the derivative equal to 0. Take a look. It's the second one that corresponds to a positive solution. So I don't think you can ever predict. So you just, case by case, you can, right? And how do I know this? The second one is the positive. Another first one, plug in some values, right? For instance, you can plug in the value g as whatever it was originally, right? The value that you departed from. I don't remember what was g. G was some sort of growth rate. So if it's plug in 5 in here and you'll see is the second one that comes up, OK? It's hard to see from the expression that this is really the positive one, right? So you just have to try it. Anyway, so those of you that came in a little bit late, if I didn't have enough copies, there are more copies. But it's only companion. You should see the most accurate one. Well, the one that works with the latest version, OK? Or the last few versions of the symbolic toolbox. OK, so just a general comment about the homework is, it's quite important that you include whether it's handwritten or in the published version, just you include some comments, some conclusion. Just giving the code and the output of the code in a graph makes it hard for me to judge anything. So having some conclusions is important. Even if you start with wrong assumptions, maybe not wrong. But maybe you interpret the problem in a very specific, and it's not the same as somebody else would interpret the same wording. But as long as you write that down, that's my assumption. And then at the end, you draw the conclusion based on those assumptions. That to me is a valid piece of work, OK? Now, if the assumptions are totally off, we can debate, we can talk about it. But if the conclusions to your modeling process are following correct reasoning, and the model is correct, then it's not like it's totally wrong. Even though you might draw different conclusions than other people, it might be seven days compared to five days, or something like that. I think if you put star around before and after the words, and you can make this pretty error. I mean, I don't think you can make it ever perfect this publishing feature in HTML. The best way to publish code is to latech. But if you don't know latech, that's a mute point. So we're not really looking to make it. And as I said, handwriting it is equally good. So I did take points off just because I want to make this point clear. So I did take points off in the homework if you didn't include some sort of conclusions. And some of you have included conclusions, but in places where I didn't expect. So I have a few comments that I scratched out. Nevertheless, think about the last step is very important, where you convey your results. Yeah, the greats should be personally companion. Let's see, any other general comments about this homework? I think sometimes like in this next homework, chapter 2, there will be, again, some departures from, well, the situation that you deal with is kind of different than the example that I gave you in class. So I think that's make that effort, make the best effort to interpret within the limits, sort of make it as simple as possible, the assumptions as simple as possible. I think even in the first homework, there was at least one that made the interpretation slightly different of that number of rebates that creates 15% increase in sales. One of the assumptions was that's a linear increase, right? So if you double the rebates, that's going to double the number of sale increase, right? But you could interpret it as being kind of cumulative, so it would be exponential increase, right? And that's an assumption, but that's certainly not an assumption that would work well for large rebates. So just in that auto sale problem, I think the linear assumption that you make is giving you what, $400 in rebates, which is not really unheard of, right? I guess in the auto industry. Now they even say half-priced cars, right? I don't know how that can be, but that's just an advertising apply. But anyway, so if you interpret the assumption as being it's not a linear increase, but it's like exponential increase, I think the maximum occurs at 800 or 700 something in rebates, right? So it's not, I mean, it's not wrong, right? Neither of the two is wrong. But the fact that you can expect that the statement says for each $100 rebate, there is a 15% increase in sales. And to assume that after 707 of those rebates, the model keeps growing exponentially, that I think is not sustainable in the market. So that's where you get a bite on the assumption that you've made. It's not in how the code follows. You've done it correctly. It's just to start with different assumptions. And I don't know if anybody has checked the website, but I put here like a cartoon that talks about how the assumptions, making, you can make your own assumptions that the report then gives whatever you want, right? So anyway, I kind of hit it here at the bottom, but OK. So let me come back to this constraint optimization. And I want to make a comment about that code. So we mostly talked about constraint optimization for the situation of that two color TVs, types of color TVs, where you have some sort of constraint on the production level, so on the total number of units. And I believe if I, you remember I was talking about the sum of the two things being less than whatever it was, maybe $10,000. And then I drew this and I said, that's the feasible region is, therefore, that triangle, right? So again, feasible region means it's the set of all points in the state space, so in basically the space where the variables live, that obey those constraints. And we said, the sum cannot exceed $10,000, so that's where this was. But I think the actual problem was having two additional constraints. If you read it carefully, there was also a constraint on the, each individual type was constrained to be something, less than something. I think one was $5,000, one was $8,000. So really, again, it's probably not worth to kind of make a picture pretty on a computer, but it would actually be $5,000 here would be the first type, so that would be a bound for the first whatever the X1 was, one type of color TV, and $8,000 was for the other one. Has anybody caught that? It's along the, right, so it has, right? It only has, the supplier only supplies $8,000 for a 21 inch and $5,000 for a 19 inch, okay? So it really should be, I don't know if I can draw it, I don't wanna, but if I were to draw, it should be this, right? So let me just run this, see what it is. Yeah, I was doing $10,000, but it should really be $5,000 to $8,000 here. It's a little bit annoying here too, changing the code, but anyway, so changing the code life doesn't work, right? I mean, you have to do it, may take time to get it right. But anyway, so it's really this, $8,000, and then there is this line, which is the sum of the $2,000, $10,000, right? So on paper, it's, you know, instead of making a nice picture on the computer, you can see it here. So the constraint TV problem has the following feasible region. So it's $5,000, $8,000, just like this. Then there is this $10,000 thing at 45 degree, and then this. So this is X1 plus X2 less than $10,000. Okay, so to write this kind of correctly or completely would be that you want to maximize profit subject to three constraints. And those are X1 less than or equal than $5,000, X2 less than or equal than $8,000, X1 plus X2 less than or equal than $10,000. And well, we can add this, that both values have to be positive, but I don't, oftentimes we don't include this as the real constraints. These are just constraints, even if you didn't have additional ones included. So this region is called the feasible region, right? So this is gonna be the feasible set of feasible region, and it's inside this region that you look for the optimal value for your profit. If it's a function of two variables, what we've found, so through optimization, we found through Lagrange multipliers, right? That the maximum occurs where it actually occurs on this piece of the region, on the piece of the boundary, and the values were, let's see if you remember. I don't know what happened on my published version, but anybody remembers what it was? So it was somewhere here, like 4,000, and about 4,000 and about 6,000. 3,800 and 600, 100, right? So it was about 3,800, I don't know, and 6,200, okay? And even if we don't impose the other two constraints, right? This, or if we impose or we don't impose, these values lie within the other two constraints, so that would be the optimal, or the point where the optimal value of the profit are resized, but it would be possible that as you move whatever parameter, as you change a parameter in your model, what happens, that maximum might slide up or down, right? And you might actually, if the change is large enough, it might actually run into one of the other constraints. Okay, so then, so it's important that you kind of set all the possible constraints from the beginning. So you don't check, like I know it's here, so you check the whole region. You have to check the whole. The vertical points of the region stays on the back. So you checked the X, you didn't check the other two. Right, you would have to check all the boundaries. You do have to check all the boundaries, but do you have to check it using Lagrange multipliers? Like the question is, do you have to go on this and do Lagrange multipliers for each piece of the boundary? Right? Because it's just, that's the same as just setting X1. Exactly. But you do have, I mean, in principle, you do have to do that because it's possible that this peak might be actually higher than anything else, even though you don't have any critical points inside, right? But the value at this point is the maximum possible, right? Now that's where it's kind of a plot, it's not approved, but it kind of tells you, well, the maximum cannot be there. So if you were to plot it here, you see how it's increasing, right? So if you were to plug in 5,000 for X1 in your profit function, and you can do that easily, right? Then, and you would graph that, you would see that it's actually always increasing on that piece, right? Of the boundary, as well as on that piece. So the maximum really occurs on that slanted piece. And then you apply a Lagrange multiplier to that, right? You want to minimize the number of the portions of the regions that you, you can do the Lagrange multipliers. Does it make sense? So a combination of plotting and reasoning is, in the end it's, the thing is you want to make sure you don't, it doesn't, it's something that escapes you so that the conclusions get wrong, right? Any other questions? So we talked about sensitivity to, to this constraint, to the constraint value, right? And we said that if we change this, and we compute the derivative of the optimal value, of the optimal, in this case profit, to the parameter that stands for the constraint, then that ends up being exactly what? So it says sensitivity to the constraint parameter. So in this case, g of x1, x2 equals, in this case it was a sum, but this equals to c, so this is parameter c, was giving that the derivative of the, of the optimal profit which is a function of c in the end, that numerical value is exactly the same as the Lagrange multiplier, the value of the Lagrange multiplier that you found from the method, right? So that's the last thing we talked about, we said we gave a reason why this is the case, right? And we also said that this is called the shadow price and why it was called shadow price because, because the derivative is nothing but the ratio between a change in the parameter and the change in, or in the resulting change in the optimal profit, right? And if, so this is if delta c is small, right, compared to c itself, right? So if c is large like 10,000, then delta c being one, so you have some sort of production. So shadow, shadow price is, I don't think it's a universal concept, I mean it has to be applied in some sort of production scenario or where you have, where you can talk about additional units, additional items that you're producing or selling or some sort, so this is, so if this is considered small, right, of course if you are producing only 10 pieces of something, then it wouldn't make sense to say, well one additional piece is not really, it's not small, it's not a small change, right? It's a big change. But if you have 10,000, then additional, so one additional unit, it means that this is the additional profit, optimal profit, right? It's basically that you kind of look, focusing on that optimal strategy that gives you the optimal profit when you have c number of units compared to the c plus one number of units, okay? So that in our example was lambda, was excuse me, was dy, dc was 24 and this was dollars, right? That actually means it means that allowing one additional unit to be produced yields on additional $24 in profit. So that's the reason for that shadow price, okay? Let's see, any questions from the problems that I've signed? Yeah, which one? The very last one. Problem number five? Problem number five, part A. So this is an unconstrained TV problem. So here you have basically exactly the same revenue function as before, the only the cost, well the profit is decreased by $25 per unit, right? So you have a different objective function that you need to maximize. So you're gonna get a different optimal value, right? So the maximum profit you can make in this situation is gonna be some number, right? So it's gonna be achieved as some optimal x1, x2, right? And I think the second question in part A is just saying, what is the tariff that you're gonna, when you achieve that optimal profit, what is gonna be the tariff you're gonna pay the government? So it's just $25 times the sum of the x1, x2. No, and that's just comparing to the original without tariffs. You lost. $200,000 in lost opportunity, or lost sales. Right, and that's also in part because your optimal strategy probably is gonna change and it has to change. Most likely it's gonna change and the number of units produced for each type. So that's gonna create a different profit, right? So the sum of the two will not actually necessarily give you the optimal profit, right? Let's see, I think I should emphasize again the importance of choosing the right variables to start with, which I think in this case is fairly clear, right? Or not. You see, it kind of starts talking about decision variables. So whenever we specify, these are gonna be our variables and then we're gonna write our objective function in terms of those variables. Those variables, think about them as decision variables because you're gonna have to make the decision, based on the model, you're gonna have to make the decision on what those two variables will be, right? So your X1, X2 are, you know, for problem six, for instance, they even tell you price and advertising. For problem number five, well it's the same as the unconstrained, right? So there are a few kind of important steps to follow here, especially when you have constrained. Make sure you have this feasible region that's respecting all the constraints. Okay, so any other questions? Yeah, no, they're posted on the website. But if you need to ask, we can make appointments. Let's move to chapter three. So, I mean, we could spend a lot of time on each of these type of problems. I think what we wanna do is we wanna start revisiting some of these assumptions. For instance, the assumption that things grow linearly. When you say, like I said earlier, if you have some change in, I don't wanna call it a parameter, but if you, every $100 rebates creates this much added sales, right? That translates, you have to make the assumption that that's gonna be a linear increase, right? But that's not always true. I mean, maybe on a short span, it looks linear, right? But maybe in the long term, and in general, in long term, nothing stays linear, right? So I think the first task is to change that linear assumption in the peak problem because that was a kind of a very simple situation. So we need to kind of remember what that problem said and look at the growth rate, I believe. So revisit the peak problem by changing the linear assumptions on the growth Let's see which one is the first growth rate, right? Growth rate of the pig, maybe I shouldn't say growth rate, but the growth of the pig. So if we say the growth rate initially was five pounds per day, right? That means that the weight was whatever it was initially, plus five times T, right? So that's a linear growth. So instead of that, they're gonna say do it, think about it as a non-linear growth. So the growth rate will no longer be constant. So new assumption, so this is the old assumption, new assumption is that the weight as a function of T is non-linear and of course is debatable what is the true function that describes that but it might make sense to think about something that grows, it is exponentially but it's with a very small constant here. So in the end the slope initially is the same as the linear growth, right? So if you take the derivative of this and set it equal to, at times zero you would get what? You get 200 times 0.05 and that should be five, right? So this slope is again initially the same, yeah, the growth rate, yeah, but it's cumulative. Every day. Well, not really because later days is gonna grow actually faster than, the growth rate is kind of depending of where it's actually compounded, exactly, yeah. So it's a compounded rate, right? Compounded continuously, right? So that's, okay, so now this is not sustainable. I mean for, right, I mean after four days probably you're gonna have to adjust this model, right? And use a different model. But the point of this exercise is to indicate how difficult it is to perform the same task that we performed in first chapter computationally, okay? So computationally we're not gonna be as lucky as going to the computer and asking for, okay, find me the maximum, then when I do sensitivity, find me again the solution as a function of that parameter, plot it and walk away, okay? So very soon you'll see that just relying on symbolic computation and symbolic solutions of equations, it's not gonna be the way to go. And even in simple examples like such as this one. So, right, so basically the new profit function is gonna be, again, x was what, x was the number of days, right? Which was t, in effect, was 0.6. I'm just gonna write down the model, which is now, I forgot, this was a market price, right? And you see, market price assumption is that it drops at one cent per day, and again in a linear fashion, yeah? So you're just changing one assumption in the growth of the weight growth. So minus, I think this was a cost of, okay? So, now the task is maximize f, again, xs would be positive. So, it doesn't seem like anything dramatically different than what we did in chapter one, does it? Take the derivative, 30 equals zero, okay? Except, let's try to run this. So, I think I have, I posted the, what I call an only a pig here, more code. So that's just example 3.1 in the book. And you see the new function, right? So I'm just gonna run it cell by cell. By the way, somebody asked me about, how can you actually type comments within code? And easiest is to create a cell, but don't name it anyway, and just make comments underneath. And when you publish this, it's gonna look just like a text. But, so you can make cells without names. Now, if I put a name here, this is gonna actually show as a subsection or something. Okay, so let's run this. Okay, so the first thing is to plot, right? Get an idea of what's the thing that you look at. And I don't, well, okay, I said between zero and 40. How do I know 40 is the right number? Right, but before you get this graph, if you don't say, if you do zero to 300, so really you have to go through this once and figure out where the critical points might be. And then you adjust the graph. Differentiate this. It probably, did I get an error here? No, okay. It doesn't look pretty here, but, so let me run it again. And I don't know, you don't have to display it. But actually, it's a good thing to compare this with what it was in chapter one. In chapter one, our objective function was quadratic. The derivative was linear. You could take that by hand and figure out where the derivative equal to zero, right? Whereas here, this is how the derivative looks. And then you have to set this equal to zero. So what happens? When you have exponentials and polynomials in an equation and you try to solve exclusively, you could run out of luck. It wasn't the case here because, you know, something happened and it was able to solve it, okay? Did it solve it? Let's see if I display this. Can we see what it is? You can see what it is. It is no longer an explicit function that you can write down, right? It's actually something that's called Lambert. So that's kind of a new function, right? An exotic function that the computer happened to have it in, you know, because somebody 300 years ago figured, you know, this kind of equation is important to solve, so let's just give it a name just to the roots. But, okay, and so anyway, we can solve this and we get 20, 90.47, right? So that's the number of days. In this model, if this model were to be valid for that long of a period, right? Then this would be where the maximum, where the maximum profit would be. Based on the growth rate, right? Which is already kind of, I mean, it's kind of, you cannot really say this is a good model, right? Because after 20 days, if you compute the weight of the pig, it's gonna be probably something, you know, that you don't see in reality, okay? Nevertheless, so let's see what the profit is here. Okay, 139, I don't know if you remember. Before it was 133, right? With the linear growth, and only after eight days, right? So this is not a huge improvement in the profit. Let's see, so what is, okay, so, maybe I'll talk about this in a second. But the point is that it's very soon we will not be able to rely on the computer solving equations explicitly for us. So there is an alternative numerical way of doing it. And it's something that you've probably heard. Newton's method, so that's kind of an implementation of the Newton's method. And it leads, after a few iterations, so I'll talk about this in a second. It leads to about the same value that you would, well, that we did find, fortunately we found it. Okay, but here's, so I'm gonna come back to this. But the big point is, when you do sensitivity, that's when you kind of run into troubles with symbolic computations. So can you guess why? Let me go here, I don't think I even, it's even in the code here. But let me take this, and then right now we're gonna do sensitivity to R, which is the growth rate. Is it growth rate? No. Okay, what's the sensitivity to? One cent drop? Yep. So the price, I mean, yeah, the price drop. This is with respect to R, and I think later we do respect to C, which is the, no, there's no question. Is the 0.025, that's the growth rate. When it's compounded continuously, right? Okay, so which one do you wanna do? You wanna try symbolically. See, okay, let's try C. So let me just take this, I'm gonna do it separately from this. Okay, so I'm gonna, let's say I start from, I know nothing, right, and the computer knows nothing now. So what I do is I just introduce the X and the C. And now I just define this, and I put C instead of this, 0.025. Okay, so that's a function. And now what do I wanna do? I wanna differentiate. So now, believe it or not, differentiation is not, symbolic differentiation is, well, as long as you see the expressions, you know, the computer knows, if you can write an expression, then the computer knows how to differentiate. So that's not a big deal. But now here's the, I hope, when you solve this with respect to X, right? You wanna call this X max, I don't know if X max C, right? So it gives this Lambert again, right? Let me try with, I wanna see if this can do it with the value here, let me see that. Okay, it's still fine because it's the same type of equation, right? So it can do, it has exponentials and it has polynomials in it, yeah, right. And actually, this is what I was hoping that I would see too. So the point is, I mean, the point is that you can, depending on the version that you run, the symbolic capabilities that you have in your version, the newer versions can solve, well, this is not really solving it explicitly, right? It can represent a solution using some fancy functions, right? So it's possible that previous versions, the versions you run, doesn't have that powerful of a symbolic kernel, right? Something in the kernel, it differs, right? I cannot explain, the symbolic thing is a mystery to me, how it works and how it comes up to this, okay? But it's clearly not something that you can, I mean, I can, even though in this example, probably it wasn't that conclusive, but if you do, if you have not just exponentials, polynomials, but maybe also trigonometric functions, and try this, you know, it's looking everywhere, it's like, what function can I use, you know? And I think, you see, it's, I don't know how long it may take, but at some point, if it's smart enough, it will say, well, I don't have any explicit way of writing this, okay? All right. So, I mean, one way or the other, things don't go wrong, right? When you try to, when you rely on getting the solution explicitly. So, okay? Hopefully that kind of explains, that you don't, you cannot just rely on this. So, what this chapter is about is about introducing the numerical ways of solving, right? So, symbolically, solving f prime equals zero may not be successful, right? So, you could get a message that, you know, just don't have enough special functions, specific names for the functions to display that. But still, the solutions do exist, and they have, you know, there's gonna be values. If you have a, if you have a parameter, I think we set C, let's do C. So, C is the growth rate. For each C, there's gonna be a maximum, right? For different Cs, there's gonna be different maximum. Okay? So, what's an alternate? So, alternate method, well, there's always a numerical method for finding roots of functions. So, the basic one is called the Newton's method, right? The most basic one. Let's see, how many of you have seen that anywhere? Okay, well, almost everybody. So, I'm just gonna mention this that if I have a function, let's call it capital F, the reason I call this capital F is, previously we had to deal with F prime equals zero, right? So, sometimes we use this Newton's method for a function, but sometimes we use it for the derivative if we need to find maximum or minimum. Okay? So, in general, this is about finding the roots of a function, and let's call it capital F, and what is the method doing? So, the method is, let's say this is the function, the graph of the function, and it has a root, so it has a zero. For some x, the function F is zero, but you don't know what it is. You wanna find out, I think we call this x star, right? So, what's the method doing? It starts with an initial, so start with an initial guess, x naught, and even this can be problematic, right? So, you have to know, you have to know a priori where this zero, approximately how much it is, because there might be several zeros, right? This function might have several, several zeros, right? This function might have several roots, several zeros, right? So, you have to be somewhat close to this, even though you don't know exactly what it is, but you should start with a close value, and then perform the following operation. So, assuming that, if this point were, well, there's a lot of exceptions to this rule. So, for instance, one thing that you, well, this rule applies is, at the point where you have a zero, the derivative cannot be zero, okay? So, that's kind of this picture, right? The slope is not zero here, so it's not gonna be zero in the neighborhood of this point. So, assuming this, you know, you don't have a horizontal tangent at this point to start with, because then it's a bad start, it's a bad guess, okay? But if it's not zero, then it's gonna intersect the x-axis in a new point and call it x1. That will be the next iteration of this method, of this algorithm. So, you start with x0, you compute x1, and then you do what? Then you repeat the process, right? Is this, sounds familiar? So, then compute x1 as follows. So, what you want is you want, so this is the point where the tangent line to x0 and f of x0, that's this point, intersects the x-axis. And when you do this computation, here's, let's see, so you do the slope. So, the slope is the rise, so this is f of x0 minus zero over x0 minus x1. This is the slope, and we said this has to be the equal to the derivative, that's the slope of the tangent at x0, so f prime at x0, okay? So, when you do this, you get f of x0 over f of, so you get x0 minus x1 equals f of x0 divided by f prime at x0. So, x1 is very easy to compute, it's just x0 minus f of x0 over f prime of x0. Okay, so that's how you compute the x1. And then, iterate. So, once you compute the x1, you're gonna compute x2 in the same kind of fashion. So, in general, the n plus one is gonna be the nth, xn minus f at xn over f prime at xn. Of course, assuming f prime of xn is not zero. So, if you ever have peaks and valleys in the neighborhood of a zero, that's this method is not gonna, it may run into one of those points and then you can no longer divide by it, right? So, you have to have something that is like increasing, strictly increasing and crossing the x-axis. So, there's a nice discussion of this and let's see, I posted here in the codes. There's a chapter of a book, Numerical Computing by Cliff Moller and I linked here as chapter four, you can download it. It talks about various ways of let me see if I can do this or not. Talks about various ways of finding zeros and let me just, Newton's method is this one, right? And we just wrote, of course, little f in our case is capital F. And then it shows the code, what it is and it also shows a few examples like finding a square root of something, right? Square root of x, I mean x square minus m when you find, when you set that equal to zero, you get the square root of m and the minus square root of m and that's how the algorithm goes, right? And it's successful, so you can find the square root of two through that method, right? You get up to a few iterations, you're very close to that number. But it also shows an example where this kind of fails. They call it a perverse example. If it's a cube, it's like a cube root of something, right? I think this is a cube root. Then you see how this method kind of fails because it goes on a tangent, then it gets here, then it goes on a tangent. It never closes in, it doesn't close into the root, right, to the solution. So sometimes, if you're running through such a, you know, it's not that uncommon actually for the Newton's method to have an infinite loop, right? Where the values just jump around. But in our code, so this is a nice thing to kind of try to get, you know, more familiar about this method. But here, it's an implementation of that code of that Newton's method four, the function f, which is the derivative, right? Okay, it's very important, I mean, I'm saying this, it's obvious, but I want to emphasize it because we're trying to find the zero of the derivative. And remember the last time we met, I was trying to find, I was actually showing you finding a zero of a function, but I was supposed to look at the derivative. So anyway, so this is what we do this, okay? Now, it's a grandeur that this f is symbolic, right? In fact, you can see what happens when you don't, when you don't have your function given symbolically. That's a problem for Newton's method. Why, because Newton's method asks you to find the derivative. So if you don't have a function symbolically, how do you find this derivative, right? Well, you would have to do numeric differentiation that's already a topic of numerical analysis. So, but in this case, our f was symbolic, right? We can see what it is. Let's see, I don't wanna, remember, it's never a good idea to start your code in the middle of the script. Just, it's best at least to run through the previous cell. So you define what needs to be defined. So anyway, so this is, so let's, I'm gonna split this into two cells. I'm just gonna run this so you can see. Okay, so that's that function that we're trying to set equal to zero. That's the derivative. Okay, we can plot this if you want. What was the range, I don't know, zero to 40? Okay, so you see it crosses the zero? Probably it's hard to see, but anyway, the range is zero and it's not increasing, it's decreasing, but that doesn't, it's important thing is that it's, it's monazone, it's not, the derivative is never zero in this area. So, see, I, using Newton's method, I picked the initial guess to be 19. I guess that's just because, I don't know why, actually. It doesn't have to be 19. It could be anywhere in this range, right? It could be 35 or something. And let's just run this cell. Okay, so, so what this, the way I wrote this code is it displays the, you see it displays in a kind of fancy way. So if you wanna learn a little bit of how to display in MATLAB, you can kind of read this command F print F. But bottom line is it displays the number of the index of iteration and also the value. The new value, so this is x new, x compared to x old minus. And this is how you evaluate F at x not and F prime at x not. I wrote F prime to be as F1. So this is F, F1 is the derivative of that derivative. So it's really the second derivative, right? Of the, of the profit function. Anyway, so you see how the, it goes really fast. It actually converges really fast. And why do I say it converges? Because you see there's no pattern of kind of oscillating, right? Jumping around. Okay, I mean there is, there's a rigorous theory of why, when this Newton's method converges, but I don't think we need to hear. I think it's fairly obvious that, you know, that's the value, right? And this, this uses none of that Lambert, you know, none of those exotic functions. Yes, it really depends on the function. Yeah, how many iterations? I think it's one of those things that you just, you just try, try a few, maybe try 10. Ooh, I just ran the whole thing, sorry. And then you'll see, I mean it's, it's good to start low and then, ooh, I just, I just told you it doesn't jump, but it looks like it jumps around. You see? But it jumps around a very small, I mean decimal, I mean over here, right? So you could be comfortable in saying, this method gives you an approximate solution. Up to, I don't know how many decimals, right? Exact decimals. So I think it depends, it does even 10. Doesn't cost it to do 100, but it's, it's like one of those things you experiment and then you, okay, and you don't have to display any of them, right? You can just display the last one. But you wanna make sure that it's fairly close. Okay, and there are other ways to stop this. There are better ways to stop this iteration is when you get to, like the difference between these two is with a certain prescribed value number, then you say, well, I don't need any, any better, you know, approximation. So there's a, I think that chapter in the book is, uses a while loop. So you can do that too, but, okay. Anyway, this, so again, this takes the place of that, the, takes the, takes place of that, trying symbolically to do symbolically. And this is actually important in sensitivity, as I said. I mean, I wasn't very convincing because every time I was trying to solve symbolically, you gave me this Lambert, right? But only because it was exponential and it was polynomials. But you saw that, or even in different machines, if you don't have that, I don't know, latest, or something in the setup, a minor work, perfect, then you don't get a solution explicitly. Well, so, so the sensitivity, the way we do sensitivity here is already different than we did in chapter one and two. So here I start with sensitivity to this parameter. And I'm pretty sure when I wrote this code in the version that was then not long ago that it wasn't powerful enough to even solve this. So, so then it made even, I think my comment here was, was maybe right, maybe, maybe it's not accurate anymore, but let's run this here. So the sensitivity is now in just, so it's just in the form of a table. You see? So I just pick values for R and I do this. Okay, well, so I do this here. Yeah, so, but I no longer actually can take, do the derivative of x max R and divide by, right? I don't do that kind of formula for the sensitivity, but I can just say display these values in a table and maybe plot them. So plotting is, I don't know, there's just a fancy way of plotting, but it's just plotting the number of optimal number of days as a function of this, of this parameter, right? It's just another way of seeing this table. And you can see it's not that different than when we had linear assumption, but it's not the same. So with respect to C is again a table and again a sensitivity, okay? Again, there should be a comment once you're done with this and say what is this graph saying, right? It's saying that if we were wrong with that assumption from instead of 2.5%, interesting growth rate, which gives what it was, 19.20 days, right? A relative change in this by how much? I don't know when we have to compute. What's the relative change here versus here leads to a relative change in the number of days, okay? But it's no longer, you don't have a number, right? The homework for Monday, you still have to figure out that using that formula, right? But once we will soon kind of depart from the symbolic computation and just display our sensitivity as a table, as either a table or a graph and comments, right? Any questions? Nice. So I posted this code and I posted, as I said, if you wanna read more about finding zeros of a function, you know, numerically, that chapter is a great resource. What we're gonna be doing next, just kind of a warning, we're gonna be moving to two-dimensional, so finding zeros of systems rather than just of single equations. So we're gonna solve numerically systems of equations, right? Instead of f equals zero, we're gonna say f equals zero and g equals zero simultaneously, numerically. And then the, is the same Newton's method, but it's using matrices rather than just functions and it's gonna use Jacobian of a matrix and so forth. So it's good to understand this in the very simple setting of one dimension, of one equation, okay? So this homework is due Monday and then I'm gonna post some more from chapter three, probably following Monday. Thank you. Your name? Nathan Brown, I may have just not heard you. Oh yeah. I think that's here.