### Related

##### charfun

h(x,y,t):=charfun(x&g...

Calculate

##### charfun

h(x,y,t):=charfun(x&g...

Calculate

##### charfun

f(n):=2+charfun(n>...

f(37);

f(62);

Calculate

##### charfun

h(x,y,t):=charfun(x&g...

Calculate

##### charfun-subst

charfun (x < 1);

subst (x = -1, %);

e : charfun ('"and" ...

Calculate

? charfun;

Calculate

charfun (x < 1);

Calculate

##### charfun-subst

charfun (x < 1);

subst (x = -1, %);

e : charfun ('"and" ...

Calculate

charfun (x < 1);

Calculate

##### charfun-integrate-sin

f(x):=charfun(x<0)...

integrate(f(x),x);

Calculate

### charfun

Run Example
```(%i1)h(x,y,t):=charfun(x>
y-t/2)*charfun(x<
y)*4/t^2*(x-y+t/2);
t
charfun(x > y - -) charfun(x < y) 4
2                            t
(%o1)    h(x, y, t) := ----------------------------------- (x - y + -)
2                           2
t
(%i2) ```
Run Example
```charfun (x <
1);
(%o1)                           charfun(x < 1)
(%i2)  subst (x = -1, %);
(%o2)              e : charfun ('"and" (-1 <
x, x <
1));
[subst (x = -1, e), subst (x = 0, e), subst (x = 1, e)];
(%o3)                    charfun(mand(- 1 < x, x < 1))
(%i4) ```
Run Example
```display2d;
(%o1)                                true
(%o2)                           charfun(dummy)
(%i3) /* piecewise function definition */itv: [[x<
0],[x>
=0,x<
1], [x>
=1]];
(%o3)                [[x < 0], [x >= 0, x < 1], [x >= 1]]
(%i4)  /* intervals */fi:  [ 1,    x^2+1,      2*x  ];
2
(%o4)                          [1, x  + 1, 2 x]
(%i5)  /* local functions *//* creation of global function f and its derivative */f:0;
(%o5)                                  0
(%i6) for i: 1 thru 3 do f:f+charfun(apply("and",itv[i]))*fi[i];
(%o6)                                done
(%i7) df:diff(f,x);
(%o7)        2 x charfun((x >= 0) and (x < 1)) + 2 charfun(x >= 1)
(%i8) /* display local functions and derivatives */for i: 1 thru 3 do (  apply(assume,itv[i]),  newline(),  print(itv[i]),  print("f = ",ev(f)),  print("df = ",ev(df)),  apply(forget,itv[i])  );

[x < 0]
f =  1
df =  0

[x >= 0, x < 1]
2
f =  x  + 1
df =  2 x

[x >= 1]
f =  2 x
df =  2
(%o8)                                done
(%i9) plot2d([f,df],[x,-2,3],[y,-1,5],[style, [lines,4,3],[lines,2,2]]);
plot```

Help for Charfun