Question: Maple doesn't seem to compute correctly this expression

I have just come across this curious but really boring problem.
In the code snippet below, expr1 and expr2 are identical.

restart:
data := [a=1, b=2]:
convert(
  piecewise(And(x(t) > a, x(t) < b), 1, 0),
  Heaviside
):
expr1 := eval(eval(%, data),  x(t)=z):
plot(expr1, z=0..3);


convert(
  piecewise(And(z > a, z< b), 1, 0),
  Heaviside
):
expr2 := eval(%, data),:
plot(expr2, z=0..3);


But if I change the parameterization of the problem, expr2 is still correct but expr1 is not

restart:
data := [d=1.5, a=0.5]:
convert(
  piecewise(And(x(t) > d-a, x(t) < d+a), 1, 0),
  Heaviside
):
expr1 := eval(eval(%, data),  x(t)=z):
plot(expr1, z=0..3);


convert(
  piecewise(And(z > d-a, z< d+a), 1, 0),
  Heaviside
):
expr2 := eval(%, data),:
plot(expr2, z=0..3);

Where does this come from?

PS: I'm sorry not to be able loading the mw file

Please Wait...