A piecewise function, also known as a piecewise-defined function or hybridfunction, is a mathematical function constructed from multiple sub-functions, each defined on a distinct, non-overlapping subset of the function's domain, typically intervals of the real numbers.[1][2] These subsets collectively cover the entire domain without overlap, allowing the overall function to exhibit different behaviors in different regions.[3]One of the most fundamental examples is the absolute value function, defined as |x| = -x if x < 0 and |x| = x if x \geq 0, which creates a V-shaped graph symmetric about the y-axis.[4][5] Another classic case is the Heaviside step function, which remains zero for negative inputs and jumps to one for non-negative inputs, modeling abrupt changes like on-off switches in physics and engineering.[6] Piecewise functions are notated using cases, such as f(x) = \begin{cases} g(x) & \text{if } x \in A \\ h(x) & \text{if } x \in B \end{cases}, where A and B partition the domain.[1]To graph a piecewise function, each sub-function is plotted separately over its corresponding interval, with attention to continuity at boundaries where pieces meet; the result may be continuous, like the absolute value, or discontinuous, like the step function.[7][2] Properties such as domain, range, and monotonicity are analyzed piece by piece, often revealing where the function is increasing, decreasing, or constant within each segment.[8] In practice, piecewise functions are essential for modeling real-world phenomena with regime-specific rules, such as tax brackets where rates change by income level, shipping costs varying by weight zones, or velocity profiles in fluid dynamics that differ across regions.[1] They also form the basis for more advanced concepts in calculus, like handling discontinuities, and in applied fields including computer graphics for rendering segmented curves.[9]
Basic Concepts
Definition
A piecewise function is a function defined by specifying distinct sub-functions over different subsets of its domain, where the domain is partitioned into non-overlapping intervals or sets that collectively cover the entire domain without gaps. This structure allows the function to exhibit different behaviors in separate regions, forming a composite function through case-based definitions.[1][2]Formally, let f: X \to Y be a function, where the domain X is partitioned into subsets \{X_i\}_{i \in I}, with I a finite or countable index set, such that \bigcup_{i \in I} X_i = X and X_i \cap X_j = \emptyset for all i \neq j. Then f(x) = f_i(x) for each x \in X_i, where each f_i: X_i \to Y is a sub-function defined on its respective subset. This partition ensures a complete and exclusive division of the domain, enabling the piecewise construction.[10][1]The subsets in the partition are typically intervals, which may be open (e.g., (a, b)), closed (e.g., [a, b]), or half-open (e.g., [a, b)), depending on the boundaries required for the sub-functions. Such intervals must be disjoint and their union must equal the full domain to avoid ambiguities or undefined points. This approach presupposes familiarity with standard functions but extends them via conditional definitions across the partitioned domain.[1]
Notation
Piecewise functions are typically denoted using a functional equation where the right-hand side employs a large left-curved brace encompassing multiple lines, each specifying an expression valid under a particular condition. This format is expressed asf_1(x) & \text{if } x \in D_1, \\
f_2(x) & \text{if } x \in D_2, \\
\vdots & \vdots \\
f_n(x) & \text{if } x \in D_n,
\end{cases} $$
where the $D_i$ represent subsets of the domain that partition it completely.[](https://mathworld.wolfram.com/PiecewiseFunction.html) In typesetting systems like LaTeX, this structure is rendered using the `cases` environment provided by the `amsmath` package, which aligns the expressions and conditions in a two-column array for clarity and proper spacing.[](https://www.latex-project.org/help/documentation/amsldoc.pdf)
The conditions $D_i$ in this notation are understood to be mutually exclusive and collectively exhaustive, covering the entire domain without overlap, ensuring a unique value for $f(x)$ at every point. The sequence of cases does not imply any evaluation order or priority; it merely lists the defining pieces systematically.[](https://mathworld.wolfram.com/PiecewiseFunction.html)
An alternative compact notation employs the Iverson bracket $[P]$, which evaluates to 1 if proposition $P$ is true and 0 otherwise, allowing a piecewise function to be written as a sum: $f(x) = \sum_{i=1}^n f_i(x) [x \in D_i]$. This form is particularly useful in fields like [combinatorics](/page/Combinatorics) and [discrete mathematics](/page/Discrete_mathematics) where indicator functions facilitate summations over conditions.[](https://mathworld.wolfram.com/IversonBracket.html)
In programming contexts, piecewise definitions mirror conditional logic through if-then-else constructs, such as in pseudocode or languages like [Python](/page/Python) and Mathematica, where functions branch based on input ranges (e.g., `if x in D1 then return f1(x) else if x in D2 then return f2(x) ...`). This parallels mathematical notation but emphasizes computational evaluation order.[](https://reference.wolfram.com/language/ref/Piecewise.html)
Boundary points between domains are handled explicitly in the conditions using inequalities like $<$, $\leq$, $>$, or $\geq$ to determine inclusion or exclusion, ensuring unambiguous definition at transitions (e.g., $x < a$ for open intervals or $x \leq a$ for closed ones).[](https://mathworld.wolfram.com/PiecewiseFunction.html)
The curly brace-based notation for piecewise functions evolved from conditional definitions in early 20th-century real analysis texts and became standardized in modern mathematical literature, as seen in seminal works like Walter Rudin's *Principles of Mathematical Analysis*.
## Examples
### Elementary Examples
One of the simplest piecewise functions is the absolute value function, defined as
$$ |x| = \begin{cases}
x & \text{if } x \geq 0 \\
-x & \text{if } x < 0
\end{cases} $$
over the domain of all real numbers $\mathbb{R}$. This function produces non-negative outputs, with $|1| = 1$ and $|-1| = 1$. Its graph consists of two linear rays forming a V-shape, symmetric about the y-axis, with the vertex at the origin (0,0).
The signum function, often denoted $\operatorname{sgn}(x)$, is another elementary example, given by
$$ \operatorname{sgn}(x) = \begin{cases}
1 & \text{if } x > 0 \\
0 & \text{if } x = 0 \\
-1 & \text{if } x < 0
\end{cases}. $$
[](https://mathworld.wolfram.com/Sign.html) It captures the sign of $x$, yielding $\operatorname{sgn}(1) = 1$ and $\operatorname{sgn}(-1) = -1$, while explicitly handling the zero case to avoid discontinuity issues at the origin. The graph appears as horizontal lines at y=1 for x>0, y=-1 for x<0, and a single point at (0,0).[](https://mathworld.wolfram.com/Sign.html)
The Heaviside step function, denoted $H(x)$, serves as a basic unit step and is defined piecewise as
$$ H(x) = \begin{cases}
0 & \text{if } x < 0 \\
1 & \text{if } x \geq 0
\end{cases}. $$
[](https://tutorial.math.lamar.edu/classes/de/StepFunctions.aspx) Evaluations give $H(1) = 1$ and $H(-1) = 0$. Its graph is a horizontal line at y=0 for x<0, jumping to y=1 for x≥0, forming a right-angled step at the origin.[](https://tutorial.math.lamar.edu/classes/de/StepFunctions.aspx)
The floor function, denoted $\lfloor x \rfloor$, returns the greatest integer less than or equal to x and can be expressed as $\lfloor x \rfloor = \max\{ n \in \mathbb{Z} \mid n \leq x \}$, or piecewise over intervals as $\lfloor x \rfloor = n$ for each integer n where $n \leq x < n+1$.[](https://mathworld.wolfram.com/FloorFunction.html) For instance, $\lfloor 1 \rfloor = 1$ and $\lfloor -1 \rfloor = -1$. The graph features horizontal line segments at integer heights y=n over each half-open interval [n, n+1), connected by vertical jumps at integers, resembling a staircase descending to the left.[](https://mathworld.wolfram.com/FloorFunction.html)
These examples illustrate basic piecewise linear and constant constructions, where the function switches definitions at finite points to build simple yet informative behaviors across the real line.
### Applied Examples
Piecewise functions are widely used in applied contexts to model real-world systems that exhibit abrupt changes or distinct behaviors across different intervals, allowing for accurate representation of discontinuities without overcomplicating the overall framework. In economics, progressive income tax systems exemplify piecewise linear functions, where the tax liability is calculated by applying different marginal rates to portions of income falling within specific brackets. For instance, in the U.S. federal income tax structure, the tax function T(z) for taxable income z is defined piecewise as T(z) = 0 for 0 ≤ z < I_0, and for each subsequent bracket i, the rate r_i applies to the income segment between thresholds I_{i-1} and I_i, resulting in a continuous but non-differentiable function at the bracket boundaries.[](https://scholar.harvard.edu/files/stantcheva/files/optimal_income_taxation_1.pdf)[](https://www1.claremontmckenna.edu/pages/faculty/LGrant/ref_cards_full/Topic_referenceSheet_income_tax.pdf) This approach ensures that taxpayers pay proportionally more as income rises, with the piecewise nature reflecting policy-driven thresholds designed to promote equity.[](https://scholar.harvard.edu/files/stantcheva/files/optimal_income_taxation_1.pdf)
In transportation engineering, traffic light operations rely on piecewise constant functions to dictate signal colors over fixed time intervals within a cycle, optimizing flow and safety at intersections. A typical cycle might define the light state as green for t ∈ [0, 30) seconds, yellow for t ∈ [30, 35) seconds, and red for t ∈ [35, 60) seconds, repeating periodically, where the durations are set based on traffic volume and pedestrian needs to minimize delays.[](https://ops.fhwa.dot.gov/publications/fhwahop08024/chapter5.htm)[](https://www.nyc.gov/html/dot/html/infrastructure/signals.shtml) These intervals create a step-like function for the signal output, enabling deterministic control that switches abruptly at phase boundaries, as seen in time-series plots of signal timing that highlight the partitioned cycle structure.[](https://ops.fhwa.dot.gov/publications/fhwahop08024/chapter5.htm)
Electrical engineering applications often employ piecewise constant functions to describe voltage across switched DC circuits, where the output changes discretely upon switch activation. For example, in a simple relay-controlled power supply, the voltage V(t) can be modeled as V(t) = 5 V for 0 ≤ t < 1 s and V(t) = 0 V for t ≥ 1 s, capturing the on-off behavior of the switch in power conversion or timing circuits.[](https://web.engr.oregonstate.edu/~moon/ece323/hspice98/files/chapter_5.pdf) Such models are visualized in time-series oscilloscope traces, emphasizing the constant levels separated by instantaneous transitions at switching instants, which is crucial for analyzing transient responses in DC-DC converters.[](https://www2.eecs.berkeley.edu/Pubs/TechRpts/2009/EECS-2009-78.pdf)
## Analytic Properties
### Continuity
A piecewise-defined function $f$ is continuous on its entire domain if it is continuous on the interior of each subinterval in its partition and if, at each partition boundary $c$, the left-hand limit $\lim_{x \to c^-} f(x)$, the right-hand limit $\lim_{x \to c^+} f(x)$, and the function value $f(c)$ all exist and are equal.[](https://ximera.osu.edu/mooculus/calculus1/continuity/digInContinuityOfPiecewiseFunctions) This condition ensures that there are no breaks in the graph at the junctions between pieces, preserving the function's continuity across the domain.[](https://math.dartmouth.edu/opencalc2/cole/lecture18.pdf)
The requirement for matching left and right limits at boundaries means that the defining expressions for adjacent pieces must agree at those endpoints; failure to do so results in a discontinuity, such as a jump discontinuity where the one-sided limits exist but differ from each other or from $f(c)$.[](https://math.dartmouth.edu/opencalc2/cole/lecture18.pdf) For instance, if the left limit at $c$ equals 2 and the right limit equals 3, the function exhibits a jump of size 1 at that point.[](https://math.dartmouth.edu/opencalc2/cole/lecture18.pdf) Removable discontinuities can also occur in piecewise functions when the one-sided limits agree but differ from the prescribed value at the boundary; redefining $f(c)$ to match the common limit resolves the issue. An example is the function defined as $f(x) = x$ for $x \neq 0$ and $f(0) = 1$, which has a removable discontinuity at $x = 0$ since $\lim_{x \to 0} f(x) = 0 \neq 1 = f(0)$.[](https://tutorial.math.lamar.edu/classes/calci/continuity.aspx)
On a compact interval $[a, b]$, a piecewise function that is continuous on each piece and satisfies the limit-matching condition at finitely many boundaries is uniformly continuous on $[a, b]$, as it is continuous on the compact set and thus inherits uniform continuity from the Heine-Cantor theorem.[](https://www.math.stonybrook.edu/~bishop/classes/math320.F21/lecOct19.pdf) A piecewise continuous function on $[a, b]$—meaning it is continuous except at finitely many jump discontinuities—is bounded on the interval, since each continuous piece is bounded on its closed subinterval and there are only finitely many such pieces.[](https://people.tamu.edu/~mvorobet/Math151/F16/s6_3_sol.pdf) Such functions have exactly finitely many points of discontinuity, corresponding to the partition boundaries where the matching condition fails.[](https://people.tamu.edu/~mvorobet/Math151/F16/s6_3_sol.pdf)
### Differentiability
A piecewise function $f$ defined on an interval is differentiable at an interior point if each defining sub-function is differentiable on the open intervals of its domain, and at any junction point $c$, the left-hand [derivative](/page/Derivative) $f'_-(c) = \lim_{h \to 0^-} \frac{f(c+h) - f(c)}{h}$ and right-hand [derivative](/page/Derivative) $f'_+(c) = \lim_{h \to 0^+} \frac{f(c+h) - f(c)}{h}$ both exist and are equal.[](https://openstax.org/details/books/calculus-volume-1) This condition ensures the existence of the [derivative](/page/Derivative) $f'(c)$ at the boundary, assuming continuity at $c$ as a prerequisite. If the one-sided derivatives differ, the function exhibits a corner and is not differentiable there.
For instance, the absolute value function $f(x) = |x|$ is continuous everywhere but not differentiable at $x = 0$, where the left-hand derivative is $-1$ and the right-hand derivative is $+1$, resulting in a sharp corner.[](https://openstax.org/details/books/calculus-volume-1) Similarly, consider $f(x) = \begin{cases} x & x < 0 \\ x^2 & x \geq 0 \end{cases}$. This function is continuous at $x = 0$ since $\lim_{x \to 0^-} f(x) = 0 = f(0) = \lim_{x \to 0^+} f(x)$. The derivative is $f'(x) = 1$ for $x < 0$ and $f'(x) = 2x$ for $x > 0$. At $x = 0$, the left-hand derivative is $\lim_{h \to 0^-} \frac{f(0+h) - f(0)}{h} = \lim_{h \to 0^-} \frac{h}{h} = 1$, while the right-hand derivative is $\lim_{h \to 0^+} \frac{f(0+h) - f(0)}{h} = \lim_{h \to 0^+} \frac{h^2}{h} = 0$. Since $1 \neq 0$, $f$ is not differentiable at $x = 0$.[](https://openstax.org/details/books/calculus-volume-1)
For higher-order differentiability, a piecewise function is $C^k$ (k times continuously differentiable) on its domain if it is continuous, each sub-function is $C^k$ on its open interval, and at each junction $c$, the function and all derivatives up to order $k$ match from both sides, i.e., the one-sided derivatives $f^{(m)}_-(c) = f^{(m)}_+(c)$ for $m = 0, 1, \dots, k$.[](https://www.math.ucdavis.edu/~hunter/intro_analysis_pdf/ch8.pdf)
In the context of distributions, piecewise smooth functions possess weak derivatives even when classical derivatives fail at junctions. The weak derivative is defined via integration by parts against test functions $\phi \in C_c^\infty(\mathbb{R})$: $\int_{-\infty}^\infty f \phi' \, dx = -\int_{-\infty}^\infty g \phi \, dx$, where $g$ is the weak derivative. For $f(x) = |x|$, the weak derivative is the sign function $\operatorname{sgn}(x)$, which equals $2H(x) - 1$ (with $H$ the Heaviside step function), capturing the jump in slope at $x = 0$.[](https://math.mit.edu/~stevenj/18.303/delta-notes.pdf)[](https://www.math.ucdavis.edu/~hunter/pdes/ch3.pdf) This framework, introduced in Sobolev spaces, allows differentiation of functions like the Heaviside step in a generalized sense.[](https://www.math.ucdavis.edu/~hunter/pdes/ch3.pdf)
### Integrability
A piecewise continuous function on a closed [interval](/page/Interval) $[a, b]$, which is continuous except at finitely many points where it has finite one-sided limits, is [bounded](/page/Bounded_function) and Riemann integrable over $[a, b]$. This follows from the fact that such functions have only finitely many discontinuities, and a [bounded function](/page/Bounded_function) on $[a, b]$ is Riemann integrable if and only if its set of discontinuities has [Lebesgue measure](/page/Lebesgue_measure) zero, which holds for finite sets.[](https://www.math.ucdavis.edu/~hunter/m125b/ch1.pdf) The discontinuities do not affect integrability because they can be isolated in subintervals where the upper and lower sums converge appropriately, allowing the integral to be computed as the limit of Riemann sums despite the jumps.[](https://www.math.mcgill.ca/labute/courses/255w03/L7.pdf)
In the Lebesgue sense, a piecewise [measurable function](/page/Measurable_function) defined on a set of finite measure, where each piece is bounded and measurable, is Lebesgue integrable provided the [integral](/page/Integral) of its [absolute value](/page/Absolute_value) is finite. Since simple functions, which are finite linear combinations of indicator functions over measurable sets and thus piecewise [constant](/page/Constant), form the foundation of [Lebesgue integration](/page/Lebesgue_integration), any such piecewise function can be approximated by simple functions, ensuring integrability over finite-measure domains like bounded intervals.[](https://terrytao.wordpress.com/2010/09/19/245a-notes-2-the-lebesgue-integral/) The Lebesgue [integral](/page/Integral) extends naturally to these functions, handling discontinuities more robustly than the [Riemann integral](/page/Riemann_integral) by focusing on measure rather than partitions.
The [integral](/page/Integral) of a piecewise [function](/page/Function) $f$ over an [interval](/page/Interval) that is the [union](/page/Union) of subintervals $D_i$, where $f$ is continuous on each $D_i$ except possibly at endpoints, computes as $\int f = \sum_i \int_{D_i} f_i$, with each $\int_{D_i} f_i$ evaluated using standard antiderivatives or numerical methods applicable to continuous functions. This additivity holds because the points of discontinuity at the junctions have measure zero and contribute nothing to the [integral](/page/Integral).[](https://www.math.ucsd.edu/~ashenk/Math_20A_Sum_12/Lecture_11.pdf)
For improper integrals involving piecewise functions, singularities within a piece or at infinity require careful handling, such as splitting the domain and taking limits; for example, a function defined as $f(x) = 1/\sqrt{x}$ for $0 < x \leq 1$ and $f(x) = 0$ elsewhere on $(0, 2]$ has an integrable singularity at 0 since $\int_0^1 1/\sqrt{x} \, dx = 2 < \infty$.[](https://tutorial.math.lamar.edu/classes/calcii/improperintegrals.aspx) Convergence depends on the behavior near the singularity, with piecewise definitions allowing separate assessment of each problematic piece.
Piecewise smooth functions, which are continuously differentiable except at finitely many points, are of [bounded variation](/page/Bounded_variation) if the total sum of the absolute [jumps](/page/Jump) at those points is finite, as the variation then equals the sum of the integrals of $|f'|$ over [smooth](/page/Smooth) pieces plus the jump contributions. This property ensures the function can serve as an integrator in Riemann-Stieltjes integrals without issues from excessive oscillation.[](https://heil.math.gatech.edu/handouts/bv.pdf)
## Applications
### In Mathematics
In [real analysis](/page/Real_analysis), piecewise functions provide a framework for representing non-analytic functions that cannot be expressed by a single smooth formula across their [domain](/page/Domain). A notable extreme case is the [Dirichlet function](/page/Dirichlet_function), defined as $ f(x) = 1 $ if $ x $ is rational and $ f(x) = 0 $ if $ x $ is irrational, which can be conceptualized as an infinite piecewise construction and is discontinuous at every point in its [domain](/page/Domain). This function illustrates the limitations of [continuity](/page/Continuity) in piecewise definitions, as its [oscillation](/page/Oscillation) between values prevents limits from existing anywhere.[](https://www.math.ucdavis.edu/~hunter/m125a/intro_analysis.pdf)
In approximation theory, extensions of the Weierstrass approximation theorem demonstrate that continuous functions on compact intervals can be uniformly approximated by piecewise polynomials, offering greater flexibility than global polynomials for functions with localized behaviors. Specifically, continuous piecewise linear functions, or polygonal lines, serve as intermediate approximants that polynomials can closely mimic through techniques like [Fourier series](/page/Fourier_series) truncation or binomial expansions of [absolute value](/page/Absolute_value) functions. These extensions, developed by mathematicians such as Lerch, [Volterra](/page/Volterra), and Lebesgue in the late [19th century](/page/19th_century), underscore the density of piecewise polynomials in the space of continuous functions.[](https://www.math.pku.edu.cn/teachers/litj/notes/numer_anal/WeierstrassApprox_Pinkus.pdf)
Within algebra, piecewise linear functions play a key role in toric geometry, where they define support functions on the fan of a toric variety, enabling the classification of Cartier divisors and line bundles through continuous, integer-valued maps that are linear on each cone. In semigroup theory, particularly the Gomory-Johnson infinite group problem arising in integer programming relaxations, piecewise linear functions act as minimal valid functions that are subadditive and periodic, with rational breakpoints allowing finite-dimensional analyses of extremality via perturbation decompositions in inverse semigroups of partial bijections.[](https://www.mimuw.edu.pl/~jarekw/pragmatic2010/CoxLittleSchenckJan2010.pdf)[](https://arxiv.org/pdf/1811.06189)
For Fourier series, the convergence properties of piecewise smooth functions—those continuous with piecewise continuous derivatives—exhibit the [Gibbs phenomenon](/page/Gibbs_phenomenon) at jump discontinuities, where partial sums overshoot the function value by approximately 9% of the jump size, regardless of the number of terms. This oscillatory behavior, first noted by Wilbraham and Gibbs, highlights nonuniform [convergence](/page/Convergence) near discontinuities but allows [pointwise](/page/Pointwise) recovery of values elsewhere. In distribution theory, general distributions often involve decompositions where piecewise continuous functions form the regular parts, as seen in the distributional derivatives of Heaviside-like jumps or piecewise $ C^1 $ functions, facilitating the extension of classical [calculus](/page/Calculus) to generalized objects.[](https://epubs.siam.org/doi/pdf/10.1137/S0036144596301390)
### In Science and Engineering
In physics, piecewise functions are essential for modeling potential barriers in [quantum mechanics](/page/Quantum_mechanics), where the [potential energy](/page/Potential_energy) is often defined as piecewise constant across different regions of space. For instance, the finite square well potential, a foundational model, describes a particle confined between two regions with zero potential inside the well and a constant positive value outside, allowing for the calculation of bound states and [wave function](/page/Wave_function) tunneling. This piecewise structure enables analytical solutions to the time-independent [Schrödinger equation](/page/Schrödinger_equation) in each region, matched at boundaries to ensure [continuity](/page/Continuity) of the [wave function](/page/Wave_function) and its [derivative](/page/Derivative).[](https://ocw.mit.edu/courses/8-04-quantum-physics-i-spring-2016/a565b327f85c7721b18f1074dbd69ede_MIT8_04S16_LecNotes11.pdf)
In [engineering](/page/Engineering), piecewise functions underpin [signal processing](/page/Signal_processing) techniques such as [pulse-width modulation](/page/Pulse-width_modulation) (PWM), where signals are approximated as piecewise constant over fixed intervals to [control](/page/Control) power delivery in devices like inverters and motors. PWM generates a series of rectangular pulses with varying widths, effectively creating a piecewise constant [waveform](/page/Waveform) whose average value mimics a desired continuous signal, reducing [harmonic](/page/Harmonic) distortion in applications like motor drives. In [control theory](/page/Control_theory), hybrid systems employ piecewise models to represent switching between operational modes, such as in [automotive engine](/page/Automotive_engine) controls where dynamics shift discontinuously based on state thresholds, enabling stability analysis through piecewise Lyapunov functions.[](https://www.sciencedirect.com/topics/computer-science/pulse-width-modulation)[](https://link.springer.com/chapter/10.1007/978-3-540-78929-1_24)
Within [computer science](/page/Computer_science), piecewise functions facilitate algorithmic approximations in [machine learning](/page/Machine_learning), notably decision trees, which partition input spaces into regions where the output is constant, forming a piecewise [constant function](/page/Constant_function) that models complex decision boundaries. For numerical methods, the [finite element method](/page/Finite_element_method) relies on piecewise [polynomial](/page/Polynomial) basis functions over mesh elements to approximate solutions to partial differential equations, allowing flexible handling of irregular geometries in simulations of [structural mechanics](/page/Structural_mechanics) or fluid flow. These piecewise constructions ensure computational efficiency by localizing computations and enabling error estimates through polynomial degree variation.[](https://projecteuclid.org/journals/bulletin-of-the-american-mathematical-society/volume-79/issue-6/Piecewise-polynomials-and-the-finite-element-method/bams/1183535131.short)
In [economics](/page/Economics), piecewise linear utility functions model [risk aversion](/page/Risk_aversion) by defining different slopes for gains and losses, capturing phenomena like [loss aversion](/page/Loss_aversion) where [marginal utility](/page/Marginal_utility) decreases more sharply for losses than gains. Such functions, often used in [prospect theory](/page/Prospect_theory) extensions, allow for piecewise definitions that reflect constant relative [risk aversion](/page/Risk_aversion) within segments, aiding in [portfolio optimization](/page/Portfolio_optimization) and behavioral [finance](/page/Finance) analyses. For simulations of discontinuous [dynamics](/page/Dynamics), tools like MATLAB's piecewise function construct conditional expressions for modeling [hybrid](/page/Hybrid) systems, such as impact events in mechanical simulations, ensuring accurate [numerical integration](/page/Numerical_integration) across mode switches.[](https://research.tilburguniversity.edu/files/1387980/Risk_Aversion_Wuerth_Schumacher.pdf)[](https://www.mathworks.com/help/symbolic/sym.piecewise.html)