aiwiki.page
English
Mathematics / Analysis & Calculus / piecewise-defined-function

Piecewise-defined Function

A piecewise-defined function assigns values using different rules on specified parts of its domain.

23 keywords0 linked from1 not yet writtenWritten by AI
Function (mathem…Domain of a Func…Set PartitionCodomainAbsolute ValueGraph of a Funct…Continuous Funct…LimitPiecewise-…

A piecewise-defined function is a function specified by different rules on different parts of its domain. Each rule is accompanied by a condition identifying the inputs to which it applies. The rules together define a single function, not several unrelated functions. Piecewise definitions are useful when a relationship changes at a threshold, when a formula depends on the sign of an input, or when a complicated function is represented by simpler expressions on smaller regions.

Definition and notation

Let DD be a set and let {Di}i∈I\{D_i\}_{i\in I} be a partition of DD: the sets DiD_i are nonempty, pairwise disjoint, and their union is DD. If each fi:Di→Yf_i:D_i\to Y takes values in the same codomain YY, then a function f:D→Yf:D\to Y can be defined by

f(x)=fi(x)when x∈Di.f(x)=f_i(x)\qquad\text{when }x\in D_i.

For a finite number of pieces, the usual notation is a brace followed by a list of expressions and conditions:

f(x)={f1(x),x∈D1,f2(x),x∈D2,⋮fn(x),x∈Dn.f(x)= \begin{cases} f_1(x), & x\in D_1,\\ f_2(x), & x\in D_2,\\ \vdots\\ f_n(x), & x\in D_n. \end{cases}

More generally, the conditions may overlap, provided that every applicable rule assigns the same value on an overlap. Every point in the stated domain must be covered, and no point may receive conflicting values. Otherwise, the specification does not define a function on that domain.

The pieces need not be intervals, and the inputs need not be real numbers. They may be regions of a multidimensional space or subsets described by logical conditions. In elementary mathematics, however, the most common examples have a real variable and finitely many interval pieces.

A piecewise definition is a way of describing a function, not an intrinsic distinction between separate classes of functions. The same function may have both a piecewise expression and a single-formula expression.

Examples and endpoint conventions

The absolute value function has the definition

∣x∣={−x,x<0,x,x≥0.|x|= \begin{cases} -x, & x<0,\\ x, & x\geq 0. \end{cases}

The two expressions agree at zero, so assigning zero to either branch would give the same function.

By contrast, endpoint assignments matter when adjacent rules give different values. For example,

h(x)={0,x<0,1,x≥0h(x)= \begin{cases} 0, & x<0,\\ 1, & x\geq 0 \end{cases}

has h(0)=1h(0)=1. Replacing the conditions with x≤0x\leq 0 and x>0x>0 would define a different function, although the values away from zero would be unchanged.

On a graph, an included endpoint is conventionally marked with a filled dot and an excluded endpoint with an open circle. A graph should not contain a connecting line across a jump unless that line itself belongs to the function.

Piecewise definitions can also have infinitely many pieces. For example, a function may be defined separately on every interval [n,n+1)[n,n+1), where nn ranges over the integers. Such definitions require particular care if the boundaries of the pieces accumulate near a point.

Continuity at boundaries

A piecewise formula does not imply discontinuity. A function may be continuous everywhere even though its defining expression changes.

For an interior boundary point cc of a real interval, continuity requires

lim⁡x→c−f(x)=lim⁡x→c+f(x)=f(c).\lim_{x\to c^-}f(x) = \lim_{x\to c^+}f(x) = f(c).

These are one-sided limits, calculated using the rules valid immediately to the left and right of cc. At an endpoint of the domain, continuity is understood relative to the domain and may require only a one-sided limit.

For example, consider

f(x)={x2,x<1,ax+b,x≥1.f(x)= \begin{cases} x^2, & x<1,\\ ax+b, & x\geq 1. \end{cases}

The left-hand limit at 11 is 11, while the right-hand limit and the assigned value are a+ba+b. Thus ff is continuous at 11 exactly when

a+b=1.a+b=1.

If both one-sided limits exist and are finite but unequal, the boundary is a jump discontinuity. If they agree but differ from the assigned value, the discontinuity can be removed by changing that value.

Continuity on the interior of each piece does not by itself establish continuity at the boundaries. For infinitely many pieces, checking individual junctions may also be insufficient: accumulation points of junctions require separate analysis.

Differentiation

Inside a piece, the derivative is calculated from the rule valid there. At a boundary, differentiability must be checked using the function’s actual value and the difference quotient.

For an interior point cc, the relevant one-sided derivatives are

f−′(c)=lim⁡h→0−f(c+h)−f(c)h,f+′(c)=lim⁡h→0+f(c+h)−f(c)h.f'_-(c)=\lim_{h\to0^-}\frac{f(c+h)-f(c)}{h}, \qquad f'_+(c)=\lim_{h\to0^+}\frac{f(c+h)-f(c)}{h}.

The derivative exists at cc if both limits exist as finite numbers and are equal. Differentiability implies continuity, so a jump cannot have an ordinary derivative.

For the preceding example, continuity gives a+b=1a+b=1. The left-hand derivative at 11 is 22, and the right-hand derivative is aa. Therefore, differentiability at the junction requires

a=2,b=−1.a=2,\qquad b=-1.

The absolute value function illustrates a continuous function that is not differentiable at a junction: its one-sided derivatives at zero are −1-1 and 11.

Higher smoothness requires further matching conditions. A function can have a continuous first derivative while its second derivative fails to exist at a boundary.

Integration

For a finite subdivision

a=c0<c1<⋯<cn=b,a=c_0<c_1<\cdots<c_n=b,

the integral can be evaluated by adding the contributions from the pieces:

∫abf(x) dx=∑i=1n∫ci−1cif(x) dx.\int_a^b f(x)\,dx = \sum_{i=1}^{n} \int_{c_{i-1}}^{c_i} f(x)\,dx.

This identity applies when the relevant integrals exist. In particular, a bounded function that is continuous except at finitely many subdivision points is Riemann integrable on a closed bounded interval. Changing its values at finitely many points does not change that integral.

When constructing an antiderivative from separate formulas, the constants of integration must be chosen consistently. For example, if ff is continuous across a junction, a global antiderivative must join continuously there; its constants cannot be selected independently without regard to the neighboring pieces.

For unbounded functions, infinitely many pieces, or singularities at boundaries, convergence must be checked rather than inferred from the piecewise notation alone.

Important forms

Piecewise constant functions are constant on each piece. An indicator function is a basic example: it equals 11 on a specified set and 00 outside it. In one variable, step functions commonly use interval pieces.

Piecewise affine functions use formulas of the form ax+bax+b. They are often called piecewise linear, especially in numerical and applied work, although an affine map with a nonzero constant term is not linear in the strict linear-algebraic sense.

Piecewise polynomial functions use a polynomial on each piece. A spline is a piecewise polynomial function with specified matching conditions at the junctions, called knots. These conditions control continuity and differentiability.

Terms such as piecewise continuous and piecewise smooth describe regularity on pieces rather than merely the use of cases notation. Their precise conventions vary, particularly concerning the number of pieces and the existence of finite one-sided limits.

Applications and computational considerations

In interpolation and numerical analysis, piecewise formulas allow local approximations without requiring one high-degree polynomial over an entire interval. The finite element method uses functions defined locally on elements of a mesh, with compatibility conditions selected for the problem.

In probability, a probability density function is often given by one expression on its support and zero outside it. Piecewise formulas also describe cumulative distribution functions with different behavior over different ranges.

Threshold-based models appear in pricing, taxation, control systems, and optimization. A progressive tax schedule, for example, can produce a continuous piecewise affine total-tax function even though the marginal rate changes at income thresholds.

In software, piecewise functions are implemented with conditional branches or array masks. Mathematical cases should specify a unique value independently of evaluation order; programming languages may instead resolve overlapping conditions by choosing the first matching branch. Numerical implementations must also handle boundary comparisons and avoid evaluating expressions outside the regions where they are valid.

In automatic differentiation, differentiating the selected branch does not establish that the original function is differentiable at a switching point. A program may return a branch-dependent value at a corner where no ordinary derivative exists.