123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264 |
- \documentstyle[11pt,reduce]{article}
- \title{DFPART: A Package for Calculating with Derivatives of
- Generic Functions}
- \date{}
- \author{
- H. Melenk \\[0.05in]
- Konrad--Zuse--Zentrum \\
- f\"ur Informationstechnik Berlin \\
- Takustra\"se 7 \\
- D--14195 Berlin--Dahlem \\
- Federal Republic of Germany \\[0.05in]
- Email: melenk@zib.de}
- \begin{document}
- \maketitle
- \index{derivatives}
- \index{partial derivatives}
- \index{generic function}
- The package {\tt DFPART} supports computations with total and partial
- derivatives of formal function objects. Such computations can
- be useful in the context of differential equations or
- power series expansions.
- \section{Generic Functions}
- A generic function is a symbol which represents a mathematical
- function. The minimal information about a generic function
- function is the number of its arguments. In order to facilitate
- the programming and for a better readable output this package
- assumes that the arguments of a generic function have default
- names such as $f(x,y)$,$q(rho,phi)$.
- A generic function is declared by prototype form in a statement
- \vspace{.1in}
- {\tt GENERIC\_FUNCTION} $fname(arg_1,arg_2\cdots arg_n)$;
- \vspace{.1in}
- \noindent
- where $fname$ is the (new) name of a function and $arg_i$ are
- symbols for its formal arguments.
- In the following $fname$ is referred to as ``generic function",
- $arg_1,arg_2\cdots arg_n$ as ``generic arguments" and
- $fname(arg_1,arg_2\cdots arg_n)$ as ``generic form".
- Examples:
- \begin{verbatim}
- generic_function f(x,y);
- generic_function g(z);
- \end{verbatim}
- After this declaration {\REDUCE} knows that
- \begin{itemize}
- \item there are formal partial derivatives $\frac{\partial f}{\partial x}$,
- $\frac{\partial f}{\partial y}$ $\frac{\partial g}{\partial z}$
- and higher ones, while partial derivatives of $f$ and $g$
- with respect to other variables are assumed as zero,
- \item expressions of the type $f()$, $g()$ are abbreviations for
- $f(x,y)$, $g(z)$,
- \item expressions of the type $f(u,v)$ are abbreviations for\\
- $sub(x=u,y=v,f(x,y))$
- \item a total derivative $\frac{d f(u,v)}{d w}$ has to be computed
- as $\frac{\partial f}{\partial x} \frac{d u}{d w} +
- \frac{\partial f}{\partial y} \frac{d v}{d w}$
- \end{itemize}
- \section{Partial Derivatives}
- The operator {\tt DFP} represents a partial derivative:
- \vspace{.1in}
- {\tt DFP}($expr,{dfarg_1,dfarg_2\cdots dfarg_n}$);
- \vspace{.1in}
- \noindent
- where $expr$ is a function expression and $dfarg_i$ are
- the differentiation variables. Examples:
- \begin{verbatim}
- dfp(f(),{x,y});
- \end{verbatim}
- means $\frac{\partial ^2 f}{\partial x \partial y}$ and
- \begin{verbatim}
- dfp(f(u,v),{x,y});
- \end{verbatim}
- stands for $\frac{\partial ^2 f}{\partial x \partial y} (u,v)$.
- For compatibility with the $DF$ operator the differentiation
- variables need not be entered in list form; instead the syntax
- of {\tt DF} can be used, where the function expression is followed
- by the differentiation variables, eventually with repetition
- numbers. Such forms are interenally converted to the above
- form with a list as second parameter.
- The expression $expr$ can be a generic function
- with or without arguments, or an arithmetic expression built
- from generic functions and other algebraic parts. In the
- second case the standard differentiation rules are applied
- in order to reduce each derivative expressions to a minimal
- form.
- When the switch {\tt NAT} is on partial derivatives of generic
- functions are printed in standard index notation, that is
- $f_{xy}$ for $\frac{\partial ^2 f}{\partial x \partial y}$
- and $f_{xy}(u,v)$ for $\frac{\partial ^2 f}{\partial x \partial y}(u,v)$.
- Therefore single characters should be used for the arguments
- whenever possible. Examples:
- \begin{verbatim}
- generic_function f(x,y);
- generic_function g(y);
- dfp(f(),x,2);
- F
- XX
- dfp(f()*g(),x,2);
- F *G()
- XX
- dfp(f()*g(),x,y);
- F *G() + F *G
- XY X Y
- \end{verbatim}
- The difference between partial and total derivatives is
- illustrated by the following example:
- \begin{verbatim}
- generic_function h(x);
- dfp(f(x,h(x))*g(h(x)),x);
- F (X,H(X))*G(H(X))
- X
- df(f(x,h(x))*g(h(x)),x);
- F (X,H(X))*G(H(X)) + F (X,H(X))*H (X)*G(H(X))
- X Y X
- + G (H(X))*H (X)*F(X,H(X))
- Y X
- \end{verbatim}
- Cooperation of partial derivatives and Taylor series under
- a differential side relation $\frac{dq}{dx}=f(x,q)$:
- \begin{verbatim}
- load_package taylor;
- operator q;
- let df(q(~x),x) => f(x,q(x));
- taylor(q(x0+h),h,0,3);
- F (X0,Q(X0)) + F (X0,Q(X0))*F(X0,Q(X0))
- X Y 2
- Q(X0) + F(X0,Q(X0))*H + -----------------------------------------*H
- 2
- + (F (X0,Q(X0)) + F (X0,Q(X0))*F(X0,Q(X0))
- XX XY
- + F (X0,Q(X0))*F (X0,Q(X0)) + F (X0,Q(X0))*F(X0,Q(X0))
- X Y YX
- 2 2 3
- + F (X0,Q(X0))*F(X0,Q(X0)) + F (X0,Q(X0)) *F(X0,Q(X0)))/6*H
- YY Y
- 4
- + O(H )
- \end{verbatim}
- Normally partial differentials are assumed as non-commutative
- \begin{verbatim}
- dfp(f(),x,y)-dfp(f(),y,x);
- F - F
- XY YX
- \end{verbatim}
- However, a generic function can be declared to have globally
- interchangeable partial derivatives using the declaration
- {\tt DFP\_COMMUTE}
- which takes the name of a generic function or a generic function
- form as argument. For such a function differentiation variables are
- rearranged corresponding to the sequence of the generic variables.
- \begin{verbatim}
- generic_function q(x,y);
- dfp_commute q(x,y);
- dfp(q(),{x,y,y}) + dfp(q(),{y,x,y}) + dfp(q(),{y,y,x});
- 3*Q
- XYY
- \end{verbatim}
- If only a part of the derivatives commute, this has to be
- declared using the standard {\REDUCE} rule mechanism. Please
- note that then the derivative variables must be written as
- list.
- \section{Substitutions}
- When a generic form or a {\tt DFP} expression takes part in a
- substitution the following steps are performed:
- \begin{enumerate}
- \item The substitutions are performed for the arguments. If the
- argument list is empty the substitution is applied to the
- generic arguments of the function; if these change, the resulting
- forms are used as new actual arguments.
- If the generic function itself is not affected by the substitution,
- the process stops here.
- \item If the function name or the generic function
- form occurs as a left hand side in the substitution list,
- it is replaced by the corresponding right hand side.
- \item The new form is partially differentiated according to the
- list of partial derivative variables.
- \item The (eventually modified) actual parameters are substituted
- into the form for their corresponding generic variables.
- This substitution is done by name.
- \end{enumerate}
- Examples:
- \begin{verbatim}
- generic_function f(x,y);
- sub(y=10,f());
-
- F(X,10)
- sub(y=10,dfp(f(),x,2));
- F (X,10)
- XX
- sub(y=10,dfp(f(y,y),x,2));
- F (10,10)
- XX
- sub(f=x**3*y**3,dfp(f(),x,2));
- 3
- 6*X*Y
- generic_function ff(y,z);
- sub(f=ff,f(a,b));
- FF(B,Z)
- \end{verbatim}
- The dataset $dfpart.tst$ contains more examples,
- including a complete application for computing the coefficient
- equations for Runge-Kutta ODE solvers.
- \end{document}
|