Examples of Baire class 2 functions Do you know of examples of Baire class 2 functions which are not Baire class 1 functions, besides the the indicator function of the rationals and the indicator function of the Cantor set?
 A: Here are three examples:


*

*Let $C$ be the Cantor set. For each interval $(a,b)$ contiguous to $C$, define $f$ on $[a,b]$ by 
$$ f(x)=\frac{2(x-a)}{b-a}-1, $$
so $f$ maps the interval to $[-1,1]$. Otherwise, let $f(x)=0$. 

*Write each $x\in(0,1)$ in binary: $x=0.a_1a_2a_3\dots$, not terminating in a string of $1$s, and define $$f(x)=\limsup_{n\to\infty} \frac{a_1+\dots+a_n}n.$$

*Conway's base 13 function.
The first two examples come from Bruckner's book Differentiation of real functions. All three are examples of functions that are not derivatives but have the intermediate value property. 
The first one is discontinuous precisely at the points of $C$, and it is "almost" Baire class $1$, in that one can turn it into a Baire class $1$ function by only modifying its values (carefully) at the endpoints of intervals contiguous to $C$. But if one does this, then the function no longer has the intermediate value property.  
The second function has the property that the image of any subinterval of $(0,1)$, no matter how small, is all of $(0,1)$. The third function is in the same spirit, but it behaves even more dramatically: The image of every open interval is all of $\mathbb R$.  
(I discussed these examples recently in an analysis course, while looking at the problem of how to characterize which functions are derivatives.)
To verify that the functions are indeed in Baire class at most $2$: 


*

*For example 1, use that the limit of $x^n$ on $[0,1]$ is $0$ for $x<1$ and $1$ at $x=1$, to get for each open interval $(a,b)$ contiguous to $C$ a Baire class $1$ function $f_{[a,b]}$ that is zero everywhere except on $[a,b]$, where it coincides with $f$. Now use that the sum of finitely many Baire class $1$ functions is Baire class $1$.

*For example 2, there are several ways to proceed. Here is one, which I do not think is optimal, but will do: Recall that a limsup is the infimum (over $m$) of a supremum (over all $n>m$), so it is enough to see that each $f_m(x)= \sup_{n>m}g_n$ is Baire class $1$, where $$g_n(x)=\frac{a_1+\dots+a_n}n.$$ The point is that each $g_n$ has finitely many discontinuities, all of which are jump discontinuities. Any such function is Baire class $1$. This would appear to mean that $f_m$ is Baire class $2$, but we are saved by noting $f_m$ is the uniform limit of the $g_n$, $n>m$. (The point is that each Baire class is closed under uniform limits.) 

*The argument for example 3 is similar. (Note that this function is unbounded.)
To see that the functions are not Baire class $1$: The functions in examples 2 and 3 are discontinuous everywhere, but the set of points of continuity of a Baire class $1$ function is dense. For example 1, use the extension of this result giving us that, in fact, if $f$ is Baire class $1$, then for any perfect set $P$, the set of points of continuity of $f\upharpoonright P$ is comeager relative to $P$. In example 1 this fails (by design) when $P=C$.
For basic properties of Baire class $1$ functions, a useful reference is Oxtoby's book Measure an category. A reference for the fact that Baire class $1$ functions are closed under uniform limits may be harder to find; it appears for example in the book of van Rooij and Schikhof, A second course on real functions. The latter also discusses example 2 (see their Exercise 9.M).
To close, let me include some examples that do not have the intermediate value property. Note first that if $A\subseteq\mathbb R$ and $\chi_A$ is its characteristic (or indicator) function, then $\chi_A$ is continuous iff $A=\emptyset$ or $\mathbb R$. More interestingly, $\chi_A$ is Baire class $1$ iff $X$ is both an $F_\sigma$ and a $G_\delta$ set. 
Recall that a set is $F_\sigma$  iff it is the countable union of closed sets, and it is $G_\delta$ iff it is the countable intersection of open sets. The notation $F_\sigma$ is pronounced F-sigma. Here, the F is for fermé, "closed" in French, and the $\sigma$ is for somme, French for "sum", "union". Similarly, the notation $G_\delta$ stands for G-delta. Here, the G is for Gebiet, German for "area", "region" -- neighborhood --, and the $\delta$ is for Durchschnitt, German for "intersection". 
Note that, in particular, open sets are both: They are clearly $G_\delta$, and any open interval (and therefore, any countable union of open intervals) is a countable union of closed intervals. It follows that closed sets are also both. In particular, contrary to your claim, the characteristic function of the Cantor set is Baire class $1$. More generally, a function $f$ is Baire class $1$ iff the preimage $f^{-1}(U)$ of any open set is $F_\sigma$.
For the more general case where $A$ is $F_\sigma$ or $G_\delta$, then $\chi_A$ is Baire class $2$. For any $A$ which is either, but not both, $\chi_A$ is an example of a properly Baire class $2$ function. For instance, this is the case with $A=\mathbb Q$. In fact, $\chi_A$ is Baire class $2$ iff $A$ is both an $F_{\sigma\delta}$ and a $G_{\delta\sigma}$ set ($G_{\delta\sigma}$ sets are countable unions of $G_\delta$ sets, that is, countable unions of countable intersections of open sets, and $F_{\sigma\delta}$ sets are countable intersections of $F_\sigma$ sets, that is, countable intersections of countable unions of closed sets). 
More generally, $f$ is Baire class $2$ iff for any open $U$, the set $f^{-1}(U)$ is $G_{\delta\sigma}$. For details, and a significant generalization that characterizes each Baire class, see section 24 in Kechris's book Classical descriptive set theory.  
