Now let's use our EOQ model to give you an illustration. Of course, we have all other kinds of illustrations but here let's just talk about our EOQ. Recall our EOQ problem, which is the economic order quantity problem. In this case there is a decision-maker. He wants to determine the order quantity in each order in the following environment. Pretty much the demand is deterministic. Every day you will see some constant usage of your demand. Then at some point you would obtain the order, then it will go up to the order quantity. Then you will get constant consumption. Then you get the replenishment again, and so on. Demand is deterministic. Then regardless of the order quantity, there is a fixed ordering cost. Every time when you place an order, you're going to pay $5, for example. Then it doesn't matter whether you order 10 units or 20 units. We don't allow shortage. That's why whenever you hit the boundary, whenever you hit zero, you should get replenished. Then ordering lead time is zero. To the margin you would agree, there's not really a need to have this constraint or assumption because if you do have some lead time, all you need to do is to just order a little bit earlier. But anyway, it's equivalent to say there's no ordering lead time. Then finally, the inventory holding cost is also constant. Because of this inventory shape, we know pretty much we are having q over 2 as our average inventory level. That's how we later would calculate the inventory cost. Thus give notations for this problem. We would say we have some parameters. Capital D is the annual demand as the annual number of units that you are going to sell in a year. Capital K is the unit ordering cost per order. The h is the unit holding cost per year, per item, or per unit. A small p is your unit purchasing cost. These are some given information. Also we have our decision variable, which is small q. That small q is going to somehow determine your ordering cost, which is related to K, and you are holding cost which is related to h. Later we will see the formula. If our q is too large, we are going to pay a lot of inventory costs because we're going to have a lot of inventory once we get in order. But if your q is too small, then you need to pay a lot of ordering cost. That's also not efficient. So we want to find the best q to minimize our annual total cost. For all our calculation, maybe you need to make sure that you are all using the same unit of measurement. Maybe we may use one year as our time unit. That's something you may do when you are talking about demand because for demand you always have monthly demand, weekly demand and so on and so on. You need to make sure that your demand unit and the cost unit are having the same unit of measurements. Somehow, you may consider D as your demand rate if you are having the correct usage of your unit of measurements. Let's formulate this problem. Our annual holding cost, as we mentioned, is h multiplied by q over 2, because q over 2 is our average inventory level. Average inventory level multiplied by the per unit inventory costs h. Once we determine q and then use that to go through one year, that's going to give us hq over 2 as the total annual holding cost. The annual purchasing cost is p times D because somehow you need to purchase D units and then to sell them. You are purchasing cost is just pD and it has nothing to do with your ordering quantity. Your annual holding cost depends on the total orders you'll need to place in a year. In total, you need D units, and in each order you'll have q units. So D over q is the total number of orders you are going to a place in a year, and the KD over q would be your annual total ordering cost. If we collect all the things and ignore this irrelevant pD, we're going to solve this problem. We want to find a q to somehow minimize the sum of ordering cost and holding cost. That's our problem. Previously, we know how to formulate this problem. If you give me numbers, I may also do some line search or do some gradient descent, whatever, or invoke a solver. I know how to solve this problem. I may get solutions or I may get numbers. But previously there are two issues. The first issue is that previously what we are doing is that we are getting numerical solution, but now we want to get analytical solutions. That's one thing. Second, previously when you use gradient descent or whatever method for this problem, you get converged to a solution that's a local mean. But how do you know it is the global mean? Previously, we ignored this issue, now let's deal with that. For now, what we may do is that, this is our total cost function. Now, we know we may do some first order derivative, second order derivative. For first order derivative you may see that your q here as the denominator is going to be q squared in the denominator. On the contrary, for this q that is at the first-order term, is this up here. That's how you get your first order derivative. Then, you do the derivative again with respect to q. Then this particular term which goes away and then you get something like this. A very good thing is that now we may say, this is a positive value for any possible q. When we are talking about the feasible region, which is from zero to infinity, whatever q you give me, we know the second order derivative is positive. Certainly, you cannot replace q by zero, and you won't do that because that's not going to be feasible. Somehow, when we are talking about this, we know this function is convex. Graphically, we know the ordering cost decreases in q and then the holding cost increases in q, so the sum which is the total cost, this curve, naturally is convex. We have proved that it is indeed convex, by showing that the second order derivative is always positive. Instead, now we know if there is an optimal solution, it's going to satisfy the first-order condition. Your q star should have your first order derivative zero and after some arrangement, you are going to see that that means your q star should be this particular formula, the square root of 2KD over h. This is our analytical solution. You don't need to give me numbers, I still solve it. In the future, if you give me specific numbers, I don't need to call the function. I don't need to call those algorithms in the two iterative search. I don't. All I need to do is to plugging numbers into this formula and then I'm done. That's how we say this is an analytical solution. This quantity is feasible and this quantity is optimal. Plus, we may plug in this number back to your TC function and that's going to tell us that your total cost would be the square root of 2KDh. How do you do that? Your TC of q is KD over q plus hq over 2. All you need to do is to replace q by this particular formula and then after some arrangements, you will see this. The last thing I want to say about EOQ is that EOQ now serves as two purpose. First, it's a decision tool. If you tell me KD and h, I then tell you what's the amount to order. That's good. Also, it has managerial implications, it tells us what. If your ordering cost increase, that's going to increase your order quantity. Why is that? Because if each order cost you a lot, you need to decrease the number of orders in a year, so you need to increase your ordering quantity. If your annual demand goes up, then what do you do? You increase your order quantity. Again, that makes sense, because if you don't do that, you will have too many orders in a year. You shouldn't do that. You should increase your order quantity somehow. Then lastly, your ordering quantity is going to decrease in your holding cost h. Why is that? Because if your holding cost is high, you should not have too many inventory, so you should cut down your ordering quantity to cut down your inventory level. Analytical solution is good in a sense that it helps us understand the behavior of your solution whenever some parameter changes. That's going to help you first intuitively confirm whether your solution makes sense and second, to understand the behavior of your solution and finally, help you to do things like sensitivity analysis, to understand the impact for the parameters, to somehow predict what's going to happen in the future, and so on. Through this example, I hope you see how do we apply the second order derivatives to check whether a function is convex? How do we apply first-order derivative?How do we obtain an analytical solution? How an analytical solution makes sense to us?