Useful examples of pathological functions What are some particularly well-known functions that exhibit pathological behavior at or near at least one value and are particularly useful as examples?
For instance, if $f'(a) = b$, then $f(a)$ exists, $f$ is continuous at $a$, $f$ is differentiable at $a$, but $f'$ need not be continuous at $a$.  A function for which this is true is $f(x) = x^2 \sin(1/x)$ at $x=0$.
 A: Also: Conway base 13 function.
This function has the following properties.
1. On every closed interval $[a, b]$, it takes every real value.
2. It is continuous nowhere.  
A: Here's an example of a strictly increasing function on ℝ which is continuous exactly at the irrationals.
Pick your favorite absolutely convergent series ∑an in which all the terms are positive (mine is ∑1/2n) and your favorite enumeration of the positive rationals: ℚ={q1,q2,...}. For a real number x, define f(x) to be the sum of all the an for which qn ≤ x.
A: Have also a look here:
https://mathoverflow.net/questions/22189/what-is-your-favorite-strange-function
A: The Dirac delta "function." It's not a "function," strictly speaking, but rather a very simple example of a distribution that isn't a function.
A: The bump function $\psi\colon \mathbb{R} \to \mathbb{R}$ given by $\psi(x) = e^{-1/(1-x^2)}$ for $|x|\leq 1$ and $\psi(x) = 0$ for $|x| > 1$ is not exactly pathological per se, but it's very useful for (at least) two things:


*

*It's an example of a function that is smooth (all derivatives exist) but not analytic (not equal to its Taylor series in a neighbourhood of every point) -- look at the points $x=\pm 1$.

*You can use it to build partitions of unity on manifolds, which is important when you want to build a global object (like a Riemannian metric) out of local data (defined in each chart).

A: $\displaystyle\frac{\sin(x)}{x}$ is useful; it has a singularity at $x=0$, but if you take the union of $\displaystyle y=\frac{\sin(x)}{x}$ with the point $(x=0,y=1)$ then you get $\text{sinc}(x/\pi)$. The $\text{sinc}$ function has a lot of applications in signal processing and diffraction.
A: I like $f(x,y) = \frac{xy}{x^{2}+y{2}}$ for $(x,y) \ne (0,0)$ and $f(x,y)=0$ for $(x,y)=(0,0)$.  Here $f$ has partial derivatives at (0,0) but it is not differentiable at $(0,0)$
A: The constant function $0$ is an extremely pathological function: it has all kinds of properties that almost none of the functions $\mathbb R\to\mathbb R$ have: it is everywhere continuous, differentiable, analytic, polynomial, constant (not all of those are independent of course...), you name it. By contrast many of the answers given here involve properties that almost all functions have, or that almost all functions with the mentioned pathologies (e.g., being everywhere continuous for the Weierstrass function) have.
In fact being a definable function is a pathology that all answers share, but this is admittedly hard to avoid in an answer.
A: The Cauchy distribution is another example.  This distribution pops up frequently in statistical reasoning.  
For example, the ratio of two independent standard normal random variables is a standard Cauchy variable.  We calculate ratios all the time, but often forget to consider that their distribution does not follow a simple normal distribution.
This is interesting for several reasons:


*

*The mean and variance for the Cauchy distribution are undefined (--> infinity).  If one is trying to estimate these parameters for the ratio of two normal variables, the results may blow up to rather large values that are hard to interpret.

*In such a situation, one would therefore prefer to use more robust estimators of the central tendency (such as the median) and scale (median absolute deviation).  When designing and testing robust estimators (en.wikipedia.org/wiki/Robust_statistics), one way to test them is to try them out on a Cauchy distribution, and make sure that they don't blow up like the usual formulas for mean and variance.
A: When I was first learning calculus, the fact that $sin(1/x)$ is continuous on the set $(0,\infty)$ gave me a headache. 
A: The function f(x) = x over the rationals and 2x over the irrationals is locally increasing in 0 but it is neither increasing nor decreasing.
A: The Cauchy functionals, which satisfy the very simple equation f(a+b) = f(a)+f(b) for all real a,b.  These are either a line through the origin (the "nice" ones) or really "ugly" functions that are discontinuous and unbounded in every interval.  The latter are possible because the Axiom of Choice implies (actually is equivalent to) that infinite dimensional vector spaces have bases; i.e. the reals over the rationals have a Hamel basis.  A great explanation of all this (including the nice/ugly terminology) is in Horst Herrlich's monograph The Axiom of Choice.
A: The Weierstrass function is continuous everywhere and differentiable nowhere.
The Dirichlet function (the indicator function for the rationals) is continuous nowhere.
A modification of the Dirichlet function is continuous at all irrational values and discontinuous at rational values.
The Devil's Staircase is uniformly continuous but not absolutely. It increases from 0 to 1, but the derivative is 0 almost everywhere.
A: $\left(\frac{1}{x}\right)^{\frac{1}{x}}$. Try graphing it if you dare (including over the negatives)
A: Three examples suffice to show why some modes of convergence don't imply other modes of convergence: pointwise convergence, Lp norm convergence, convergence in measure, etc.  See the counterexamples section here.
