Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Piecewise linear function
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Type of mathematical function}} {{Refimprove|date=March 2013}} {{for|other uses of "piecewise linear"|Piecewise linear (disambiguation)}} In [[mathematics]], a '''piecewise linear''' or '''segmented function''' is a [[real-valued function]] of a real variable, whose [[graph of a function|graph]] is composed of straight-[[line segment]]s.<ref>{{cite book | title = Technical Analysis And Applications With Matlab | page = 143 | first = William D. | last = Stanley | year = 2004 | publisher = Cengage Learning | isbn = 978-1401864811}}</ref> ==Definition== A piecewise linear function is a function defined on a (possibly unbounded) [[Interval (mathematics)|interval]] of [[real number]]s, such that there is a collection of intervals on each of which the function is an [[affine transformation|affine function]]. (Thus "piecewise linear" is actually defined to mean "piecewise [[affine function|affine]]".) If the domain of the function is [[compact space|compact]], there needs to be a finite collection of such intervals; if the domain is not compact, it may either be required to be finite or to be [[Locally finite collection|locally finite]] in the reals. ==Examples== [[Image:Piecewise linear function.svg|right|thumb|A continuous piecewise linear function]] The function defined by : <math>f(x) = \begin{cases} -x - 3 & \text{if }x \leq -3 \\ x + 3 & \text{if }-3 < x < 0 \\ -2x + 3 & \text{if }0 \leq x < 3 \\ 0.5x - 4.5 & \text{if }x \geq 3 \end{cases}</math> is piecewise linear with four pieces. The graph of this function is shown to the right. Since the graph of an affine(*) function is a [[line (geometry)|line]], the graph of a piecewise linear function consists of [[line segment]]s and [[ray (mathematics)|rays]]. The ''x'' values (in the above example β3, 0, and 3) where the slope changes are typically called breakpoints, changepoints, threshold values or knots. As in many applications, this function is also continuous. The graph of a continuous piecewise linear function on a compact interval is a [[polygonal chain]]. (*) A [[linear map|linear function]] satisfies by definition <math> f(\lambda x) = \lambda f(x) </math> and therefore in particular <math> f(0) = 0 </math>; functions whose graph is a straight line are ''[[affine function|affine]]'' rather than ''linear''. There are other examples of piecewise linear functions: * [[Absolute value]]<ref name=":0">{{Cite web|last=Weisstein|first=Eric W.|title=Piecewise Function|url=https://mathworld.wolfram.com/PiecewiseFunction.html|access-date=2020-08-24|website=mathworld.wolfram.com|language=en}}</ref> * [[sawtooth wave|Sawtooth function]] * [[Floor function]] * [[Step function]], a function composed of constant sub-functions, so also called a piecewise constant function ** [[Boxcar function]], ** [[Heaviside step function]]<ref name=":0" /> ** [[Sign function]] * [[Triangular function]] ==Fitting to a curve== [[Image:Finite element method 1D illustration1.svg|right|thumb|A function (blue) and a piecewise linear approximation to it (red)]] An approximation to a known curve can be found by sampling the curve and interpolating linearly between the points. An algorithm for computing the most significant points subject to a given error tolerance has been published.<ref>{{Cite journal | last1 = Hamann | first1 = B. | last2 = Chen | first2 = J. L. | doi = 10.1016/0167-8396(94)90004-3 | title = Data point selection for piecewise linear curve approximation | journal = Computer Aided Geometric Design | volume = 11 | issue = 3 | pages = 289 | year = 1994 | url = https://escholarship.org/content/qt6p65k0mr/qt6p65k0mr.pdf?t=ptt2jz }}</ref> ==Fitting to data== {{Main|Segmented regression}} If partitions, and then breakpoints, are already known, [[linear regression]] can be performed independently on these partitions. However, continuity is not preserved in that case, and also there is no unique reference model underlying the observed data. A stable algorithm with this case has been derived.<ref name="Golovchenko">{{cite web|last=Golovchenko|first=Nikolai|title=Least-squares Fit of a Continuous Piecewise Linear Function|url=https://drive.google.com/file/d/1M5b5EoGbARlcsRVnG-7D64cpL8Vh76Av/view?usp=sharing|access-date=6 Dec 2012}}</ref> If partitions are not known, the [[residual sum of squares]] can be used to choose optimal separation points.<ref>{{Cite journal | last1 = Vieth | first1 = E. | title = Fitting piecewise linear regression functions to biological responses | journal = Journal of Applied Physiology | volume = 67 | issue = 1 | pages = 390β396 | year = 1989 | pmid = 2759968 | doi = 10.1152/jappl.1989.67.1.390 }}</ref> However efficient computation and joint estimation of all model parameters (including the breakpoints) may be obtained by an iterative procedure<ref>{{Cite journal |last=Muggeo |first=V. M. R. |date=2003 |title=Estimating regression models with unknown break-points |journal=Statistics in Medicine |volume=22 |issue=19 |pages=3055β3071 |doi=10.1002/sim.1545 |pmid=12973787|s2cid=36264047 }}</ref> currently implemented in the package <code>segmented</code><ref>{{Cite FTP |last=Muggeo |first=V. M. R. |date=2008 |title=Segmented: an R package to fit regression models with broken-line relationships |url=ftp://200.236.31.12/CRAN/doc/Rnews/Rnews_2008-1.pdf#page=20 |volume=8 |server=R News |url-status=dead |pages=20β25}}</ref> for the [[R (programming language)|R language]]. A variant of [[decision tree learning]] called [[model tree]]s learns piecewise linear functions.<ref>{{Cite journal | last1 = Landwehr | first1 = N. | last2 = Hall | first2 = M. | last3 = Frank | first3 = E. | title = Logistic Model Trees | doi = 10.1007/s10994-005-0466-3 | journal = Machine Learning | volume = 59 | issue = 1β2| pages = 161β205 | year = 2005 | s2cid = 6306536 | url = http://www.cs.waikato.ac.nz/~eibe/pubs/LMT.pdf| doi-access = free }}</ref> ==Generalizations== [[Image:Piecewise linear function2D.svg|right|thumbnail|A piecewise linear function of two arguments (top) and the convex polytopes on which it is linear (bottom)]] The notion of a piecewise linear function makes sense in several different contexts. Piecewise linear functions may be defined on [[dimension|''n''-dimensional]] [[Euclidean space]], or more generally any [[vector space]] or [[affine space]], as well as on [[piecewise linear manifold]]s and [[simplicial complex]]es (see [[simplicial map]]). In each case, the function may be [[real number|real]]-valued, or it may take values from a vector space, an affine space, a piecewise linear manifold, or a simplicial complex. (In these contexts, the term βlinearβ does not refer solely to [[linear map|linear transformations]], but to more general [[affine transformation|affine linear]] functions.) In dimensions higher than one, it is common to require the domain of each piece to be a [[polygon]] or [[polytope]]. This guarantees that the graph of the function will be composed of polygonal or polytopal pieces. [[Spline (mathematics)|Splines]] generalize piecewise linear functions to higher-order polynomials, which are in turn contained in the category of piecewise-differentiable functions, [[PDIFF]]. ==Specializations== Important sub-classes of piecewise linear functions include the [[continuous function|continuous]] piecewise linear functions and the [[Convex function|convex]] piecewise linear functions. In general, for every ''n''-dimensional continuous piecewise linear function <math>f : \mathbb{R}^n \to \mathbb{R}</math>, there is a : <math>\Pi \in \mathcal{P}(\mathcal{P}(\mathbb{R}^{n+1}))</math> such that : <math>f(\vec{x}) = \min_{\Sigma \in \Pi} \max_{(\vec{a}, b) \in \Sigma} \vec{a} \cdot \vec{x} + b.</math><ref>{{cite journal | last = Ovchinnikov | first = Sergei | arxiv = math/0009026 | issue = 1 | journal = BeitrΓ€ge zur Algebra und Geometrie | mr = 1913786 | pages = 297β302 | title = Max-min representation of piecewise linear functions | volume = 43 | year = 2002}}</ref> If <math>f</math> is convex and continuous, then there is a : <math>\Sigma \in \mathcal{P}(\mathbb{R}^{n+1})</math> such that : <math>f(\vec{x}) = \max_{(\vec{a},b) \in \Sigma} \vec{a} \cdot \vec{x} + b.</math> == Applications == [[File: R-3VAR1.JPG|thumb|left|Crop response to depth of the watertable<ref>[https://www.waterlog.info/segreg.htm A calculator for piecewise regression].</ref>]] [[File:Mustard segm regr no effect.png|thumb|right|Example of crop response to soil salinity<ref>[https://www.waterlog.info/partreg.htm A calculator for partial regression].</ref>]] In [[agriculture]] piecewise [[regression analysis]] of measured data is used to detect the range over which growth factors affect the yield and the range over which the crop is not sensitive to changes in these factors. The image on the left shows that at shallow [[watertable]]s the yield declines, whereas at deeper (> 7 dm) watertables the yield is unaffected. The graph is made using the method of [[least squares]] to find the two segments with the [[best fit]]. The graph on the right reveals that crop yields [[salt tolerance of crops|tolerate]] a [[soil salinity]] up to ECe = 8 dS/m (ECe is the electric conductivity of an extract of a saturated soil sample), while beyond that value the crop production reduces. The graph is made with the method of partial regression to find the longest range of "no effect", i.e. where the line is horizontal. The two segments need not join at the same point. Only for the second segment method of least squares is used. {{clear}} == See also == * [[Linear interpolation]] * [[Spline interpolation]] * [[Tropical geometry]] * [[Polygonal chain]] == Further reading == * Apps, P., Long, N., & Rees, R. (2014). [http://onlinelibrary.wiley.com/doi/10.1111/jpet.12070/full Optimal piecewise linear income taxation]. ''Journal of Public Economic Theory'', '''16'''(4), 523β545. ==References== {{reflist}} {{DEFAULTSORT:Piecewise Linear Function}} [[Category:Real analysis]] [[Category:Types of functions]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Cite FTP
(
edit
)
Template:Cite book
(
edit
)
Template:Cite journal
(
edit
)
Template:Cite web
(
edit
)
Template:Clear
(
edit
)
Template:For
(
edit
)
Template:Main
(
edit
)
Template:Refimprove
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)