 in mathematics, a piecewise linear function is a function composed of straight-line sections. it is a piecewise-defined function whose pieces are affine functions. if the function is continuous, the graph will be a polygonal curve. ==examples== right|thumb|a continuous piecewise linear function the function defined by: :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} is piecewise linear with four pieces. (the graph of this function is shown to the right.) since the graph of a linear function is a line, the graph of a piecewise linear function consists of line segments and rays. other examples of piecewise linear functions include the absolute value function, the square wave, the sawtooth function, and the floor function. ==fitting to a curve== 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. ==fitting to data== if partitions are already known, linear regression can be performed independently on these partitions. however, continuity is not preserved in that case. a stable algorithm with this case has been derived. if partitions are not known, the residual sum of squares can be used to choose optimal separation points. a variant of decision tree learning called model trees learns piecewise linear functions. ==notation== right|thumbnail|a piecewise linear function in two dimensions (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 n-dimensional euclidean space, or more generally any vector space or affine space, as well as on piecewise linear manifolds, simplicial complexes, and so forth. in each case, the function may be real-valued, or it may take values from a vector space, an aff
Real_analysis Types_of_functions