Can piecewise linear function $[a,b]\to\mathbb R$ have infinitely many segments? The term piecewise linear function is quite frequently used. Sometimes I encounter this notion in a text where it is not defined. (Which is probably not surprising, since this terminology is commonly used.)
If we are talking about functions from some finite interval $[a,b]$ to $\mathbb R$, is it safe to assume that the usual meaning is that it is a function consisting only of finitely many linear segments?
For example, would this function be considered piecewise linear: $f\colon[0,1]\to\mathbb R$ such that $f\left(\frac1{2k-1}\right)=0$, $f\left(\frac1{2k}\right)=1$ and $f$ is linear on each interval $\left[\frac1{2k},\frac1{2k-1}\right]$ the function $f$ is continuous ($k=1,2,\dots$)?
EDIT: As pointed out in the comments, this was obviously an oversight on my side, since the above function is only defined on $(0,1]$. 
I will add that if we have a function $f$ such that for each point $x\in[a,b]$ there is an open interval containing $x$ such that $f$ is linear on this interval, using compactness of $[a,b]$ we can get finite subcovering and finally get $f$ which consist of finitely many linear segments.
EDIT 2: The above "compactness based argument" was incorrect as pointed out in freakish's answer. Sorry for an edit which was too hasty. (Added later - correction would look like this: Let us assume that $f$ is linear on some set of closed subintervals and additionally that any point is either intererior point of one of these intervals or there are two intervals such that for one of them this point is the left endpoint and for the other one it is the right endpoint (with the exception of the points $a$ and $b$ which are required to be endpoint only of one interval). Then using compactness of $[a,b]$ we can show that there are only finitely many segments.)
 A: 
I will add that if we have a function $f$ such that for each point $x\in[a,b]$ there is an open interval containing $x$ such that $f$ is linear on this interval, using compactness of $[a,b]$ we can get finite subcovering and finally get $f$ which consist of finitely many linear segments.

Well this statement is false (or at least misleading). First of all the requirement "each point $x\in[a,b]$ has an open neighbourhood such that $f$ is linear on the neighbourhood" implies that $f$ is linear (not only piecewise linear). That's because if it is not linear then you take the maximal subinterval $[a',b']$ on which it is and then the requirement fails for either $x=a'$ or $x=b'$.
The definition for $f$ to be piecewise linear (or at least how I would define it) is:

Definition. $f:[0,1]\to\mathbb{R}$ is piecewise linear if there is a collection of intervals $\{I\}$ such that for any $I$ the restriction $f_{|I}$ is linear and $[0,1]=\bigcup I$.

If you additionally assume that $f$ is continuous then in the above definition you can replace "intervals" with "closed intervals". Note that the above definition implies that any two such intervals intersect in at most one point (the common end).
Secondly consider any continuous function $g:[0,1]\to\mathbb{R}$ and pick any increasing sequence $(a_n)$ such that $a_0=0$, $a_n\to \frac{1}{2}$. Define $f:[0,1]\to\mathbb{R}$ by
$$f(a_n)=g(a_n)$$
$$f\mbox{ over }[a_n,a_{n+1}]\mbox{ is a linear interpolation from }f(a_n)\mbox{ to }f(a_{n+1})$$
$$f(x)=g\big(\frac{1}{2}\big)\mbox{ for }x>\frac{1}{2}$$
You can easily pick $g$ so that $f$ is piecewise linear on infinitely many intervals (e.g. $g(x)=\frac{1}{1+x}$). Note that is is constant on $[\frac{1}{2},1]$ and linear on intervals of the form $[a_n, a_{n+1}]$ which all in all sum to whole $[0,1]$.
So generally I don't think that the definition requires finite number of intervals however YMMV.
