Up | Next | Prev | PrevTail | Tail |
This package 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.
The package 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.
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
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,\dots ,arg_n\) as “generic arguments" and \(fname(arg_1,arg_2,\dots ,arg_n)\) as “generic form". Examples:
generic_function f(x,y); generic_function g(z);
After this declaration REDUCE knows that
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,
expressions of the type \(f()\), \(g()\) are abbreviations for \(f(x,y)\), \(g(z)\),
expressions of the type \(f(u,v)\) are abbreviations for
\(sub(x=u,y=v,f(x,y))\)
a total derivative \(\displaystyle \frac {d f(u,v)}{d w}\) has to be computed as \(\displaystyle \frac {\partial f}{\partial x} \frac {d u}{d w} + \frac {\partial f}{\partial y} \frac {d v}{d w}\)
The operator dfp represents a partial derivative:
where \(\langle \)expr\(\rangle \) is a function expression and \(\langle \)dfarg\(_i\)\(\rangle \) are the differentiation variables. Examples:
dfp(f(),{x,y});
means \(\displaystyle \frac {\partial ^2 f}{\partial x \partial y}\) and
dfp(f(u,v),{x,y});
stands for \(\displaystyle \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 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 nat is on partial derivatives of generic functions are printed in standard index notation, that is \(f_{xy}\) for \(\displaystyle \frac {\partial ^2 f}{\partial x \partial y}\) and \(f_{xy}(u,v)\) for \(\displaystyle \frac {\partial ^2 f}{\partial x \partial y}(u,v)\). Therefore single characters should be used for the arguments whenever possible. Examples:
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
The difference between partial and total derivatives is illustrated by the following example:
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
Cooperation of partial derivatives and Taylor series under a differential side relation \(\frac {dq}{dx}=f(x,q)\):
load_package taylor; operator q; let df(q(~x),x) => f(x,q(x)); taylor(q(x0+h),h,0,3); q(x0) + f(x0,q(x0))*h f (x0,q(x0)) + f (x0,q(x0))*f(x0,q(x0)) x y 2 + -----------------------------------------*h + 2 (f (x0,q(x0)) + f (x0,q(x0))*f(x0,q(x0)) xx xy + f (x0,q(x0))*f (x0,q(x0)) x y + f (x0,q(x0))*f(x0,q(x0)) yx 2 + f (x0,q(x0))*f(x0,q(x0)) yy 2 3 4 + f (x0,q(x0)) *f(x0,q(x0)))/6*h + O(h ) y
Normally partial differentials are assumed as non-commutative
dfp(f(),x,y)-dfp(f(),y,x); f - f xy yx
However, a generic function can be declared to have globally interchangeable partial derivatives using the declaration 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.
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
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.
When a generic form or a dfp expression takes part in a substitution the following steps are performed:
Examples:
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)
The dataset dfpart.tst contains more examples, including a complete application for computing the coefficient equations for Runge-Kutta ODE solvers.
Up | Next | Prev | PrevTail | Front |