 And so what will often happen when we work with these optimization questions here is oftentimes there is a unique critical number, like we saw right here. That's not always the case, but that happens a lot for these type of textbook examples here. And oftentimes, because there's a single critical number, you get that the optimal solution will be at that critical number. I don't want you to jump the gun though and just to automatically assume that because you have a single critical number, it is automatically the best answer. We'll see some examples later on for which the critical numbers might not be the best answer, it could actually happen at the boundary. But let's move on to another example here. So this one is a purely number theoretic situation here. Find two non-negative integers x and y for which 2x plus y equals 30, such that x, y squared is maximized. So this right here is what we're trying to optimize. I mean, using the words like maximize, that's clear what we're trying to do. Let's take the value z equals x, y squared. We're trying to optimize the value z right here. This is our optimizing function, but it has two variables. We have x and y, much like the previous example, we need to find some way of removing one of the variables. And that's where this constraint comes into play. The numbers must be chosen so that 2x plus y equals 30. Because if we didn't have any restriction on x and y, why not just pick x bigger, bigger, bigger, bigger, y bigger, bigger, bigger, bigger. There's some constraint between the values here. Now much like the perimeter one before, I mean this is very similar like the perimeter situation we had 2x plus y equals some specific number. We can solve for one of the variables y equals 30 minus 2x. And then we substitute that in above right here. And so we're going to get that z equals x times 30 minus 2x. And this is squared. And so we want to maximize this value. So even though our optimizing function is now x, y squared is supposed to x, y and our so quote, unquote perimeter functions a little bit different. There are some different language on this problem. The basic concept is exactly the same. We want to optimize a function of two variables. We use the constraint to remove one of the variables so that our function that we have to optimize is a single variable. And then we're going to take its derivative. Now in terms of the derivative, if you want to, we can multiply this thing out. Because of the squaring here, you have to foil it before you multiply things out. I think I might just live with the factorization here. And I'm just going to take the derivative using the product rule. So take the derivative of x, you get a 1. That'll then give you 30 minus 2x squared, the derivative of the other function, plus x times, take the derivative of the square, we get 2 times 30 minus 2x raised to the first, and then times it by the inner derivative for the chain rule, we get negative 2 there. Let's clean that thing up a little bit. Some things to notice that the first term, the 30 minus 2x squared, showed up. But also the next thing had a 30 minus 2x in it as well. We could factor that out. One of the, actually, the main reason I didn't want to multiply out the, I didn't want to foil out the original expression is because there was a repeated factor, I actually knew that repeated factor was going to be useful as I try to factor the derivative using the product rule. So I actually could find one of the critical numbers faster. All right. So if you factor out the 30 minus 2x, what's left behind? Well, you get 30 minus 2x from the first product, then you're going to get a negative 4x because we had a 2 and we had a negative 2 right there. And so let's see, 30 minus 2x, both 30 and 2 are divisible by 2. You can factor out a 2, leaving 15 minus x. And then let's see, if you take the negative 2x minus 4x, that gives you negative 6x. And then 6 and 30 also have a common factor of 6. If you factor that out, that'll leave behind 5 minus x, like so. And so let's clean that up a little bit more. We get this factor of 12 in front, that won't be too consequential for us, 15 minus x. And then likewise, we're going to get 5 minus x, like so. And this should equal zero because again, we're looking for critical numbers in this situation. Before we start looking at the critical, critical numbers aren't too hard to find at this moment, we're going to get x equals 15. And we're going to get x equals 5. We should, we should at some point think about the domain of this thing. This has a lot more to do with the constraint than anything else here. Because remember, the constraint said that 2x plus y equals 30. And the original, the original expression did say x and y have to be non-negative numbers. So it has to be greater than or equal to zero. So in terms of domain, x has to be greater than zero. But y, in order for y to be greater than zero, well, like we saw before, y equals 30 minus 2x. Clearly, as x gets bigger, bigger, bigger, bigger, bigger, bigger, y will eventually get negative. In particular, when does this thing equal zero? That happens when x equals 15. So the domain of this thing will be from zero to 15. And you'll notice that 15 was one of our critical numbers. So like we said before, it's certainly very possible that the endpoints of the domain could be the maximum values. In this situation, we have one endpoint at zero, another endpoint at 15. It also is a critical number. And then we had a critical number at five. So my intuition is going to be that five, x equals five is the best choice. But that's often what happens. We have this single critical number. But illustrate what's going on right here. If you plug in x equals zero into the function, you're going to get zero times, well, whatever, y squared, that's going to equal zero. And then 15 down here, you're going to get 15. But remember, y is going to equal zero when x is 15. And so this likewise gives us zero. So as often happens, the endpoints give us an optimal solution. If we were trying to minimize area or minimize the product, we want to maximize this thing. So to maximize, we get five times 30 minus 10 is what we get for y this times a 20. So we get five times 20 squared, 400. And so then we end up with 2000 as the corresponding z value for x equals five. And that's going to be our optimal solution here. So notice if x equals five and y equals 20, so these are non negative integers so that two x plus y equals 30, then x, y squared equals 2000 is maximal. It's always a good idea with a story problem to finish it up with a sentence. It's a story problem, you should have a story solution.