Question: What are good examples of functions $f: \Bbb R \rightarrow \Bbb R$ (or $f: D \rightarrow \Bbb R$ with $D \subseteq \Bbb R$) which are not just given by "a formula" (or finitely many formulae on explicitly given intervals), but make sense to a beginner / good high school student?
I know that for a wide enough definition of "formula", that's exactly what a function is. But here, by a formula I mean a finite algebraic expression of real powers of $x$ as well as (inverse) trigonometric functions, exp, logs and absolute values; more or less what one would call elementary functions, and what many students falsely believe to be all functions, which is exactly what I want to counter with such examples.
Background: Teaching a first-year Calculus course (in North America), the first thing I need to make sure is that the students know what a function is. I am aware of the effort pre-calculus teachers put into explaining functions as "input-output-machines", cf. this question. And when talking of functions whose domain and/or range are arbitrary sets, letters, geometric shapes, colours, animals, cars etc., as in those discussions, students know that those functions are not given by an "algebraic formula". However, as soon as we start talking about "real" functions (meaning strictly: those whose domain and range are subsets of $\Bbb R$) I see that, subconsciously, almost every student falls back to the belief that "a function is a formula", in the above narrow sense.
In the first week of such a course one puts in a little (p)review of what functions can be, typically using piecewise defined functions (including ones with some jumps or removable discontinuities). However, these surely feel very artificial to students. Also, even if they quickly take in that information, I fear they now basically believe that a function is a collection of possibly several "elementary formulae", just one at a time / for each "piece".
Obviously I cannot use any of the many non-elementary functions which are given as integrals, power series, or solutions to differential equations, because these are accessible at the end of a calculus lecture (at best).
(Edit: And, cf. discussion in the comments, I should have said that these non-elementary but highly applicable functions are what I eventually want to get at here, and I think every calculus course -- even if it's not aimed at mathematicians -- should care about them. The FT of Calculus (and later, the theories of differential equations and power series) gives us tons of differentiable functions which cannot be expressed by elementary formulae. I firmly believe that many functions encountered in higher engineering and physics are actually of this kind. And students have a very hard time understanding this. Teaching the course before, near the end of the course I have assigned them questions like
What are the zeroes of the function $F(x) = \int_2^x \frac{dt}{\log(t)}$
or
With the usual curve sketching routine, sketch the graph of the function $G(x) = \int_0^x \frac{\sin(t)}{t} dt$
which should be easy resp. doable for anyone who understands the Fundamental Theorem and the basics of calculus (for the first one, I even give them as hint: there's an obvious one, and then think about whether the function increases). But students struggled a lot with these questions, and I think one of the biggest reasons for that is that they don't "get" what the actual function is; many try to answer the questions for the only functions-given-as-formula they see in there, $1/\log(x)$ resp. $\sin(x)/x$. End Edit)
The best examples I have come up with, which have sort of worked in the classroom, are
- the prime-counting function $\pi(x)=$ number of primes $\le x$
- the Dirichlet function $Dir(x) = \mathbf 1_\Bbb Q = \begin{cases} 1 \text{ if } x \in \Bbb Q \\ 0 \text{ if } x \notin \Bbb Q. \end{cases}$
I have also played around with ideas like
- $f(x) =$ the first decimal place in the standard decimal expansion of $x$ where a 7 appears.
What would you suggest?