Sponsored links: Algebra eBooks
 

Help Index

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z

The Maxima on-line user's manual

Algebra Calculator

Search:

Charfun Calculator

Charfun

Function: charfun (<p>) Return 0 when the predicate <p> evaluates to false; return 1 when the predicate evaluates to true. When the predicate evaluates to something other than true or false (unknown), return a noun form.

display2d;
gradef(charfun(dummy),0);
/* piecewise function definition */itv: [[x<0],[x>=0,x<1], [x>=1]];
 /* intervals */fi:  [ 1,    x^2+1,      2*x  ];
 /* local functions *//* creation of global function f and its derivative */f:0;
for i: 1 thru 3 do f:f+charfun(apply("and",itv[i]))*fi[i];
df:diff(f,x);
/* 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])  );
plot2d([f,df],[x,-2,3],[y,-1,5],[style, [lines,4,3],[lines,2,2]]);

Examples:

          (%i1) charfun (x < 1);
          (%o1)                    charfun(x < 1)
          (%i2) subst (x = -1, %);
          (%o2)                           1
          (%i3) e : charfun ("and" (-1 < x, x < 1))$
          (%i4) [subst (x = -1, e), subst (x = 0, e), subst (x = 1, e)];
          (%o4)                       [0, 1, 0]

There are also some inexact matches for charfun. Try ?? charfun to see them.

(%o1)                                true
(%i2) 

Charfun Example

Related Examples

charfun

charfun (2 < 1);

Calculate

charfun

charfun (2 < 1);

Calculate

charfun-integrate-sin

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

integrate(f(x),x);

Calculate

charfun-subst

charfun (x < 1);

subst (x = -1, %);

e : charfun ('"and" ...

Calculate

charfun

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

f(37);

f(62);

Calculate

charfun-subst

charfun (x < 1);

subst (x = -1, %);

e : charfun ('"and" ...

Calculate

charfun

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

f(37);

f(62);

Calculate