Do constraints influence the domain of the objective function in optimization problems? I'm trying to devise a general method for finding the domain of objective functions, but it's unclear to me whether or not the constraints are taken into consideration.
It seems the constraints will affect the domain of an objective function, but there are instances in James Stewart's Calculus (8th edition) where it's unclear if the author is deriving the domain of the objective function from the function itself, without considering the constraints, or if the constraints are being considered.
For example,

Example 3) Find the point on the parabola $y^2 =2x$ that is closest to point $(4, 1)$

Constraint: $y^2 = 2x \Rightarrow x = \frac{1}{2}y^2$
Objective function: $d= \sqrt{(x-4)^2 + (y-1)^2} \Rightarrow d(y) = \sqrt{(\frac{1}{2}y^2 -4)^2 + (y-1)^2}$
The author implies that the domain of $d(y)$ is $(-\infty, \infty)$, but he doesn't explain how he arrived at that. It seems to me that the author used the objective function, without considering the constraint, to derive its domain since looking at it we can see that $d(y)$ would be defined for every value of $y$.
Looking at the constraint, it was rendered a polynomial function of $y$ which will be defined over $(-\infty, \infty)$. So maybe the constraint wasn't considered because it had no bearing on the domain of the objective function due to being defined everywhere and thus unbounded when written in terms of $y$. If the constraint were written in terms of $x$, $y = \pm \sqrt{2x}$, then the domain of the constraint becomes $[0, \infty)$. When substituting the constraint $y = \pm \sqrt{2x}$ into the objective function, $d(x) =\sqrt{(x-4)^2 + (\pm \sqrt{2x}-1)^2}$, the domain of $d(x)$ becomes $[0, \infty)$. Thus it would seem to be the case that the domain of the constraint does affect the domain of the objective function, and furthermore depending on which variable the constraint is written in terms of also affects the domain.
If the constraint is viewed as a function, then substituting it into the objective function renders the objective function a composite function. Viewing it this way makes sense that the constraint's restricted domain would also restrict the objective function's domain.
Therefore, it seems that to find the overall domain of the objective function we would use the same process or method employed when finding the domain of any composite function. In other words, when finding the domain of the objective function we DO consider the constraint (more precisely its domain).
But I'm uncertain if my thoughts on this are correct and would appreciate some guidance and/or input.

*

*Does the constraint affect the domain of the objective function?


*Tips or general thought process on how to find the domain of the objective function

From a pedagogical standpoint, my advice to students is to consider the domain of the quantity to be optimized and then restrict it further based upon the larger context of the problem. I do not believe there is a universal algorithm for this process as this class of problems is highly varied.
