I ran into this problem recently:
You are given the function $f(x) = x^2 + (n - 1 - x)^2$ defined on the closed interval $[0, n-1]$. Find the maximum value of this function by providing an or more $(x_{max}, f(x_{max}))$ pairs.
My understanding so far is to proceed like I would in Calc 2, finding f', getting critical points, plugging in those values in f, etc. My work so far:
$f'(x) = 4x-2n+2$
$f'(x) = 0$ when $x = (n-1)/2$
$f((n-1)/2) = 2((n-1)/2)^2$
This is where I get stuck; is this an answer? I'm not sure where the domain upper bound of n-1 even plays into this. I'm not familiar with the concept of a varying domain.
The words "defined on" in this problem signify that the domain of the function $f(x)$ is $[0,n-1]$. The value you arrived at for $x_{max}=(n-1)/2$ belongs to this domain. Hence, there is no need to worry.
Remember that we cannot comment about the validity of the $y$ value $=f(x_{max})$ as long as we don't know the codomain.
Remark: you did not check the sign of $f''(x)$. But it turns out this did not matter since the question is asking you a maximum and there is only one extremum. So, that extremum must be a maximum. (if the question is assumed correct that is)