 I want to present you another problem that's almost identical to what we just did before. Some of the language is different, but it's going to be basically the same problem as you can see. Imagine we have a Boy Scout who's participating in the sport of orienteering. Now if your nerd sense is going off right now, that's because orienteering is the sport of compass, using a compass, right? So not a lot of people probably know how to do that nowadays, but it's kind of a thing that a nerdy Boy Scout would do. Talkingly, I did this myself when I was about 14 years old, 13 years old. Anyways, so he's participating in the sport of orienteering and he must find a specific tree in the woods as fast as possible. So again, it's a race. So like the last one, he has to do it in the fastest time possible. It doesn't matter about speed, it doesn't matter about distance, he needs to do it fast. It's part of a race. So he can get there by traveling east along the trail for 300 meters, as you can see illustrated. And then north through the woods for 800 meters, you'll notice that the diagram is not drawn to scale. They never are. He can run 160 meters per minute along the trail, but only 70 meters per minute through the woods, because he doesn't want to run as fast, he might trip on a rock or run to a tree or something. Running directly through the woods towards the tree minimizes the distance, but he'll be going slowly the whole time, kind of like with our rower, right? The rower went diagonal, he went slower than we went straight. So find the path, though, give the Boy Scout to the tree in the minimum amount of time. Same basic idea as last time. We're going to say x is the distance from where he leaves the trail to the end of the trail, then we're going to get 300 minus x right here as the distance he'll run along the trail. And then you get the square root of x squared plus 800 squared. As the distance he'll run through the forest there, he can go down the trail at a speed of 160 meters per minute. And then he can run through the woods at only 70 meters per minute. What's the optimal solution? Well, it's going to be very similar to as before time. We call the time he spends on the trail plus the time he spends in the woods. The time he spends on along the trail will be 300 minus 7 meters divided by 160 meters per minute. That would give us minutes. And then the time he spends in the woods will take the square root of x squared plus 800 squared all over 70. You'll notice I haven't squared 800 yet. I'm not going to for a while. I'm practicing what is often referred to in computer science as lazy computation. I will get around to it when I finally see a need. I don't see it yet, so I'm going to wait. If we take the derivative of t with respect to x, we'll get negative 1 over 160 plus we're going to get 170th times 1 half times x squared plus 800 x 800 squared to the negative one half power and times that by 2x. You'll notice again that this one half cancels with this too. And we get zero equals negative one sixtieth. We end up are right. I'm sorry. Not equals. That should be plus x sits above 70 times the square root of x squared plus 80 800 squared. This is calculation is almost the same thing, right? We could actually have put some variables in the original setting and try to solve this optimization problem in general. We're not going to be that ambitious right here. So x over 70 times the square root equals 160 one over 160. Again we will cross multiply. We get that 160x equals 70 times the square root here. There is a common factor of 10 between 70 and 160. Let's cancel that out. And so then square both sides. We're going to get 16 squared, which is 256 times x squared. This equals x. I'm sorry. 49. Don't forget that 49x squared plus 800 squared. Distribute the 49 we get 49x squared plus 49 times 800 squared. I'm still being lazy in my computation here. So track 49x squared from both sides. You'll get 207x squared equals 49 times 800 squared. And so divide both sides by 270, not 270, 207. So you get x squared equals 49 times 800 squared over 207. And so then if we take the square root, you can see my laziness is paid off, x equals 7 times 800. I never knew how to know what 800 squared was, the square root of 207. And so that right there is approximately 389 meters. Okay. Coming back up to the picture above. What's the feasible range for x right here? Well, x could be zero, in which case the boy runs immediately through the woods. And x could all be up the way to 300 who runs the end of the trail and then goes to the forest like that. 389, isn't that what we just got a moment ago? That would be like running down here and going backwards through that. That's not going to be an optimal solution. That's outside the domain right here. So it's like, huh, weird. And so if we look at our T chart that we're going to create, turns out we don't want this number. The critical number doesn't work. I mean, it does work, but it doesn't give us the optimal solution we're looking for. So we're looking for zero to 300, which if you plug in zero, it'll take the boy 13.3 minutes. And if he goes, if he goes down the end of the trail 300, then gets off, then I'll take him 12.21 minutes. And so this right here will give us the optimal solution. This is the minimum value. And so like I was mentioning before, in the last video I mentioned, I don't know if I don't remember mentioning this video here, but when it comes to optimization, the critical numbers do not always give us the best answer. They oftentimes do. And because they do so often, we kind of forget that they're not the only options. The end points might be optimal solutions as well. In terms of this case, minimizing the best strategy for the boy will be run 300 meters down the trail to the end and then go, then go, I mean, the trail doesn't end at 300 meters, but if he keeps on going, that's going to add more distance, more time than necessary. So do always make sure you're checking the end points, not just the critical numbers. Sometimes the end points are silly. They give you like zero or infinity or things like that, but they actually can give you the optimal solution. So watch out for them.