 This time, we're going to be looking at another example of applying Amdahl's law to optimizing programs. As with the previous example, I'm going to be looking for how much time am I spending on each of these programs on average and then improving the most expensive one. So I'll start with program one again. Program one is 10% of my total computation, and every time I run program one, it takes 12 seconds. So on average, I spend 1.2 seconds on program one. Program two is 30% of my total computation, and that's going to take five seconds. So 30% times five seconds gives me 1.5 seconds. Then program three takes the remaining 60% of my computation, and that takes three seconds to run. So that will give me 1.8 seconds on average. So this time, program three is the most expensive. That's consuming more of my time on average than any of the other programs. So I would want to optimize program three first. Program two is taking the next most amount of time, so I would optimize it second. Then maybe once I've improved those two quite a bit, then I would work on program one. This may seem a little backwards. Program one is clearly much more expensive than either of the other two, but a whole lot more of my computation is related to program three. Two times as much computation happens in program three as in program two, and six times as much as in program one. So in this case, I'm really interested in running program three a lot. As a result, it's not as important that program three doesn't take a whole lot of time to run because I'm running it almost all the time. Again, if I want to know how much I need to speed up program three before I would switch to optimizing program two, well, I'm just going to look at the ratio of these two times. So once program three has been improved by 1.8 divided by 1.5 times, 18 over 15 or six-fifths, then I would switch to optimizing program two. If I want to know what that tells me about the execution time for program three, then I need to apply this speed up to the three seconds. So I'd have five, six times three seconds. I'll have a three in the numerator and a three in the denominator, which will cancel. And that would tell me that once program three takes less than 2.5 seconds to run, then I'd be interested in switching to program two. Remember that the six-fifths is the speed up that I've got. This is how much I'm improving program three. And that turns into a five-six when I actually want to apply it as an execution time. If I just applied six over five to my three seconds, then I would get a larger number. Whereas I'm expecting to improve my performance slightly, so I want to get a smaller execution time out in the end. So again, I'm going to get diminishing returns if I focus on just optimizing say program three, which is why once I get to this threshold of 1.5 seconds, then I would switch to optimizing program two. I don't just want to focus on optimizing a single program in this case.