2 * Functions and Variables for Differentiation::
5 @c -----------------------------------------------------------------------------
6 @node Functions and Variables for Differentiation, , Differentiation, Differentiation
7 @section Functions and Variables for Differentiation
8 @c -----------------------------------------------------------------------------
10 @c -----------------------------------------------------------------------------
12 @deffn {Function} antid (@var{expr}, @var{x}, @var{u(x)})
14 @c TODO: The antid package is currently undocumented except of this function.
15 Returns a two-element list, such that an antiderivative of @var{expr} with
16 respect to @var{x} can be constructed from the list. The expression @var{expr}
17 may contain an unknown function @var{u} and its derivatives.
19 Let @var{L}, a list of two elements, be the return value of @code{antid}.
20 Then @code{@var{L}[1] + 'integrate (@var{L}[2], @var{x})}
21 is an antiderivative of @var{expr} with respect to @var{x}.
23 When @code{antid} succeeds entirely,
24 the second element of the return value is zero.
25 Otherwise, the second element is nonzero,
26 and the first element is nonzero or zero.
27 If @code{antid} cannot make any progress,
28 the first element is zero and the second nonzero.
30 @code{load ("antid")} loads this function. The @code{antid} package also
31 defines the functions @code{nonzeroandfreeof} and @code{linear}.
33 @code{antid} is related to @mref{antidiff} as follows.
34 Let @var{L}, a list of two elements, be the return value of @code{antid}.
35 Then the return value of @code{antidiff} is equal to
36 @code{@var{L}[1] + 'integrate (@var{L}[2], @var{x})} where @var{x} is the
37 variable of integration.
43 @c expr: exp (z(x)) * diff (z(x), x) * y(x);
44 @c a1: antid (expr, x, z(x));
45 @c a2: antidiff (expr, x, z(x));
46 @c a2 - (first (a1) + 'integrate (second (a1), x));
47 @c antid (expr, x, y(x));
48 @c antidiff (expr, x, y(x));
52 (%i2) expr: exp (z(x)) * diff (z(x), x) * y(x);
54 (%o2) y(x) %e (-- (z(x)))
56 (%i3) a1: antid (expr, x, z(x));
58 (%o3) [y(x) %e , - %e (-- (y(x)))]
60 (%i4) a2: antidiff (expr, x, z(x));
63 (%o4) y(x) %e - I %e (-- (y(x))) dx
66 (%i5) a2 - (first (a1) + 'integrate (second (a1), x));
68 (%i6) antid (expr, x, y(x));
70 (%o6) [0, y(x) %e (-- (z(x)))]
72 (%i7) antidiff (expr, x, y(x));
75 (%o7) I y(x) %e (-- (z(x))) dx
80 @opencatbox{Categories:}
81 @category{Integral calculus}
85 @c -----------------------------------------------------------------------------
87 @deffn {Function} antidiff (@var{expr}, @var{x}, @var{u}(@var{x}))
89 Returns an antiderivative of @var{expr} with respect to @var{x}.
90 The expression @var{expr} may contain an unknown function @var{u} and its
93 When @code{antidiff} succeeds entirely, the resulting expression is free of
94 integral signs (that is, free of the @code{integrate} noun).
95 Otherwise, @code{antidiff} returns an expression
96 which is partly or entirely within an integral sign.
97 If @code{antidiff} cannot make any progress,
98 the return value is entirely within an integral sign.
100 @code{load ("antid")} loads this function.
101 The @code{antid} package also defines the functions @code{nonzeroandfreeof} and
104 @code{antidiff} is related to @code{antid} as follows.
105 Let @var{L}, a list of two elements, be the return value of @code{antid}.
106 Then the return value of @code{antidiff} is equal to
107 @code{@var{L}[1] + 'integrate (@var{L}[2], @var{x})} where @var{x} is the
108 variable of integration.
112 @c THERE IS A DEMO FILE share/integration/antid.dem, EXECUTED BY demo('antid)
113 @c BUT I THINK THE FOLLOWING ILLUSTRATES THE BASIC FUNCTIONALITY MORE CLEARLY
114 @c MAYBE MERGE IN THE DEMO PROBLEMS LATER
117 @c expr: exp (z(x)) * diff (z(x), x) * y(x);
118 @c a1: antid (expr, x, z(x));
119 @c a2: antidiff (expr, x, z(x));
120 @c a2 - (first (a1) + 'integrate (second (a1), x));
121 @c antid (expr, x, y(x));
122 @c antidiff (expr, x, y(x));
125 (%i1) load ("antid")$
126 (%i2) expr: exp (z(x)) * diff (z(x), x) * y(x);
128 (%o2) y(x) %e (-- (z(x)))
130 (%i3) a1: antid (expr, x, z(x));
132 (%o3) [y(x) %e , - %e (-- (y(x)))]
134 (%i4) a2: antidiff (expr, x, z(x));
137 (%o4) y(x) %e - I %e (-- (y(x))) dx
140 (%i5) a2 - (first (a1) + 'integrate (second (a1), x));
142 (%i6) antid (expr, x, y(x));
144 (%o6) [0, y(x) %e (-- (z(x)))]
146 (%i7) antidiff (expr, x, y(x));
149 (%o7) I y(x) %e (-- (z(x))) dx
154 @opencatbox{Categories:}
155 @category{Integral calculus}
159 @c -----------------------------------------------------------------------------
161 @deffn {Function} at @
162 @fname{at} (@var{expr}, [@var{eqn_1}, @dots{}, @var{eqn_n}]) @
163 @fname{at} (@var{expr}, @var{eqn})
165 Evaluates the expression @var{expr} with the variables assuming the values as
166 specified for them in the list of equations @code{[@var{eqn_1}, ...,
167 @var{eqn_n}]} or the single equation @var{eqn}.
169 If a subexpression depends on any of the variables for which a value is
170 specified but there is no @code{atvalue} specified and it can't be otherwise
171 evaluated, then a noun form of the @code{at} is returned which displays in a
172 two-dimensional form.
174 @code{at} carries out multiple substitutions in parallel.
176 See also @mrefdot{atvalue} For other functions which carry out substitutions,
177 see also @mref{subst} and @mrefdot{ev}
182 @c atvalue (f(x,y), [x = 0, y = 1], a^2);
183 @c atvalue ('diff (f(x,y), x), x = 0, 1 + y);
184 @c printprops (all, atvalue);
185 @c diff (4*f(x, y)^2 - u(x, y)^2, x);
186 @c at (%, [x = 0, y = 1]);
190 (%i1) atvalue (f(x,y), [x = 0, y = 1], a^2);
195 (%i2) atvalue ('diff (f(x,y), x), x = 0, 1 + y);
198 (%i3) printprops (all, atvalue);
201 --- (f(@@1, @@2))! = @@2 + 1
210 (%i4) diff (4*f(x, y)^2 - u(x, y)^2, x);
212 (%o4) 8 f(x, y) (-- (f(x, y))) - 2 u(x, y) (-- (u(x, y)))
216 (%i5) at (%, [x = 0, y = 1]);
219 (%o5) 16 a - 2 u(0, 1) (-- (u(x, 1))! )
225 Note that in the last line @code{y} is treated differently to @code{x}
226 as @code{y} isn't used as a differentiation variable.
228 The difference between @mrefcomma{subst} @mref{at} and @mref{ev} can be
229 seen in the following example:
232 @c e1:I(t)=C*diff(U(t),t)$
233 @c e2:U(t)=L*diff(I(t),t)$
239 (%i1) e1:I(t)=C*diff(U(t),t)$
240 (%i2) e2:U(t)=L*diff(I(t),t)$
245 (%o3) I(t) = C (-- (U(t))! )
247 !U(t) = L (-- (I(t)))
253 (%o4) I(t) = C (-- (L (-- (I(t)))))
257 (%i5) ev(e1,e2,diff);
260 (%o5) I(t) = C L (--- (I(t)))
267 @opencatbox{Categories:}
268 @category{Evaluation}
269 @category{Differential equations}
273 @c I SUSPECT THERE IS MORE TO BE SAID HERE
275 @c Me, too: Where is desolve, for example?
277 @c -----------------------------------------------------------------------------
279 @defvr {Property} atomgrad
281 @code{atomgrad} is the atomic gradient property of an expression.
282 This property is assigned by @code{gradef}.
285 @opencatbox{Categories:}
286 @category{Differential calculus}
290 @c -----------------------------------------------------------------------------
292 @deffn {Function} atvalue @
293 @fname{atvalue} (@var{expr}, [@var{x_1} = @var{a_1}, @dots{}, @var{x_m} = @var{a_m}], @var{c}) @
294 @fname{atvalue} (@var{expr}, @var{x_1} = @var{a_1}, @var{c})
296 Assigns the value @var{c} to @var{expr} at the point @code{@var{x} = @var{a}}.
297 Typically boundary values are established by this mechanism.
299 @var{expr} is a function evaluation, @code{@var{f}(@var{x_1}, ..., @var{x_m})},
300 or a derivative, @code{diff (@var{f}(@var{x_1}, ..., @var{x_m}), @var{x_1},
301 @var{n_1}, ..., @var{x_n}, @var{n_m})}
302 @c HMM, WHAT IS THIS NEXT PHRASE GETTING AT ??
303 @c DOES IT INTEND TO IMPLY THAT IMPLICIT DEPENDENCIES ARE IGNORED ??
304 in which the function arguments explicitly appear.
305 @var{n_i} is the order of differentiation with respect to @var{x_i}.
307 The point at which the atvalue is established is given by the list of equations
308 @code{[@var{x_1} = @var{a_1}, ..., @var{x_m} = @var{a_m}]}.
309 If there is a single variable @var{x_1},
310 the sole equation may be given without enclosing it in a list.
312 @code{printprops ([@var{f_1}, @var{f_2}, ...], atvalue)} displays the atvalues
313 of the functions @code{@var{f_1}, @var{f_2}, ...} as specified by calls to
314 @code{atvalue}. @code{printprops (@var{f}, atvalue)} displays the atvalues of
315 one function @var{f}. @code{printprops (all, atvalue)} displays the atvalues
316 of all functions for which atvalues are defined.
318 The symbols @code{@@1}, @code{@@2}, @dots{} represent the
319 variables @var{x_1}, @var{x_2}, @dots{} when atvalues are displayed.
321 @code{atvalue} evaluates its arguments.
322 @code{atvalue} returns @var{c}, the atvalue.
324 See also @mrefdot{at}
329 @c atvalue (f(x,y), [x = 0, y = 1], a^2);
330 @c atvalue ('diff (f(x,y), x), x = 0, 1 + y);
331 @c printprops (all, atvalue);
332 @c diff (4*f(x,y)^2 - u(x,y)^2, x);
333 @c at (%, [x = 0, y = 1]);
337 (%i1) atvalue (f(x,y), [x = 0, y = 1], a^2);
342 (%i2) atvalue ('diff (f(x,y), x), x = 0, 1 + y);
345 (%i3) printprops (all, atvalue);
348 --- (f(@@1, @@2))! = @@2 + 1
357 (%i4) diff (4*f(x,y)^2 - u(x,y)^2, x);
359 (%o4) 8 f(x, y) (-- (f(x, y))) - 2 u(x, y) (-- (u(x, y)))
363 (%i5) at (%, [x = 0, y = 1]);
366 (%o5) 16 a - 2 u(0, 1) (-- (u(x, 1))! )
372 @opencatbox{Categories:}
373 @category{Differential equations}
374 @category{Declarations and inferences}
378 @c LOOKS LIKE cartan IS THE NAME OF A PACKAGE AND NOT A FUNCTION OR VARIABLE
379 @c PROBABLY SHOULD SPLIT OUT cartan AND ITS CONTENTS INTO ITS OWN TEXINFO FILE
380 @c ext_diff AND lie_diff NOT DOCUMENTED (OTHER THAN HERE)
382 @c -----------------------------------------------------------------------------
384 @deffn {Function} cartan
386 The exterior calculus of differential forms is a basic tool
387 of differential geometry developed by Elie Cartan and has important
388 applications in the theory of partial differential equations.
389 The @code{cartan} package
390 implements the functions @code{ext_diff} and @code{lie_diff},
391 along with the operators @code{~} (wedge product) and @code{|} (contraction
392 of a form with a vector.)
393 Type @code{demo ("tensor")} to see a brief
394 description of these commands along with examples.
396 @code{cartan} was implemented by F.B. Estabrook and H.D. Wahlquist.
398 @opencatbox{Categories:}
399 @category{Differential geometry}
403 @c -----------------------------------------------------------------------------
405 @deffn {Function} init_cartan ([@var{x_1}, ..., @var{x_n}])
407 @code{init_cartan([@var{x_1}, ..., @var{x_n}])} initializes global variables
408 for the @code{cartan} package.
409 The sole argument is a list of symbols, from which the Cartan basis is constructed.
411 @code{init_cartan} returns the basis which is constructed.
413 @code{init_cartan} assigns values to the following global variables:
414 @code{cartan_coords}, @code{cartan_dim}, @code{extdim}, and @code{cartan_basis}.
415 In addition, the following arrays are assigned:
416 @code{extsub} and @code{extsubb}.
418 Note: Because of the internal implementation of the @code{cartan} package,
419 it is necessary for @code{init_cartan} to be called before any expression
420 containing the Cartan coordinates @code{@var{x_1}, ..., @var{x_n}} is parsed.
422 @opencatbox{Categories:}
423 @category{Differential geometry}
424 @category{Package cartan}
428 @c -----------------------------------------------------------------------------
430 @deffn {Function} del (@var{x})
432 @code{del (@var{x})} represents the differential of the variable @math{x}.
434 @code{diff} returns an expression containing @code{del}
435 if an independent variable is not specified.
436 In this case, the return value is the so-called "total differential".
438 See also @mrefcomma{diff} @mref{del} and @mrefdot{derivdegree}
448 (%i1) diff (log (x));
452 (%i2) diff (exp (x*y));
454 (%o2) x %e del(y) + y %e del(x)
456 (%o3) x y del(z) + x z del(y) + y z del(x)
459 @opencatbox{Categories:}
460 @category{Differential calculus}
464 @c -----------------------------------------------------------------------------
466 @deffn {Function} delta (@var{t})
468 The Dirac Delta function.
470 Currently only @mref{laplace} knows about the @code{delta} function.
475 @c laplace (delta (t - a) * sin(b*t), t, s);
479 (%i1) laplace (delta (t - a) * sin(b*t), t, s);
480 Is a positive, negative, or zero?
487 @opencatbox{Categories:}
488 @category{Mathematical functions}
489 @category{Laplace transform}
493 @c -----------------------------------------------------------------------------
494 @anchor{dependencies}
495 @defvr {System variable} dependencies
496 @defvrx {Function} dependencies (@var{f_1}, @dots{}, @var{f_n})
498 The variable @code{dependencies} is the list of atoms which have functional
499 dependencies, assigned by @mref{depends}, the function @code{dependencies}, or @mref{gradef}.
500 The @code{dependencies} list is cumulative:
501 each call to @code{depends}, @code{dependencies}, or @code{gradef} appends additional items.
502 The default value of @code{dependencies} is @code{[]}.
504 The function @code{dependencies(@var{f_1}, @dots{}, @var{f_n})} appends @var{f_1}, @dots{}, @var{f_n},
505 to the @code{dependencies} list,
506 where @var{f_1}, @dots{}, @var{f_n} are expressions of the form @code{@var{f}(@var{x_1}, @dots{}, @var{x_m})},
507 and @var{x_1}, @dots{}, @var{x_m} are any number of arguments.
509 @code{dependencies(@var{f}(@var{x_1}, @dots{}, @var{x_m}))} is equivalent to @code{depends(@var{f}, [@var{x_1}, @dots{}, @var{x_m}])}.
511 See also @mref{depends} and @mrefdot{gradef}
515 @c depends (foo, [bar, baz]);
516 @c depends ([g, h], [a, b, c]);
518 @c dependencies (quux (x, y), mumble (u));
520 @c remove (quux, dependency);
529 (%i2) depends (foo, [bar, baz]);
530 (%o2) [foo(bar, baz)]
533 (%i3) depends ([g, h], [a, b, c]);
534 (%o3) [g(a, b, c), h(a, b, c)]
538 (%o4) [foo(bar, baz), g(a, b, c), h(a, b, c)]
541 (%i5) dependencies (quux (x, y), mumble (u));
542 (%o5) [quux(x, y), mumble(u)]
546 (%o6) [foo(bar, baz), g(a, b, c), h(a, b, c), quux(x, y),
550 (%i7) remove (quux, dependency);
555 (%o8) [foo(bar, baz), g(a, b, c), h(a, b, c), mumble(u)]
559 @opencatbox{Categories:}
560 @category{Declarations and inferences}
561 @category{Global variables}
565 @c -----------------------------------------------------------------------------
567 @deffn {Function} depends (@var{f_1}, @var{x_1}, @dots{}, @var{f_n}, @var{x_n})
569 Declares functional dependencies among variables for the purpose of computing
570 derivatives. In the absence of declared dependence, @code{diff (f, x)} yields
571 zero. If @code{depends (f, x)} is declared, @code{diff (f, x)} yields a
572 symbolic derivative (that is, a @code{diff} noun).
574 Each argument @var{f_1}, @var{x_1}, etc., can be the name of a variable or
575 array, or a list of names.
576 Every element of @var{f_i} (perhaps just a single element)
577 is declared to depend
578 on every element of @var{x_i} (perhaps just a single element).
579 If some @var{f_i} is the name of an array or contains the name of an array,
580 all elements of the array depend on @var{x_i}.
582 @code{diff} recognizes indirect dependencies established by @code{depends}
583 and applies the chain rule in these cases.
585 @code{remove (@var{f}, dependency)} removes all dependencies declared for
588 @code{depends} returns a list of the dependencies established.
589 The dependencies are appended to the global variable @mref{dependencies}.
590 @code{depends} evaluates its arguments.
592 @code{diff} is the only Maxima command which recognizes dependencies established
593 by @code{depends}. Other functions (@code{integrate}, @code{laplace}, etc.)
594 only recognize dependencies explicitly represented by their arguments.
595 For example, @mref{integrate} does not recognize the dependence of @code{f} on
596 @code{x} unless explicitly represented as @code{integrate (f(x), x)}.
598 @code{depends(@var{f}, [@var{x_1}, @dots{}, @var{x_n}])} is equivalent to @code{dependencies(@var{f}(@var{x_1}, @dots{}, @var{x_n}))}.
600 See also @mrefcomma{diff} @mrefcomma{del} @mref{derivdegree} and
601 @mrefdot{derivabbrev}
604 @c depends ([f, g], x);
605 @c depends ([r, s], [u, v, w]);
611 (%i1) depends ([f, g], x);
613 (%i2) depends ([r, s], [u, v, w]);
614 (%o2) [r(u, v, w), s(u, v, w)]
615 (%i3) depends (u, t);
618 (%o4) [f(x), g(x), r(u, v, w), s(u, v, w), u(t)]
621 (%o5) -- . s + r . --
631 (%o6) -- -- . s + r . -- --
636 @c remove (r, dependency);
640 (%i7) remove (r, dependency);
648 @opencatbox{Categories:}
649 @category{Differential calculus}
650 @category{Declarations and inferences}
654 @c -----------------------------------------------------------------------------
656 @defvr {Option variable} derivabbrev
657 Default value: @code{false}
659 When @code{derivabbrev} is @code{true},
660 symbolic derivatives (that is, @code{diff} nouns) are displayed as subscripts.
661 Otherwise, derivatives are displayed in the Leibniz notation @code{dy/dx}.
663 @c NEED EXAMPLES HERE
664 @opencatbox{Categories:}
665 @category{Differential calculus}
666 @category{Global flags}
670 @c SEEMS LIKE THIS STATEMENT COULD BE LESS CLUMSY
672 @c -----------------------------------------------------------------------------
674 @deffn {Function} derivdegree (@var{expr}, @var{y}, @var{x})
676 Returns the highest degree of the derivative
677 of the dependent variable @var{y} with respect to the independent variable
678 @var{x} occurring in @var{expr}.
683 @c 'diff (y, x, 2) + 'diff (y, z, 3) + 'diff (y, x) * x^2;
684 @c derivdegree (%, y, x);
687 (%i1) 'diff (y, x, 2) + 'diff (y, z, 3) + 'diff (y, x) * x^2;
690 (%o1) --- + --- + x --
693 (%i2) derivdegree (%, y, x);
697 @opencatbox{Categories:}
698 @category{Differential calculus}
699 @category{Expressions}
703 @c I HAVE NO IDEA WHAT THIS DOES
705 @c -----------------------------------------------------------------------------
707 @deffn {Function} derivlist (@var{var_1}, @dots{}, @var{var_k})
709 Causes only differentiations with respect to
710 the indicated variables, within the @mref{ev} command.
712 @opencatbox{Categories:}
713 @category{Differential calculus}
714 @category{Evaluation}
718 @c -----------------------------------------------------------------------------
720 @defvr {Option variable} derivsubst
721 Default value: @code{false}
723 When @code{derivsubst} is @code{true}, a non-syntactic substitution such as
724 @code{subst (x, 'diff (y, t), 'diff (y, t, 2))} yields @code{'diff (x, t)}.
726 @opencatbox{Categories:}
727 @category{Differential calculus}
728 @category{Expressions}
732 @c -----------------------------------------------------------------------------
734 @deffn {Function} diff @
735 @fname{diff} (@var{expr}, @var{x_1}, @var{n_1}, @dots{}, @var{x_m}, @var{n_m}) @
736 @fname{diff} (@var{expr}, @var{x}, @var{n}) @
737 @fname{diff} (@var{expr}, @var{x}) @
738 @fname{diff} (@var{expr})
740 Returns the derivative or differential of @var{expr} with respect to some or
741 all variables in @var{expr}.
743 @code{diff (@var{expr}, @var{x}, @var{n})} returns the @var{n}'th derivative of
744 @var{expr} with respect to @var{x}.
746 @code{diff (@var{expr}, @var{x_1}, @var{n_1}, ..., @var{x_m}, @var{n_m})}
747 returns the mixed partial derivative of @var{expr} with respect to @var{x_1},
748 @dots{}, @var{x_m}. It is equivalent to @code{diff (... (diff (@var{expr},
749 @var{x_m}, @var{n_m}) ...), @var{x_1}, @var{n_1})}.
751 @code{diff (@var{expr}, @var{x})}
752 returns the first derivative of @var{expr} with respect to
753 the variable @var{x}.
755 @code{diff (@var{expr})} returns the total differential of @var{expr}, that is,
756 the sum of the derivatives of @var{expr} with respect to each its variables
757 times the differential @code{del} of each variable.
758 @c WHAT DOES THIS NEXT STATEMENT MEAN, EXACTLY ??
759 No further simplification of @code{del} is offered.
761 The noun form of @code{diff} is required in some contexts,
762 such as stating a differential equation.
763 In these cases, @code{diff} may be quoted (as @code{'diff}) to yield the noun
764 form instead of carrying out the differentiation.
766 When @code{derivabbrev} is @code{true}, derivatives are displayed as subscripts.
767 Otherwise, derivatives are displayed in the Leibniz notation, @code{dy/dx}.
769 See also @mrefcomma{depends} @mrefcomma{del} @mrefcomma{derivdegree} @mrefcomma{derivabbrev} and @mrefdot{gradef}
774 @c diff (exp (f(x)), x, 2);
775 @c derivabbrev: true$
776 @c 'integrate (f(x, y), y, g(x), h(x));
780 (%i1) diff (exp (f(x)), x, 2);
783 (%o1) %e (--- (f(x))) + %e (-- (f(x)))
786 (%i2) derivabbrev: true$
787 (%i3) 'integrate (f(x, y), y, g(x), h(x));
799 (%o4) I f(x, y) dy + f(x, h(x)) h(x) - f(x, g(x)) g(x)
805 For the tensor package, the following modifications have been
808 (1) The derivatives of any indexed objects in @var{expr} will have the
809 variables @var{x_i} appended as additional arguments. Then all the
810 derivative indices will be sorted.
812 (2) The @var{x_i} may be integers from 1 up to the value of the variable
813 @code{dimension} [default value: 4]. This will cause the differentiation to be
814 carried out with respect to the @var{x_i}'th member of the list
815 @code{coordinates} which should be set to a list of the names of the
816 coordinates, e.g., @code{[x, y, z, t]}. If @code{coordinates} is bound to an
817 atomic variable, then that variable subscripted by @var{x_i} will be used for
818 the variable of differentiation. This permits an array of coordinate names or
819 subscripted names like @code{X[1]}, @code{X[2]}, @dots{} to be used. If
820 @code{coordinates} has not been assigned a value, then the variables will be
821 treated as in (1) above.
823 @c NEED EXAMPLES FOR TENSOR STUFF
824 @opencatbox{Categories:}
825 @category{Differential calculus}
829 @c MERGE THIS INTO @defun diff
831 @c -----------------------------------------------------------------------------
833 @defvr {Special symbol} diff
835 When @code{diff} is present as an @code{evflag} in call to @code{ev},
836 all differentiations indicated in @code{expr} are carried out.
841 @c -----------------------------------------------------------------------------
843 @deffn {Function} express (@var{expr})
845 @c HERE IS THE PREVIOUS TEXT. WHAT IS THE POINT ABOUT depends ?? I'M NOT GETTING IT
846 @c The result uses the noun form of any
847 @c derivatives arising from expansion of the vector differential
848 @c operators. To force evaluation of these derivatives, the built-in @code{ev}
849 @c function can be used together with the @code{diff} evflag, after using the
850 @c built-in @code{depends} function to establish any new implicit dependencies.
852 @c TODO: curl, grad, div and laplacian aren't currently documented.
854 Expands differential operator nouns into expressions in terms of partial
855 derivatives. @code{express} recognizes the operators @code{grad}, @code{div},
856 @code{curl}, @code{laplacian}. @code{express} also expands the cross product
859 Symbolic derivatives (that is, @code{diff} nouns)
860 in the return value of express may be evaluated by including @code{diff}
861 in the @code{ev} function call or command line.
862 In this context, @mref{diff} acts as an @mref{evfun}.
864 @code{load ("vect")} loads this function.
865 @c IN POINT OF FACT, express IS A SIMPLIFICATION RULE, AND express1 IS THE FCN WHICH DOES ALL THE WORK
871 @c grad (x^2 + y^2 + z^2);
874 @c div ([x^2, y^2, z^2]);
877 @c curl ([x^2, y^2, z^2]);
880 @c laplacian (x^2 * y^2 * z^2);
883 @c [a, b, c] ~ [x, y, z];
888 (%i2) grad (x^2 + y^2 + z^2);
890 (%o2) grad (z + y + x )
892 d 2 2 2 d 2 2 2 d 2 2 2
893 (%o3) [-- (z + y + x ), -- (z + y + x ), -- (z + y + x )]
896 (%o4) [2 x, 2 y, 2 z]
897 (%i5) div ([x^2, y^2, z^2]);
899 (%o5) div [x , y , z ]
902 (%o6) -- (z ) + -- (y ) + -- (x )
905 (%o7) 2 z + 2 y + 2 x
906 (%i8) curl ([x^2, y^2, z^2]);
908 (%o8) curl [x , y , z ]
910 d 2 d 2 d 2 d 2 d 2 d 2
911 (%o9) [-- (z ) - -- (y ), -- (x ) - -- (z ), -- (y ) - -- (x )]
915 (%i11) laplacian (x^2 * y^2 * z^2);
917 (%o11) laplacian (x y z )
920 d 2 2 2 d 2 2 2 d 2 2 2
921 (%o12) --- (x y z ) + --- (x y z ) + --- (x y z )
926 (%o13) 2 y z + 2 x z + 2 x y
927 (%i14) [a, b, c] ~ [x, y, z];
928 (%o14) [a, b, c] ~ [x, y, z]
930 (%o15) [b z - c y, c x - a z, a y - b x]
933 @opencatbox{Categories:}
934 @category{Differential calculus}
940 @c COMMENTING OUT THIS TEXT PENDING RESOLUTION OF BUG REPORT # 836704:
941 @c "gendiff is all bugs: should be deprecated"
943 @c Sometimes @code{diff(e,x,n)} can be reduced even though N is
950 @c and you can try, for example,
953 @c diff(%e^(a*x),x,q)
956 @c by using @code{gendiff} rather than @code{diff}. Unevaluable
957 @c items come out quoted. Some items are in terms of @code{genfact}, which
962 @c -----------------------------------------------------------------------------
964 @deffn {Function} gradef @
965 @fname{gradef} (@var{f}(@var{x_1}, @dots{}, @var{x_n}), @var{g_1}, @dots{}, @var{g_m}) @
966 @fname{gradef} (@var{a}, @var{x}, @var{expr})
968 Defines the partial derivatives (i.e., the components of the gradient) of the
969 function @var{f} or variable @var{a}.
971 @code{gradef (@var{f}(@var{x_1}, ..., @var{x_n}), @var{g_1}, ..., @var{g_m})}
972 defines @code{d@var{f}/d@var{x_i}} as @var{g_i}, where @var{g_i} is an
973 expression; @var{g_i} may be a function call, but not the name of a function.
974 The number of partial derivatives @var{m} may be less than the number of
975 arguments @var{n}, in which case derivatives are defined with respect to
976 @var{x_1} through @var{x_m} only.
978 @code{gradef (@var{a}, @var{x}, @var{expr})} defines the derivative of variable
979 @var{a} with respect to @var{x} as @var{expr}. This also establishes the
980 dependence of @var{a} on @var{x} (via @code{depends (@var{a}, @var{x})}).
982 The first argument @code{@var{f}(@var{x_1}, ..., @var{x_n})} or @var{a} is
983 quoted, but the remaining arguments @var{g_1}, ..., @var{g_m} are evaluated.
984 @code{gradef} returns the function or variable for which the partial derivatives
987 @code{gradef} can redefine the derivatives of Maxima's built-in functions.
988 For example, @code{gradef (sin(x), sqrt (1 - sin(x)^2))} redefines the
989 derivative of @code{sin}.
991 @code{gradef} cannot define partial derivatives for a subscripted function.
993 @code{printprops ([@var{f_1}, ..., @var{f_n}], gradef)} displays the partial
994 derivatives of the functions @var{f_1}, ..., @var{f_n}, as defined by
997 @code{printprops ([@var{a_n}, ..., @var{a_n}], atomgrad)} displays the partial
998 derivatives of the variables @var{a_n}, ..., @var{a_n}, as defined by
1001 @code{gradefs} is the list of the functions
1002 for which partial derivatives have been defined by @code{gradef}.
1003 @code{gradefs} does not include any variables
1004 for which partial derivatives have been defined by @code{gradef}.
1006 @c REPHRASE THIS NEXT BIT
1007 Gradients are needed when, for example, a function is not known
1008 explicitly but its first derivatives are and it is desired to obtain
1009 higher order derivatives.
1011 @c NEED EXAMPLES HERE
1012 @opencatbox{Categories:}
1013 @category{Differential calculus}
1014 @category{Declarations and inferences}
1018 @c -----------------------------------------------------------------------------
1020 @defvr {System variable} gradefs
1021 Default value: @code{[]}
1023 @code{gradefs} is the list of the functions
1024 for which partial derivatives have been defined by @code{gradef}.
1025 @code{gradefs} does not include any variables
1026 for which partial derivatives have been defined by @code{gradef}.
1028 @opencatbox{Categories:}
1029 @category{Differential calculus}
1030 @category{Declarations and inferences}