TITLE: Why exactly does a function need to be continuous on a closed interval for the intermediate value theorem to apply?
QUESTION [5 upvotes]: I apologize if this question is too basic. The intermediate value theorem states that if $f$ is continuous on a closed interval $[a,b]$, then for every value $c$ between $f(a)$ and $f(b)$ there exists some $x \in (a,b)$ such that $f(x) = c$. This, or some very similar variant thereof, is how the intermediate value is usually presented in textbooks. What bugs me, however, is the condition that $f$ need be continuous on the closed interval $[a,b]$ rather than the less strict condition of only being continuous on the open interval $(a,b)$. To illustrate this point, consider $f:[-1,1] \rightarrow \mathbb{R}$ where $f(x)= e^x$. This is only continuous on the open interval $(-1,1)$ but surely the IVT applies to it. A less artificial example would be the inverse sine function. Would this reasoning not apply to all such (continuous/well-behaved) functions?
As an alternative, wouldn't the following definition from Proofwiki be superior (in that it is slightly more general)? 
Let $I$ be a real interval. Let $a,b \in I$ such that $(a,b)$ is an open interval. Let $f:I \rightarrow \mathbb{R}$ be a real function continuous in $(a,b)$. Then for every value $c \in \mathbb{R}$ between $f(a)$ and $f(b)$ there exists some $x \in (a,b)$ such that $f(x) = c$

REPLY [2 votes]: I think 5xum's answer gives a good example. The general reason you need continuity on a closed interval is that you need to tie the values $f(a)$ and $f(b)$ to the values the function takes on the rest of the interval. If the function is not continuous at the end points then its value at the endpoints need have nothing to do with the values the function takes on the interior of the interval.
If you did want to change the IVT to work for an open interval you could use the following modification.
Let $f(x)$ be continuous on an open interval $(a,b)$ and let $c,d\in (a,b)$ such that $f(c)<f(d)$, then $\forall e\; (f(c)<e<f(d))$ there exists a $g\in (a,b)$ such that $f(g)=e$.