In mathematics, the **Weierstrass function** is an example of a real-valued function that is continuous everywhere but differentiable nowhere. It is an example of a fractal curve. It is named after its discoverer Karl Weierstrass.

The Weierstrass function has historically served the role of a pathological function, being the first published example (1872) specifically concocted to challenge the notion that every continuous function is differentiable except on a set of isolated points.^{[1]} Weierstrass's demonstration that continuity did not imply almost-everywhere differentiability upended mathematics, overturning several proofs that relied on geometric intuition and vague definitions of smoothness. These types of functions were denounced by contemporaries: Henri Poincaré famously described them as "monsters" and called Weierstrass' work "an outrage against common sense", while Charles Hermite wrote that they were a "lamentable scourge". The functions were difficult to visualize until the arrival of computers in the next century, and the results did not gain wide acceptance until practical applications such as models of Brownian motion necessitated infinitely jagged functions (nowadays known as fractal curves).^{[2]}

In Weierstrass's original paper, the function was defined as a Fourier series:

where , is a positive odd integer, and

The minimum value of for which there exists such that these constraints are satisfied is . This construction, along with the proof that the function is not differentiable over any interval, was first delivered by Weierstrass in a paper presented to the Königliche Akademie der Wissenschaften on 18 July 1872.^{[3]}^{[4]}^{[5]}

Despite never being differentiable, the function is continuous: Since the terms of the infinite series which defines it are bounded by ±*a ^{n}* and this has finite sum for 0 <

It might be expected that a continuous function must have a derivative, or that the set of points where it is not differentiable should be countably infinite or finite. According to Weierstrass in his paper, earlier mathematicians including Gauss had often assumed that this was true. This might be because it is difficult to draw or visualise a continuous function whose set of nondifferentiable points is something other than a countable set of points. Analogous results for better behaved classes of continuous functions do exist, for example the Lipschitz functions, whose set of non-differentiability points must be a Lebesgue null set (Rademacher's theorem). When we try to draw a general continuous function, we usually draw the graph of a function which is Lipschitz or otherwise well-behaved.

The Weierstrass function was one of the first fractals studied, although this term was not used until much later. The function has detail at every level, so zooming in on a piece of the curve does not show it getting progressively closer and closer to a straight line. Rather between any two points no matter how close, the function will not be monotone.

The computation of the Hausdorff dimension *D* of the graph of the classical Weierstrass function was an open problem until 2018, while it was generally believed that *D* = .^{[6]}^{[7]} That *D* is strictly less than 2 follows from the conditions on and from above. Only after more than 30 years was this proved rigorously.^{[8]}

The term Weierstrass function is often used in real analysis to refer to any function with similar properties and construction to Weierstrass's original example. For example, the cosine function can be replaced in the infinite series by a piecewise linear "zigzag" function. G. H. Hardy showed that the function of the above construction is nowhere differentiable with the assumptions 0 < *a* < 1, *ab* ≥ 1.^{[9]}

It is convenient to write the Weierstrass function equivalently as

for . Then *W*_{α}(*x*) is Hölder continuous of exponent α, which is to say that there is a constant *C* such that

for all *x* and *y*.^{[10]} Moreover, *W*_{1} is Hölder continuous of all orders α < 1 but not Lipschitz continuous.

It turns out that the Weierstrass function is far from being an isolated example: although it is "pathological", it is also "typical" of continuous functions:

- In a topological sense: the set of nowhere-differentiable real-valued functions on [0, 1] is comeager in the vector space
*C*([0, 1];**R**) of all continuous real-valued functions on [0, 1] with the topology of uniform convergence.^{[11]}^{[12]} - In a measure-theoretic sense: when the space
*C*([0, 1];**R**) is equipped with classical Wiener measure*γ*, the collection of functions that are differentiable at even a single point of [0, 1] has*γ*-measure zero. The same is true even if one takes finite-dimensional "slices" of*C*([0, 1];**R**), in the sense that the nowhere-differentiable functions form a prevalent subset of*C*([0, 1];**R**).