<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Piecewise_linear_function</id>
	<title>Piecewise linear function - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Piecewise_linear_function"/>
	<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Piecewise_linear_function&amp;action=history"/>
	<updated>2026-05-04T17:49:33Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>http://debianws.lexgopc.com/wiki143/index.php?title=Piecewise_linear_function&amp;diff=276868&amp;oldid=prev</id>
		<title>imported&gt;GreenC bot: Move 1 url. Wayback Medic 2.5 per WP:URLREQ#citeftp</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Piecewise_linear_function&amp;diff=276868&amp;oldid=prev"/>
		<updated>2025-05-27T10:47:51Z</updated>

		<summary type="html">&lt;p&gt;Move 1 url. &lt;a href=&quot;/wiki143/index.php?title=User:GreenC/WaybackMedic_2.5&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;User:GreenC/WaybackMedic 2.5 (page does not exist)&quot;&gt;Wayback Medic 2.5&lt;/a&gt; per &lt;a href=&quot;/wiki143/index.php?title=WP:URLREQ&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;WP:URLREQ (page does not exist)&quot;&gt;WP:URLREQ#citeftp&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Short description|Type of mathematical function}}&lt;br /&gt;
{{Refimprove|date=March 2013}}&lt;br /&gt;
&lt;br /&gt;
{{for|other uses of &amp;quot;piecewise linear&amp;quot;|Piecewise linear (disambiguation)}}&lt;br /&gt;
In [[mathematics]], a &amp;#039;&amp;#039;&amp;#039;piecewise linear&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;segmented function&amp;#039;&amp;#039;&amp;#039; is a [[real-valued function]] of a real variable, whose [[graph of a function|graph]] is composed of straight-[[line segment]]s.&amp;lt;ref&amp;gt;{{cite book | title = Technical Analysis And Applications With Matlab | page = 143 | first = William D. | last = Stanley | year = 2004 | publisher = Cengage Learning | isbn = 978-1401864811}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Definition==&lt;br /&gt;
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 &amp;quot;piecewise linear&amp;quot; is actually defined to mean &amp;quot;piecewise [[affine function|affine]]&amp;quot;.) 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.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
[[Image:Piecewise linear function.svg|right|thumb|A continuous piecewise linear function]]&lt;br /&gt;
The function defined by&lt;br /&gt;
: &amp;lt;math&amp;gt;f(x) =&lt;br /&gt;
\begin{cases}&lt;br /&gt;
 -x - 3     &amp;amp; \text{if }x \leq -3 \\&lt;br /&gt;
 x + 3      &amp;amp; \text{if }-3 &amp;lt; x &amp;lt; 0 \\&lt;br /&gt;
 -2x + 3    &amp;amp; \text{if }0 \leq x &amp;lt; 3 \\&lt;br /&gt;
 0.5x - 4.5 &amp;amp; \text{if }x \geq 3&lt;br /&gt;
\end{cases}&amp;lt;/math&amp;gt;&lt;br /&gt;
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 &amp;#039;&amp;#039;x&amp;#039;&amp;#039; 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]].&lt;br /&gt;
&lt;br /&gt;
(*) A [[linear map|linear function]] satisfies by definition &amp;lt;math&amp;gt; f(\lambda x) = \lambda f(x) &amp;lt;/math&amp;gt; and therefore in particular &amp;lt;math&amp;gt; f(0) = 0 &amp;lt;/math&amp;gt;; functions whose graph is a straight line are &amp;#039;&amp;#039;[[affine function|affine]]&amp;#039;&amp;#039; rather than &amp;#039;&amp;#039;linear&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
There are other examples of piecewise linear functions:&lt;br /&gt;
* [[Absolute value]]&amp;lt;ref name=&amp;quot;:0&amp;quot;&amp;gt;{{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}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
* [[sawtooth wave|Sawtooth function]]&lt;br /&gt;
* [[Floor function]]&lt;br /&gt;
* [[Step function]], a function composed of constant sub-functions, so also called a piecewise constant function&lt;br /&gt;
** [[Boxcar function]],&lt;br /&gt;
** [[Heaviside step function]]&amp;lt;ref name=&amp;quot;:0&amp;quot; /&amp;gt;&lt;br /&gt;
** [[Sign function]]&lt;br /&gt;
* [[Triangular function]]&lt;br /&gt;
&lt;br /&gt;
==Fitting to a curve==&lt;br /&gt;
&lt;br /&gt;
[[Image:Finite element method 1D illustration1.svg|right|thumb|A function (blue) and a piecewise linear approximation to it (red)]]&lt;br /&gt;
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.&amp;lt;ref&amp;gt;{{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 }}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Fitting to data==&lt;br /&gt;
{{Main|Segmented regression}}&lt;br /&gt;
If partitions, and then breakpoints, are already known, [[linear regression]] can be performed independently on these partitions. &lt;br /&gt;
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.&amp;lt;ref name=&amp;quot;Golovchenko&amp;quot;&amp;gt;{{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}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If partitions are not known, the [[residual sum of squares]] can be used to choose optimal separation points.&amp;lt;ref&amp;gt;{{Cite journal &lt;br /&gt;
| last1 = Vieth | first1 = E. &lt;br /&gt;
| title = Fitting piecewise linear regression functions to biological responses &lt;br /&gt;
| journal = Journal of Applied Physiology &lt;br /&gt;
| volume = 67 &lt;br /&gt;
| issue = 1 &lt;br /&gt;
| pages = 390–396 &lt;br /&gt;
| year = 1989 &lt;br /&gt;
| pmid = 2759968&lt;br /&gt;
| doi = 10.1152/jappl.1989.67.1.390 &lt;br /&gt;
}}&amp;lt;/ref&amp;gt; However efficient computation and joint estimation of all model parameters (including the breakpoints) may be obtained by an iterative procedure&amp;lt;ref&amp;gt;{{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 }}&amp;lt;/ref&amp;gt; currently implemented in the package &amp;lt;code&amp;gt;segmented&amp;lt;/code&amp;gt;&amp;lt;ref&amp;gt;{{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}}&amp;lt;/ref&amp;gt; for the [[R (programming language)|R language]]. &lt;br /&gt;
&lt;br /&gt;
A variant of [[decision tree learning]] called [[model tree]]s learns piecewise linear functions.&amp;lt;ref&amp;gt;{{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 }}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Generalizations==&lt;br /&gt;
[[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)]]&lt;br /&gt;
&lt;br /&gt;
The notion of a piecewise linear function makes sense in several different contexts. Piecewise linear functions may be defined on [[dimension|&amp;#039;&amp;#039;n&amp;#039;&amp;#039;-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.)&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
[[Spline (mathematics)|Splines]] generalize piecewise linear functions to higher-order polynomials, which are in turn contained in the category of piecewise-differentiable functions, [[PDIFF]].&lt;br /&gt;
&lt;br /&gt;
==Specializations==&lt;br /&gt;
&lt;br /&gt;
Important sub-classes of piecewise linear functions include the [[continuous function|continuous]] piecewise linear functions and the [[Convex function|convex]] piecewise linear functions.&lt;br /&gt;
In general, for every &amp;#039;&amp;#039;n&amp;#039;&amp;#039;-dimensional continuous piecewise linear function &amp;lt;math&amp;gt;f : \mathbb{R}^n \to \mathbb{R}&amp;lt;/math&amp;gt;, there is a &lt;br /&gt;
: &amp;lt;math&amp;gt;\Pi \in \mathcal{P}(\mathcal{P}(\mathbb{R}^{n+1}))&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
such that&lt;br /&gt;
: &amp;lt;math&amp;gt;f(\vec{x}) = \min_{\Sigma \in \Pi} \max_{(\vec{a}, b) \in \Sigma} \vec{a} \cdot \vec{x} + b.&amp;lt;/math&amp;gt;&amp;lt;ref&amp;gt;{{cite journal&lt;br /&gt;
 | last = Ovchinnikov | first = Sergei&lt;br /&gt;
 | arxiv = math/0009026&lt;br /&gt;
 | issue = 1&lt;br /&gt;
 | journal = Beiträge zur Algebra und Geometrie&lt;br /&gt;
 | mr = 1913786&lt;br /&gt;
 | pages = 297–302&lt;br /&gt;
 | title = Max-min representation of piecewise linear functions&lt;br /&gt;
 | volume = 43&lt;br /&gt;
 | year = 2002}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is convex and continuous, then there is a &lt;br /&gt;
: &amp;lt;math&amp;gt;\Sigma \in \mathcal{P}(\mathbb{R}^{n+1})&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
such that&lt;br /&gt;
: &amp;lt;math&amp;gt;f(\vec{x}) = \max_{(\vec{a},b) \in \Sigma} \vec{a} \cdot \vec{x} + b.&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Applications ==&lt;br /&gt;
&lt;br /&gt;
[[File: R-3VAR1.JPG|thumb|left|Crop response to depth of the watertable&amp;lt;ref&amp;gt;[https://www.waterlog.info/segreg.htm A calculator for piecewise regression].&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
[[File:Mustard segm regr no effect.png|thumb|right|Example of crop response to soil salinity&amp;lt;ref&amp;gt;[https://www.waterlog.info/partreg.htm A calculator for partial regression].&amp;lt;/ref&amp;gt;]]&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The image on the left shows that at shallow [[watertable]]s the yield declines, whereas at deeper (&amp;gt; 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]].&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;no effect&amp;quot;, 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.&lt;br /&gt;
{{clear}}&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Linear interpolation]]&lt;br /&gt;
* [[Spline interpolation]]&lt;br /&gt;
* [[Tropical geometry]]&lt;br /&gt;
* [[Polygonal chain]]&lt;br /&gt;
&lt;br /&gt;
== Further reading ==&lt;br /&gt;
* Apps, P., Long, N., &amp;amp; Rees, R. (2014). [http://onlinelibrary.wiley.com/doi/10.1111/jpet.12070/full Optimal piecewise linear income taxation]. &amp;#039;&amp;#039;Journal of Public Economic Theory&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;16&amp;#039;&amp;#039;&amp;#039;(4), 523–545.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&lt;br /&gt;
{{DEFAULTSORT:Piecewise Linear Function}}&lt;br /&gt;
[[Category:Real analysis]]&lt;br /&gt;
[[Category:Types of functions]]&lt;/div&gt;</summary>
		<author><name>imported&gt;GreenC bot</name></author>
	</entry>
</feed>