Case 1: f(a)β€yβ€f(b). Let
S={xβ[a,b]:f(x)β€y}.
Since f(a)β€y we have aβS, so S is nonempty; and xβ€b for every xβS, so S is bounded above by b. By the least upper bound property recorded in The Real Line: Standing Notation and Background for Calculus Β§completeness, c=supS exists. Since aβS and c is an upper bound for S, aβ€c; since b is an upper bound for S and c is the least one, cβ€b. Hence cβ[a,b], and f is continuous at c, since continuity on [a,b] means continuity at every point of [a,b] by The Real Line: Standing Notation and Background for Calculus Β§continuity.
Step 1: f(c)β€y. Suppose instead that y<f(c), and put Ξ΅=f(c)βy, so Ξ΅>0. By continuity of f at c there is Ξ΄>0 such that every xβ[a,b] with β£xβcβ£<Ξ΄ satisfies β£f(x)βf(c)β£<Ξ΅, and hence satisfies
f(x)>f(c)βΞ΅=y.
Let sβS. Then sβ€c, because c is an upper bound for S. If cβΞ΄<s, then β£sβcβ£=cβs<Ξ΄, so f(s)>y, contradicting sβS; hence sβ€cβΞ΄. Thus cβΞ΄ is an upper bound for S, and since c is the least upper bound, cβ€cβΞ΄, whence Ξ΄β€0 by Elementary Order Arithmetic in an Ordered Field. This contradicts Ξ΄>0. Therefore f(c)β€y.
Step 2: yβ€f(c). Suppose instead that f(c)<y, and put Ξ΅=yβf(c), so Ξ΅>0. Since f(c)<yβ€f(b) we have f(c)ξ =f(b), so cξ =b; combined with cβ€b this gives c<b. By continuity of f at c there is Ξ΄>0 such that every xβ[a,b] with β£xβcβ£<Ξ΄ satisfies β£f(x)βf(c)β£<Ξ΅, and hence satisfies
f(x)<f(c)+Ξ΅=y.
Let x0β=min{b,c+Ξ΄/2}. Since c<b and c<c+Ξ΄/2, we have c<x0β; and x0ββ€b. Together with aβ€c<x0β this gives x0ββ[a,b]. Moreover 0<x0ββcβ€Ξ΄/2<Ξ΄, so β£x0ββcβ£<Ξ΄ and therefore f(x0β)<y. Hence x0ββS, so x0ββ€supS=c, contradicting c<x0β. Therefore yβ€f(c).
Steps 1 and 2 give f(c)=y, which proves Case 1.
Case 2: f(b)β€yβ€f(a). Define g:[a,b]βR by g(x)=(β1)β
f(x). By clauses 4 and 5 of Continuity of Sums and Products of Real-Valued Functions on a Metric Space, g is continuous on [a,b]. Multiplying the inequalities f(b)β€yβ€f(a) by β1 reverses them, by Elementary Order Arithmetic in an Ordered Field, so
g(a)=βf(a)β€βyβ€βf(b)=g(b).
Applying Case 1 to g and to the value βy yields cβ[a,b] with g(c)=βy, that is, βf(c)=βy and hence f(c)=y.