Question:How can I plot a piecewise mixed function/expression?

Question:How can I plot a piecewise mixed function/expression?

Maple 14

How can I plot this piecewise function:

for j from n-1 by -1 to 0 do

... does some processing that's not really relevant to the question:

s[j] := evalf(a[j]+b[j]*(t-x[j])+c[j]*(t-x[j])^2+d[j]*(t-x[j])^3)

end do;

S := t-> piecewise(

x[0] <= t and t <= x[1], s[0],

x[1] <= t and t <= x[2], s[1],

x[2] <= t and t <= x[3], s[2]);

My friends all got theirs to work by cheap, low-class (to someone who insists on programming purity), hardcoding, like this:

S := -> piecewise(x0 <= x and x <= x1, a0+b0*(x-x0)+c0*(x-x0)^2+d0*(x-x0)^3, x1 <= x and x <= x2, a1+b1*(x-x1)+c1*(x-x1)^2+d1*(x-x1)^3, x2 <= x and x <= x3, a2+b2*(x-x2)+c2*(x-x2)^2+d2*(x-x2)^3);

plot1 := plot(points, style = POINT);

plot2 := plot(S(x), x = x0 .. x3);

display(plot1, plot2);

But I can't get it to plot. I tried making each s[j] (the pieces), as functions, but it still wouldn't plot. I also can't get S, the overall piecewise function, evaluate. Sometimes I can get it to choose the right piece (e.g., if I type S(some-number-between x[0] ans x[1]), it returns the first piece, but never evaluates it).

Thanks for all your help, everyone.

-J

﻿