How to plot "chainsaw" functions in Maple? I want to plot piecewise function. For example, 
\begin{cases}
0,  &\ 0\le t<t_1 \\
12e^{-(t-t_1)}, & \ t_1\le t<t_2
\end{cases}
The problem is that function is periodic (let $t_1$=4 and $t_2$=6, period $6$). For one period, it's pretty easy:
f := 12*exp(-t+4);
g := 0;
piece := piecewise(0 <= t and t < 4, g, 4 < t and t <= 6, f);
plot(piece, t = 0 .. 6);


But I don't know how to make it periodic. Of course, I can add some new functions in piecewise, but I'm sure that more adequate way to plot periodic fuctions exists. Any help appreciated!
 A: You may try:
 f:=t->12*exp(-t+4)*Heaviside((t-4)*(6-t)):
 s:=t->t-floor(t):
 plot(f(6*s(t/6)),t=0..25);

It is easy to modify it with other values of $t_1$ and $t_2$.

A: You should not have to manually copy any part of the original expression into a new operator (manually, eg, cut & paste), to accomplish this. The unapply command is useful for that kind of thing.
You started out by giving us this:
restart;
f := 12*exp(-t+4):
g := 0:
piece := piecewise(0 <= t and t < 4, g, 4 < t and t <= 6, f):

plot(piece, t = 0 .. 6, size=[200,200]);


Now let's construct an operator from that, which behaves like the supplied piecewise, with a period of our choice.
We'll use a re-usable constructor for this purpose.
makeperiodic := proc(expr, var, skip)
  local T, r;
  r := skip/2;
  unapply( 'eval'(expr, var=r+'frem'(T+r,skip)), [T], numeric);
end proc:

Here is the construction of the periodic operator, and quick check.
foo := makeperiodic( piece, t, 6 ):

foo(5);
                      4.414553294

foo(11);
                      4.414553294

This operator returns unevaluated when its argument is not numeric, by design.
foo(x);
                         foo(x)

Now for some plots,
# operator form
plot(foo, -12 .. 12, size=[600,200]);


# expression form (unevaluated function call)
plot(foo(x), x=-12 .. 12, size=[600,200]);


# shift two to the left
plot(foo(x+2), x=-12 .. 12, size=[600,200]);


And we could do a similar thing for some other choice of period,
bar := makeperiodic( piece, t, 5 ):
plot(bar, -10 .. 10, size=[500,200]);
plot(bar(t), t=-10 .. 10, size=[500,200]);
# shift 4 to the right
plot(bar(t-4), t=-10 .. 10, size=[500,200]);

