Suppose I have a convex cost function $f(x)$. I want to use a first-order optimization algorithm (eg bisection method) to minimize $f(x)$ with respect to $x$. But $x$ is constraint to be between $0$ and $1$: do I need to make it a constraint optimization problem or is it enough to minimize $f(x)$ with respect to $x$ and whenever x is outside of the interval of $0$ and $1$ to just make it $0$ or $1$? If I analyze it visually, it seems that it is okay to round it back to $0$ or $1$ if the optimal $x$ is outside the $0,1$ interval.
If this is okay: why? And if not: why? :)
Any help is appreciated.
Local minima of a convex function are global minima. Hence if $[0,1]$ does not contain a local minimum, it must be monotonic on the interval and so the constrained minimum will occur at $0$ or $1$.