# Real Analysis: Continuity & Intervals

## Homework Statement

If the domain of a continuous function is an interval, show that the image is an interval.

## Homework Equations

Theorem from book: f is a cont. function with compact domain D, then f is bounded and there exists points y and z such that f(y) = sup{ f(x) | x ∈ D} and f(z) = inf{ f(x) | x ∈ D}
The intermediate value theorem.

## The Attempt at a Solution

Case 1: D=[a,b]
Since D is compact and by hypothesis, f is continuous we know that there exist points y and z in D such that f(y) = sup{ f(x) | x ∈ D} and f(z) = inf{ f(x) | x ∈ D}. By definition of sup and inf these are the greatest and least points of the image of f. And so, by the intermediate value theorem, we know that any t in between f(z) < t < f(y), there exists an x in D such that f(x)=t. So, we can write the interval of the image as [f(z),f(y)].

Case 2: D=(a,b)
We can write (a,b) as an infinite union of closed sets. For example ∪[a+1/m, b-1/m] from m=1 to infinity.
By the previous case we know that each [a+1/m, b-1/m] attains a sup and inf value for all 1/m. Now we can simply take the max( sup{ f(x) | x ∈ [a+1, b-1]}, sup{ f(x) | x ∈ [a+(1/2), b-(1/2)]}, sup{ f(x) | x ∈ [a+(1/3), b-(1/3)}, ... ) and call it p. Similarly we can take the min( inf{ f(x) | x ∈ [a+1, b-1]}, inf{ f(x) | x ∈ [a+(1/2), b-(1/2)]}, inf{ f(x) | x ∈ [a+(1/3), b-(1/3)}, ... ) and call it q. This will give us an open interval in which all values of the image lie. And so, the interval of the image of f is (q,p).

Is this the right way to prove this? It seems right to me but I also have my doubts haha. Thanks!