[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

18. Differentiation


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

18.1 Functions and Variables for Differentiation

Function: antid (expr, x, u(x))

Returns a two-element list, such that an antiderivative of expr with respect to x can be constructed from the list. The expression expr may contain an unknown function u and its derivatives.

Let L, a list of two elements, be the return value of antid. Then L[1] + 'integrate (L[2], x) is an antiderivative of expr with respect to x.

When antid succeeds entirely, the second element of the return value is zero. Otherwise, the second element is nonzero, and the first element is nonzero or zero. If antid cannot make any progress, the first element is zero and the second nonzero.

load ("antid") loads this function. The antid package also defines the functions nonzeroandfreeof and linear.

antid is related to antidiff as follows. Let L, a list of two elements, be the return value of antid. Then the return value of antidiff is equal to L[1] + 'integrate (L[2], x) where x is the variable of integration.

Examples:

(%i1) load ("antid")$
(%i2) expr: exp (z(x)) * diff (z(x), x) * y(x);
                            z(x)  d
(%o2)                y(x) %e     (-- (z(x)))
                                  dx
(%i3) a1: antid (expr, x, z(x));
                       z(x)      z(x)  d
(%o3)          [y(x) %e    , - %e     (-- (y(x)))]
                                       dx
(%i4) a2: antidiff (expr, x, z(x));
                            /
                     z(x)   [   z(x)  d
(%o4)         y(x) %e     - I %e     (-- (y(x))) dx
                            ]         dx
                            /
(%i5) a2 - (first (a1) + 'integrate (second (a1), x));
(%o5)                           0
(%i6) antid (expr, x, y(x));
                             z(x)  d
(%o6)             [0, y(x) %e     (-- (z(x)))]
                                   dx
(%i7) antidiff (expr, x, y(x));
                  /
                  [        z(x)  d
(%o7)             I y(x) %e     (-- (z(x))) dx
                  ]              dx
                  /

Categories:  Integral calculus

Function: antidiff (expr, x, u(x))

Returns an antiderivative of expr with respect to x. The expression expr may contain an unknown function u and its derivatives.

When antidiff succeeds entirely, the resulting expression is free of integral signs (that is, free of the integrate noun). Otherwise, antidiff returns an expression which is partly or entirely within an integral sign. If antidiff cannot make any progress, the return value is entirely within an integral sign.

load ("antid") loads this function. The antid package also defines the functions nonzeroandfreeof and linear.

antidiff is related to antid as follows. Let L, a list of two elements, be the return value of antid. Then the return value of antidiff is equal to L[1] + 'integrate (L[2], x) where x is the variable of integration.

Examples:

(%i1) load ("antid")$
(%i2) expr: exp (z(x)) * diff (z(x), x) * y(x);
                            z(x)  d
(%o2)                y(x) %e     (-- (z(x)))
                                  dx
(%i3) a1: antid (expr, x, z(x));
                       z(x)      z(x)  d
(%o3)          [y(x) %e    , - %e     (-- (y(x)))]
                                       dx
(%i4) a2: antidiff (expr, x, z(x));
                            /
                     z(x)   [   z(x)  d
(%o4)         y(x) %e     - I %e     (-- (y(x))) dx
                            ]         dx
                            /
(%i5) a2 - (first (a1) + 'integrate (second (a1), x));
(%o5)                           0
(%i6) antid (expr, x, y(x));
                             z(x)  d
(%o6)             [0, y(x) %e     (-- (z(x)))]
                                   dx
(%i7) antidiff (expr, x, y(x));
                  /
                  [        z(x)  d
(%o7)             I y(x) %e     (-- (z(x))) dx
                  ]              dx
                  /

Categories:  Integral calculus

Function: at (expr, [eqn_1, …, eqn_n])
Function: at (expr, eqn)

Evaluates the expression expr with the variables assuming the values as specified for them in the list of equations [eqn_1, ..., eqn_n] or the single equation eqn.

If a subexpression depends on any of the variables for which a value is specified but there is no atvalue specified and it can't be otherwise evaluated, then a noun form of the at is returned which displays in a two-dimensional form.

at carries out multiple substitutions in parallel.

See also atvalue. For other functions which carry out substitutions, see also subst and ev.

Examples:

(%i1) atvalue (f(x,y), [x = 0, y = 1], a^2);
                                2
(%o1)                          a
(%i2) atvalue ('diff (f(x,y), x), x = 0, 1 + y);
(%o2)                        @2 + 1
(%i3) printprops (all, atvalue);
                                !
                  d             !
                 --- (f(@1, @2))!       = @2 + 1
                 d@1            !
                                !@1 = 0

                                     2
                          f(0, 1) = a

(%o3)                         done
(%i4) diff (4*f(x, y)^2 - u(x, y)^2, x);
                  d                          d
(%o4)  8 f(x, y) (-- (f(x, y))) - 2 u(x, y) (-- (u(x, y)))
                  dx                         dx
(%i5) at (%, [x = 0, y = 1]);
                                         !
              2              d           !
(%o5)     16 a  - 2 u(0, 1) (-- (u(x, y))!            )
                             dx          !
                                         !x = 0, y = 1

Property: atomgrad

atomgrad is the atomic gradient property of an expression. This property is assigned by gradef.

Categories:  Differential calculus

Function: atvalue (expr, [x_1 = a_1, …, x_m = a_m], c)
Function: atvalue (expr, x_1 = a_1, c)

Assigns the value c to expr at the point x = a. Typically boundary values are established by this mechanism.

expr is a function evaluation, f(x_1, ..., x_m), or a derivative, diff (f(x_1, ..., x_m), x_1, n_1, ..., x_n, n_m) in which the function arguments explicitly appear. n_i is the order of differentiation with respect to x_i.

The point at which the atvalue is established is given by the list of equations [x_1 = a_1, ..., x_m = a_m]. If there is a single variable x_1, the sole equation may be given without enclosing it in a list.

printprops ([f_1, f_2, ...], atvalue) displays the atvalues of the functions f_1, f_2, ... as specified by calls to atvalue. printprops (f, atvalue) displays the atvalues of one function f. printprops (all, atvalue) displays the atvalues of all functions for which atvalues are defined.

The symbols @1, @2, … represent the variables x_1, x_2, … when atvalues are displayed.

atvalue evaluates its arguments. atvalue returns c, the atvalue.

Examples:

(%i1) atvalue (f(x,y), [x = 0, y = 1], a^2);
                                2
(%o1)                          a
(%i2) atvalue ('diff (f(x,y), x), x = 0, 1 + y);
(%o2)                        @2 + 1
(%i3) printprops (all, atvalue);
                                !
                  d             !
                 --- (f(@1, @2))!       = @2 + 1
                 d@1            !
                                !@1 = 0

                                     2
                          f(0, 1) = a

(%o3)                         done
(%i4) diff (4*f(x,y)^2 - u(x,y)^2, x);
                  d                          d
(%o4)  8 f(x, y) (-- (f(x, y))) - 2 u(x, y) (-- (u(x, y)))
                  dx                         dx
(%i5) at (%, [x = 0, y = 1]);
                                         !
              2              d           !
(%o5)     16 a  - 2 u(0, 1) (-- (u(x, y))!            )
                             dx          !
                                         !x = 0, y = 1

Function: cartan

The exterior calculus of differential forms is a basic tool of differential geometry developed by Elie Cartan and has important applications in the theory of partial differential equations. The cartan package implements the functions ext_diff and lie_diff, along with the operators ~ (wedge product) and | (contraction of a form with a vector.) Type demo (tensor) to see a brief description of these commands along with examples.

cartan was implemented by F.B. Estabrook and H.D. Wahlquist.

Categories:  Differential geometry

Function: del (x)

del (x) represents the differential of the variable x.

diff returns an expression containing del if an independent variable is not specified. In this case, the return value is the so-called "total differential".

Examples:

(%i1) diff (log (x));
                             del(x)
(%o1)                        ------
                               x
(%i2) diff (exp (x*y));
                     x y              x y
(%o2)            x %e    del(y) + y %e    del(x)
(%i3) diff (x*y*z);
(%o3)         x y del(z) + x z del(y) + y z del(x)

Categories:  Differential calculus

Function: delta (t)

The Dirac Delta function.

Currently only laplace knows about the delta function.

Example:

(%i1) laplace (delta (t - a) * sin(b*t), t, s);
Is  a  positive, negative, or zero?

p;
                                   - a s
(%o1)                   sin(a b) %e

System variable: dependencies

Default value: []

dependencies is the list of atoms which have functional dependencies, assigned by depends or gradef. The dependencies list is cumulative: each call to depends or gradef appends additional items.

See depends and gradef.

Function: depends (f_1, x_1, …, f_n, x_n)

Declares functional dependencies among variables for the purpose of computing derivatives. In the absence of declared dependence, diff (f, x) yields zero. If depends (f, x) is declared, diff (f, x) yields a symbolic derivative (that is, a diff noun).

Each argument f_1, x_1, etc., can be the name of a variable or array, or a list of names. Every element of f_i (perhaps just a single element) is declared to depend on every element of x_i (perhaps just a single element). If some f_i is the name of an array or contains the name of an array, all elements of the array depend on x_i.

diff recognizes indirect dependencies established by depends and applies the chain rule in these cases.

remove (f, dependency) removes all dependencies declared for f.

depends returns a list of the dependencies established. The dependencies are appended to the global variable dependencies. depends evaluates its arguments.

diff is the only Maxima command which recognizes dependencies established by depends. Other functions (integrate, laplace, etc.) only recognize dependencies explicitly represented by their arguments. For example, integrate does not recognize the dependence of f on x unless explicitly represented as integrate (f(x), x).

(%i1) depends ([f, g], x);
(%o1)                     [f(x), g(x)]
(%i2) depends ([r, s], [u, v, w]);
(%o2)               [r(u, v, w), s(u, v, w)]
(%i3) depends (u, t);
(%o3)                        [u(t)]
(%i4) dependencies;
(%o4)      [f(x), g(x), r(u, v, w), s(u, v, w), u(t)]
(%i5) diff (r.s, u);
                         dr           ds
(%o5)                    -- . s + r . --
                         du           du
(%i6) diff (r.s, t);
                      dr du           ds du
(%o6)                 -- -- . s + r . -- --
                      du dt           du dt
(%i7) remove (r, dependency);
(%o7)                         done
(%i8) diff (r.s, t);
                                ds du
(%o8)                       r . -- --
                                du dt

Option variable: derivabbrev

Default value: false

When derivabbrev is true, symbolic derivatives (that is, diff nouns) are displayed as subscripts. Otherwise, derivatives are displayed in the Leibniz notation dy/dx.

Function: derivdegree (expr, y, x)

Returns the highest degree of the derivative of the dependent variable y with respect to the independent variable x occuring in expr.

Example:

(%i1) 'diff (y, x, 2) + 'diff (y, z, 3) + 'diff (y, x) * x^2;
                         3     2
                        d y   d y    2 dy
(%o1)                   --- + --- + x  --
                          3     2      dx
                        dz    dx
(%i2) derivdegree (%, y, x);
(%o2)                           2

Function: derivlist (var_1, …, var_k)

Causes only differentiations with respect to the indicated variables, within the ev command.

Categories:  Differential calculus · Evaluation

Option variable: derivsubst

Default value: false

When derivsubst is true, a non-syntactic substitution such as subst (x, 'diff (y, t), 'diff (y, t, 2)) yields 'diff (x, t).

Function: diff (expr, x_1, n_1, …, x_m, n_m)
Function: diff (expr, x, n)
Function: diff (expr, x)
Function: diff (expr)

Returns the derivative or differential of expr with respect to some or all variables in expr.

diff (expr, x, n) returns the n'th derivative of expr with respect to x.

diff (expr, x_1, n_1, ..., x_m, n_m) returns the mixed partial derivative of expr with respect to x_1, …, x_m. It is equivalent to diff (... (diff (expr, x_m, n_m) ...), x_1, n_1).

diff (expr, x) returns the first derivative of expr with respect to the variable x.

diff (expr) returns the total differential of expr, that is, the sum of the derivatives of expr with respect to each its variables times the differential del of each variable. No further simplification of del is offered.

The noun form of diff is required in some contexts, such as stating a differential equation. In these cases, diff may be quoted (as 'diff) to yield the noun form instead of carrying out the differentiation.

When derivabbrev is true, derivatives are displayed as subscripts. Otherwise, derivatives are displayed in the Leibniz notation, dy/dx.

Examples:

(%i1) diff (exp (f(x)), x, 2);
                     2
              f(x)  d               f(x)  d         2
(%o1)       %e     (--- (f(x))) + %e     (-- (f(x)))
                      2                   dx
                    dx
(%i2) derivabbrev: true$
(%i3) 'integrate (f(x, y), y, g(x), h(x));
                         h(x)
                        /
                        [
(%o3)                   I     f(x, y) dy
                        ]
                        /
                         g(x)
(%i4) diff (%, x);
       h(x)
      /
      [
(%o4) I     f(x, y)  dy + f(x, h(x)) h(x)  - f(x, g(x)) g(x)
      ]            x                     x                  x
      /
       g(x)

For the tensor package, the following modifications have been incorporated:

(1) The derivatives of any indexed objects in expr will have the variables x_i appended as additional arguments. Then all the derivative indices will be sorted.

(2) The x_i may be integers from 1 up to the value of the variable dimension [default value: 4]. This will cause the differentiation to be carried out with respect to the x_i'th member of the list coordinates which should be set to a list of the names of the coordinates, e.g., [x, y, z, t]. If coordinates is bound to an atomic variable, then that variable subscripted by x_i will be used for the variable of differentiation. This permits an array of coordinate names or subscripted names like X[1], X[2], … to be used. If coordinates has not been assigned a value, then the variables will be treated as in (1) above.

Categories:  Differential calculus

Special symbol: diff

When diff is present as an evflag in call to ev, all differentiations indicated in expr are carried out.

Function: dscalar (f)

Applies the scalar d'Alembertian to the scalar function f.

load ("ctensor") loads this function.

Function: express (expr)

Expands differential operator nouns into expressions in terms of partial derivatives. express recognizes the operators grad, div, curl, laplacian. express also expands the cross product ~.

Symbolic derivatives (that is, diff nouns) in the return value of express may be evaluated by including diff in the ev function call or command line. In this context, diff acts as an evfun.

load ("vect") loads this function.

Examples:

(%i1) load ("vect")$
(%i2) grad (x^2 + y^2 + z^2);
                              2    2    2
(%o2)                  grad (z  + y  + x )
(%i3) express (%);
       d    2    2    2   d    2    2    2   d    2    2    2
(%o3) [-- (z  + y  + x ), -- (z  + y  + x ), -- (z  + y  + x )]
       dx                 dy                 dz
(%i4) ev (%, diff);
(%o4)                    [2 x, 2 y, 2 z]
(%i5) div ([x^2, y^2, z^2]);
                              2   2   2
(%o5)                   div [x , y , z ]
(%i6) express (%);
                   d    2    d    2    d    2
(%o6)              -- (z ) + -- (y ) + -- (x )
                   dz        dy        dx
(%i7) ev (%, diff);
(%o7)                    2 z + 2 y + 2 x
(%i8) curl ([x^2, y^2, z^2]);
                               2   2   2
(%o8)                   curl [x , y , z ]
(%i9) express (%);
       d    2    d    2   d    2    d    2   d    2    d    2
(%o9) [-- (z ) - -- (y ), -- (x ) - -- (z ), -- (y ) - -- (x )]
       dy        dz       dz        dx       dx        dy
(%i10) ev (%, diff);
(%o10)                      [0, 0, 0]
(%i11) laplacian (x^2 * y^2 * z^2);
                                  2  2  2
(%o11)                laplacian (x  y  z )
(%i12) express (%);
         2                2                2
        d     2  2  2    d     2  2  2    d     2  2  2
(%o12)  --- (x  y  z ) + --- (x  y  z ) + --- (x  y  z )
          2                2                2
        dz               dy               dx
(%i13) ev (%, diff);
                      2  2      2  2      2  2
(%o13)             2 y  z  + 2 x  z  + 2 x  y
(%i14) [a, b, c] ~ [x, y, z];
(%o14)                [a, b, c] ~ [x, y, z]
(%i15) express (%);
(%o15)          [b z - c y, c x - a z, a y - b x]

Categories:  Differential calculus · Vectors · Operators

Function: gradef (f(x_1, …, x_n), g_1, …, g_m)
Function: gradef (a, x, expr)

Defines the partial derivatives (i.e., the components of the gradient) of the function f or variable a.

gradef (f(x_1, ..., x_n), g_1, ..., g_m) defines df/dx_i as g_i, where g_i is an expression; g_i may be a function call, but not the name of a function. The number of partial derivatives m may be less than the number of arguments n, in which case derivatives are defined with respect to x_1 through x_m only.

gradef (a, x, expr) defines the derivative of variable a with respect to x as expr. This also establishes the dependence of a on x (via depends (a, x)).

The first argument f(x_1, ..., x_n) or a is quoted, but the remaining arguments g_1, ..., g_m are evaluated. gradef returns the function or variable for which the partial derivatives are defined.

gradef can redefine the derivatives of Maxima's built-in functions. For example, gradef (sin(x), sqrt (1 - sin(x)^2)) redefines the derivative of sin.

gradef cannot define partial derivatives for a subscripted function.

printprops ([f_1, ..., f_n], gradef) displays the partial derivatives of the functions f_1, ..., f_n, as defined by gradef.

printprops ([a_n, ..., a_n], atomgrad) displays the partial derivatives of the variables a_n, ..., a_n, as defined by gradef.

gradefs is the list of the functions for which partial derivatives have been defined by gradef. gradefs does not include any variables for which partial derivatives have been defined by gradef.

Gradients are needed when, for example, a function is not known explicitly but its first derivatives are and it is desired to obtain higher order derivatives.

System variable: gradefs

Default value: []

gradefs is the list of the functions for which partial derivatives have been defined by gradef. gradefs does not include any variables for which partial derivatives have been defined by gradef.

Function: laplace (expr, t, s)

Attempts to compute the Laplace transform of expr with respect to the variable t and transform parameter s.

laplace recognizes in expr the functions delta, exp, log, sin, cos, sinh, cosh, and erf, as well as derivative, integrate, sum, and ilt. If laplace fails to find a transform the function specint is called. specint can find the laplace transform for expressions with special functions like the bessel functions bessel_j, bessel_i, … and can handle the unit_step function. See also specint.

If specint cannot find a solution too, a noun laplace is returned.

expr may also be a linear, constant coefficient differential equation in which case atvalue of the dependent variable is used. The required atvalue may be supplied either before or after the transform is computed. Since the initial conditions must be specified at zero, if one has boundary conditions imposed elsewhere he can impose these on the general solution and eliminate the constants by solving the general solution for them and substituting their values back.

laplace recognizes convolution integrals of the form integrate (f(x) * g(t - x), x, 0, t); other kinds of convolutions are not recognized.

Functional relations must be explicitly represented in expr; implicit relations, established by depends, are not recognized. That is, if f depends on x and y, f (x, y) must appear in expr.

See also ilt, the inverse Laplace transform.

Examples:

(%i1) laplace (exp (2*t + a) * sin(t) * t, t, s);
                            a
                          %e  (2 s - 4)
(%o1)                    ---------------
                           2           2
                         (s  - 4 s + 5)
(%i2) laplace ('diff (f (x), x), x, s);
(%o2)             s laplace(f(x), x, s) - f(0)
(%i3) diff (diff (delta (t), t), t);
                          2
                         d
(%o3)                    --- (delta(t))
                           2
                         dt
(%i4) laplace (%, t, s);
                            !
               d            !         2
(%o4)        - -- (delta(t))!      + s  - delta(0) s
               dt           !
                            !t = 0
(%i5) assume(a>0)$
(%i6) laplace(gamma_incomplete(a,t),t,s),gamma_expand:true;
                                              - a - 1
                         gamma(a)   gamma(a) s
(%o6)                    -------- - -----------------
                            s            1     a
                                        (- + 1)
                                         s
(%i7) factor(laplace(gamma_incomplete(1/2,t),t,s));
                                              s + 1
                      sqrt(%pi) (sqrt(s) sqrt(-----) - 1)
                                                s
(%o7)                 -----------------------------------
                                3/2      s + 1
                               s    sqrt(-----)
                                           s
(%i8) assume(exp(%pi*s)>1)$
(%i9) laplace(sum((-1)^n*unit_step(t-n*%pi)*sin(t),n,0,inf),t,s),
         simpsum;
                         %i                         %i
              ------------------------ - ------------------------
                              - %pi s                    - %pi s
              (s + %i) (1 - %e       )   (s - %i) (1 - %e       )
(%o9)         ---------------------------------------------------
                                       2
(%i9) factor(%);
                                      %pi s
                                    %e
(%o9)                   -------------------------------
                                             %pi s
                        (s - %i) (s + %i) (%e      - 1)


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Jaime Villate on April, 11 2013 using texi2html 1.76.