Heaviside(0):= 1: interval:= proc() local v,r,x; if nargs = 2 then r:= args[1] elif nargs = 3 then r:= args[1] .. args[2] fi; if (nargs < 2) or (nargs > 3) or not type(r,range) then ERROR(`usage is interval(a,b,x) or interval(a..b, x)`) fi; if evalb(op(1,r) >= op(2,r)) = true then ERROR(`Invalid range`,r) fi; x:= args[nargs]; if op(1,r) = -infinity then v := 1 else v := Heaviside(x-op(1,r)) fi; if op(2,r) = infinity then v else v-Heaviside(x-op(2,r)) fi end; jplot := proc () local f, r, a, b, tmp, var, n, delta, s, ii; if nargs < 2 then ERROR(`At least 2 arguments needed`) fi; f := args[1]; r := args[2]; if not type(r,`=`) then ERROR(`Not an equation`, r) fi; var := lhs(r); tmp:= rhs(r); if not type(tmp,range) then ERROR(`Invalid range`, r) fi; a := op(1,tmp); b := op(2,tmp); if a >= b then ERROR(`Invalid range`, r) fi; s:= subs(v=var,t -> solve(op(t),v)); map(s, indets(f, {Heaviside(anything), signum(anything), csgn(anything)})) union {a,b}; tmp:= sort(convert(select((t,l,u) -> ((t >= l) and (t<=u)), ", a, b), list)); n := nops(tmp); delta := 0.001*(b-a); plots[display]({seq(plot(f,var = tmp[ii]+delta .. tmp[ii+1]-delta, args[3 .. nargs]),ii = 1 .. n-1)}) end: