After replacing \(f\) by \(-f\) if necessary, we may assume \(f(a) \lt 0 \lt f(b)\text{.}\) Let
\begin{equation*}
S=\{x \in [a,b] : f(x) \lt 0\}.
\end{equation*}
Then \(a \in S\text{,}\) and \(b\) is an upper bound of \(S\text{.}\) So \(c:=\sup S\) exists. Since \(a \in S \subseteq [a,b]\text{,}\) we have \(c \in [a,b]\text{.}\)
We claim that
\(f(c)=0\text{.}\) Suppose first that
\(f(c) \lt 0\text{.}\) Then
\(c \lt b\text{,}\) since
\(f(b) \gt 0\text{.}\) Choose a sequence
\((x_n)\) in
\((c,b)\) such that
\(x_n \to c\text{.}\) By continuity of
\(f\) at
\(c\text{,}\) we have
\(f(x_n) \to f(c) \lt 0\text{.}\) Hence
\(f(x_n) \lt 0\) for all sufficiently large
\(n\text{.}\) For such
\(n\text{,}\) we have
\(x_n \in S\) and
\(x_n \gt c\text{,}\) contradicting the fact that
\(c\) is an upper bound of
\(S\text{.}\)
Now suppose that
\(f(c) \gt 0\text{.}\) Then
\(a \lt c\text{.}\) For each
\(n \in \N\text{,}\) let
\(m_n=c-(c-a)/2^n\text{.}\) Then
\(m_n \lt c=\sup S\text{,}\) so
\(m_n\) is not an upper bound of
\(S\text{.}\) Therefore there exists
\(x_n \in S\) such that
\(m_n \lt x_n \le c\text{.}\) Since
\(m_n \to c\) and
\(m_n \lt x_n \le c\) for every
\(n\text{,}\) the squeeze lemma gives
\(x_n \to c\text{.}\) By continuity,
\(f(x_n) \to f(c) \gt 0\text{,}\) so
\(f(x_n) \gt 0\) for all sufficiently large
\(n\text{.}\) But each
\(x_n \in S\text{,}\) so
\(f(x_n) \lt 0\) for every
\(n\text{,}\) a contradiction.
Therefore
\(f(c)=0\text{.}\) Since
\(f(a) \lt 0\) and
\(f(b) \gt 0\text{,}\) we have
\(c \neq a\) and
\(c \neq b\text{.}\) Hence
\(c \in (a,b)\text{.}\)