Now, we are ready to minimize the total risk. For our example, that's the variances of buying one share of stocks; one, two, and three, P 100, 1600, and 100 respectively. This of course, may actually or should actually be calculated according to the probability distribution for each random outcome, so we're going to skip that part because that part has nothing to do with optimization. Using your statistics or probability knowledge, if you know the random distribution for random outcomes, you're going to be able to calculate these numbers. So these numbers are actually parameters from the perspective of Operations Research. So accordingly, when we buy x_i shares for stock i, the total variance would be expressed in this way. Because 100 over 1600, 100, they would enter here, here, and here, and then you increase your variance by buying more. Your product 2, your investment target 2, this stock 2 has high expected revenue, its high expected revenue is here, but its variance is also very high, so you need to get some trade-off and that's very natural if you are talking about stock investment. If the minimum required expected revenue is r, for example, if you tell yourself that, I'm going to invest 100,000, I want some 10 percent return rate at least, then I'm going to set my r to be 110,000. Once I set this value, I now try to solve this non-linear program. I want to find x1, x2, and x3, such that I have enough budget, I can get this minimum required revenue expectation, and I want to blend my portfolio so that I may minimize the total risk. That's the idea of doing this nonlinear program. If you don't play stocks, you probably feel that this is a little bit unnatural, but this is actually something suggested by Nobel Laureates. So that's also some big findings in the past because actually before that, no one can systematically giving some trade-offs between risks and returns. This probably is one of the very first and very important suggestion for people to systematically model risk and the model expected return, and only if you have a model, you may have some computer programs, algorithms to automatically create some investment strategies, and that actually creates a whole new world. I don't play stocks, so I'm going to continue to take a look at the mathematical parts. Actually, if you really try to solve the models, you're going to get some managerial implications, which are also very interesting. Given different values of r, if you try to use some solvers to solve the problems, you will get different optimal portfolios. For example, when you see that you are expected profits becomes higher, higher, and higher, then you're going to allocate your budgets to these three stocks in different ways. For example, if you want 102, 104, 106, if you get a higher and higher expectation, you're going to see that eventually you really need stock 2, because if you don't buy stock 2 as much as possible, you're not going to meet your target, so that's one thing. Also, very interestingly, you may see that sometimes buying stock 1 is a must. Well, you may see that stock 1 is here, why do we want to buy stock 1 in most cases? Because stock 1 is a good choice, it has also some high return, but its risk is small, its variance is small. So almost always we need to buy stock 1. Sometimes you even can see that we would need to buy some stock 3. If you'd go back to take a look at stock 3, stock 3 is actually losing money in some sense, but if you don't really require a high expected revenue and you need to control your risk then because stock 3 is somehow cheap, then you are going to spend some money on stock 3. That would be interesting. If you don't do that, that's actually not an optimal way of doing investments. Also, given different values of r, if you want to earn more, more and more, obviously, you get different optimal portfolios, and then you're going to see you need to bear higher and higher risk. So when you want more and more and more, people would tell you that please stop, because then the risk becomes higher, higher and higher. This models may actually help you to see what's the reasonable expectation with no high risk? So this is also some benefit you may have if you are using a model to do that. In practice, people are using these kinds of model a lot, and obviously, we may want a compact formulation to make it general. Let's say we want to invest B into n stocks, the minimum required expected return is still r, the current price is Pi, for stock i, and the expected future price would be Ui, also you don't really have two prices, you just have one price, Then the variance of buying one share would be Sigma i_2, is the variance. So x_i is still our decision variables, the compact formulation would be here. I have budget constraints, and I want to have a guaranteed expected return. I want to minimize the total risk. The key here is that this term, again, x_i squared is a square term, is quadratic, so this is a nonlinear program, and you know there's no way for you to get rid of it because you are talking about variance that is naturally a squared term. In practice, actually people do something more. People understand that there are correlations among stock prices. What does that mean? If you take a look at the stock market, in many cases, some different companies, stocks, they go up or go down at the same time. For example, if you are selling similar products. Then when some people in the world saying that eating these products is very good, then both you and your competitors' stock price may go up because people like these products at the same time. So in that case, thus price amongst tags are typically correlated. I just gave you an example about positive correlation, sometimes they are also negatively correlated from time to time. For stock i, and j, actually we may have Sigma ij as their covariance, With that covariance now we are able to do some more detailed formulations or extended formulation, people suggest is to minimize the total risk, right? The total risk now not just depends on the first term, it also depends on the second term, which is a more thorough formulation regarding variance. When you buy several products and if each of them has some random outcome, and if the random outcomes are correlated, then the formulation would become this one, so to fully explain why it is in this case, it becomes a statistics or probability course. I'm going to stop here. All I want to show you is that this here is a square term, this is a product term, that's how this is a nonlinear program, and indeed, in many cases, nonlinear programs are useful and important. That's all I want to say about this portfolio optimization example.