
diff - differentiation of an expression or a polynomial

Calling sequence:

diff(expr [ , ident ... ])

Parameter:
expr    --  expression or polynomial
ident   --  identifier

Overloading:

1

Summary:

diff differentiates expr relevant to the identifier given by ident.  If more
than one identifier is given then the expression is differentiated relevant to
the first identifier, this result then according to the second indentifier and
so on until all identifiers have been processed. If the identifiers are given in
the form ident $ n through the sequence operatorthen the n-th derivative
relevant to the identifier ident is calculated. If no identifier is given then the
expression is evaluated and returned. In this case a differentiation does not
take place.

For functions whose derivative is not known by diff the function call with
evaluated arguments is returned.

With the function funcattr the effect of differentiation on any system and
user-defined function can be defined. For this purpose a procedure must be
entered in the relevant function environmentunder the index "diff". This
procedure is called with the expressions to be evaluated and the differentiation

parameter as parameters.  The result of the procedure is then used as the
result of the differentiation.

If the argument expr is a polynomial whose coefficients are elements of a
domain Dom then this domain must contain the methods diff and intmult:

  o  Dom::diff(e,x) must return the derivative of the domain element e
     relevant to x.

  o  Dom::intmult(e,i) must calculate the multiple i * e of the domain
     element e for a positive integer i.  It is diff(poly(e*x^3), x) =
     poly(3*e*x^2) and to get this, 3 * e must be calculated in the domain
     Dom.)

diff is a kernel function.

>>  diff(x^2,x);

      2*x

>>  diff(x^2*sin(y),x,y);

      x*cos(y)*2

>>  diff(sin(x)*cos(x),x$3);

      cos(x)^2*(-4)+sin(x)^2*4

>>  diff(poly(sin(a)*x^3 + 2*x, [x]), a, x);

      poly(x^2*(cos(a)*3), [x])

>>  diff(f(x),x);

      diff(f(x),x)

>>  f(2) := 4:
    diff_proc := proc(expr,x)
               begin
                   g(op(expr,1))*diff(op(expr,1),x)
               end_proc:
    f := funcattr(f, "diff", diff_proc):
    diff(f(sin(x)),x);

      cos(x)*g(sin(x))

See also:  D

