Total Variation of Function

Manipulate[SeedRandom[ranint];
With[{y1=Random[Integer,{1,d-1}],
kv=Random[Integer,{4,7}],
c=Random[Integer,{1,d-1}]},
With[{k1=(kv-2) d+d-y1+c,
y2=If[OddQ[kv],c,d-c]},With[{
k=k1/d},With[{
a1=1/k(d-y1)},
With[{prava=k1,choices=Table[k1+i,{i,-1,Random[Integer,{3,4}]}]},
Row[{Text@Column[{"What is the",Column[{"total variation","of function?"}], Spacer[15],PopupMenu[Dynamic[an],choices],"  ",If[an===prava,True,If[an==0,"",False]]}],
"     ",
Graphics[{Line[{{0,0},{d,0},{d,d},{0,d},{0,0}}],Line[{{0,y1},{a1,d}}],RGBColor[1, 0.501961, 0],Thickness[0.006],If[OddQ[kv],Line[Join[{{0,y1}},Flatten[Table[{{a1+(i-1) 2 d/k,d},{a1+d/k+(i-1) 2 d/k,0}},{i,1,kv/2,1}],1],{{d,y2}}]],Line[Join[{{0,y1}},Flatten[Table[{{a1+(i-1) 2 d/k,d},{a1+d/k+(i-1) 2 d/k,0}},{i,1,kv/2-1,1}],1],{{a1+(kv/2-1) 2 d/k,d}},{{d,y2}}]]]},
Axes->True,ImageSize->{390,400},GridLines->{Range[1,d-1],Range[1,d-1]},Ticks->{Range[d],Range[d]}]}]]]]]],
{{d,5,"length of interval"},Range[3,7]},
{{ranint,RandomInteger[{1,1999}]},ControlType->None},
{an,0,ControlType->None},
Button["new question",an=0;ranint=RandomInteger[{1,1990}]],
ContentSize->{540,460}]

BAD:   A function f  is given by a set of n+1 ordered pairs ((Subscript[x, i]),(Subscript[y, i])). Total variation of the function  f is (Subscript[V, f])(a,b)=(∑_(i=1)^n)|f((Subscript[x, i+1]))-f((Subscript[x, i]))|=(∑_(i=1)^n)|(Subscript[y, i+1])-(Subscript[y, i])|.  It is a measure of the oscillation of the function f.

REFORMATTED:  A function f is given by a set of n+1 ordered pairs ((Subscript[x, i]),(Subscript[y, i])). Total variation of the function f is (Subscript[V, f])(a,b)=(∑_(i=1)^n)|f((Subscript[x, i+1]))-f((Subscript[x, i]))|=(∑_(i=1)^n)|(Subscript[y, i+1])-(Subscript[y, i])|. It is a measure of the oscillation of the function f.

More generaly, total variation of a function f  is given by the definition (Subscript[V, f])(a,b)=sup[ Σ|f((Subscript[x, i+1]))-f((Subscript[x, i])) ], where the supremum is taken over all partitions of the interval [a,b]. If  (Subscript[V, f])(a,b) is finite, then f is of bounded variation on the interval.

E. J. Borowski, J. M. Borwein, Collins Dictionary of Mathematics, HarperCollins Publishers, 1989, p. 594.

Contributed by: Izidor Hafner