Piecewise Linear Function

Author

Eric W. Weisstein
April 15, 2011

This notebook downloaded from http://mathworld.wolfram.com/notebooks/LinearAlgebra/PiecewiseLinearFunction.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/PiecewiseLinearFunction.html.

©2011 Wolfram Research, Inc. except for portions noted otherwise

Definition

A piecewise linear function is composed of some number of linear segements defined over an equal number of intervals. The intervals are usually of constant size.

Consider the function y=(x^3) over the interval [1,2]. If  y(x) is approximated by a piecewise linear function over an increasing number of segments, e.g.,1, 2, 4, and 8, the accuracy of the approximation is seen to improve as the number of segments increases.

points[a_,b_,n_,k_]:= Module[{x1,x2},
 x1=a+(((k-1) (b-a))/n); x2=a+((k(b-a))/n);
Return[ {{x1,(x1^3)},{x2,(x2^3)}}]];

a=1;b=2;
pl=Plot[(x^3), {x,.9,2.1},PlotStyle->{Thickness[0.006],RGBColor[0,0,0.8,0.8]},Axes->True];

all={};
Do[ls={};
For[ k=1,k≤n,k++,AppendTo[ls,points[a,b,n,k]]];
lnz=Graphics[{RGBColor[1,0,0],Thickness[0.006],Line[ls]}];
AppendTo[all,Show[pl,lnz]],{n,{1,2,4,8}}]

In the first case, with a single segment, if we compute the Lagrange interpolating polynomial,
	((x−(Subscript[x, 2]))/((Subscript[x, 1])−(Subscript[x, 2])))((Subscript[x, 1])^3)+((x−(Subscript[x, 1]))/((Subscript[x, 2])−(Subscript[x, 1])))((Subscript[x, 1])^3)(Subscript[|, (Subscript[x, 1])=1,(Subscript[x, 2])=2])=7x−6
the equation of the linear function results.

The trapeziodal rule for numeric integration is described in a similar manner.

Piecewise linear functions are also key to some constructive derivations.  The length of a “piece” is given by the Distance formula, and factoring out ((Δx)^2) gives 
	(Sqrt[Δ(x^2)+Δ(y^2)])=(Sqrt[1+(((((Δy)/(Δx))))^2)])Δx .
Summing the length of a number of pieces is
	(∑_i)((Sqrt[1+(((((Subscript[Δy, i])/(Subscript[Δx, i]))))^2)])(Subscript[Δx, i])) 
Taking the limit as (Subscript[Δx, i])→0, the sum becomes 
	(∫_i)(Sqrt[1+(((((dy)/(dx))))^2)])dx , or (∫_a^b)(Sqrt[1+(((((dy)/(dx))))^2)])dx
which is the arc length from a to b in Catesian Coordinates.