Elsevier Science Home
Computer Physics Communications Program Library
Full text online from Science Direct
Programs in Physics & Physical Chemistry
CPC Home

[Licence| Download | New Version Template] adxr_v3_0.tar.gz(18 Kbytes)
Manuscript Title: TaylUR 3, a multivariate arbitrary-order automatic differentiation package for Fortran 95
Authors: G.M. von Hippel
Program title: TaylUR
Catalogue identifier: ADXR_v3_0
Distribution format: tar.gz
Journal reference: Comput. Phys. Commun. 181(2010)705
Programming language: Fortran 95.
Computer: Any computer with a conforming Fortran 95 compiler.
Operating system: Any system with a conforming Fortran 95 compiler.
Keywords: automatic differentiation, higher derivatives, Fortran 95.
Classification: 4.12, 4.14.

Does the new version supersede the previous version?: Yes

Nature of problem:
Problems that require potentially high orders of partial derivatives with respect to several variables or derivatives of complex-valued functions, such as e.g. momentum or mass expansions of Feynman diagrams in perturbative QFT, and which previous versions of this TaylUR [1,2] cannot handle due to their lack of support for mixed partial derivatives.

Solution method:
Arithmetic operators and Fortran intrinsics are overloaded to act correctly on objects of a defined type taylor, which encodes a function along with its first few partial derivatives with respect to the user-defined independent variables. Derivatives of products and composite functions are computed using multivariate forms [3] of Leibniz's rule

Dν(fg) = Σ μ≤ν(ν!/ μ!(μ - ν)!) DμfD&mu - &nug

where ν = (ν1, . . . , νd), |ν| = Σdj = 1νj, ν! = Πdj = 1νj!, Dνf = ∂|ν|f /(∂ν1x1...∂νdxd), and μ < ν iff either |μ| < |ν| or |μ| = |ν|, μ1 = ν1,...μk = νk, μk+1 < νk+1 for some k ∈ {0,...,d - 1}, and of Fàa di Bruno's formula

Dν(f o g) = Σ|ν|p=1(f(p) o g|ν|s=1Σ{(k1,...,ks1,...,λs)}ν! /(Πsj=1kj j!kj) (Dλjg)kj where the sum is over

({k1,...,ks1,...,&lambda ;s) ∈ Zs(1 + d):ki > 0, 0 < λ1 < ...< λs,
Σsi=1ki = psi=1ki&lam bda;i = ν}.

An indexed storage system is used to store the higher-order derivative tensors in a one-dimensional array. The relevant indices (k1,...,ks1,...,λ s) and the weights occuring in the sums in Leibniz's and Fàa di Bruno's formula are precomputed at startup and stored in static arrays for later use.

Reasons for new version:
The earlier version lacked support for mixed partial derivatives, but a number of projects of interest required them.

Summary of revisions:
The internal representation of a taylor object has changed to a one-dimensional array which contains the partial derivatives in ascending order, and in lexicographic order of the corresponding multiindex within the same order. The necessary mappings between multiindices and indices into the taylor objects' internal array are computed at startup.
To support the change to a genuinely multivariate taylor type, the DERIVATIVE function is now implemented via an interface that accepts both the older format derivative(f,mu,n)= ∂nμf and also a new format derivative(f,mu(:))= Dμf that allows access to mixed partial derivatives. Another related extension to the functionality of the module is the HESSIAN function that returns the Hessian matrix of second derivatives of its argument.
Since the calculation of all mixed partial derivatives can be very costly, and in many cases only some subset is actually needed, a masking facility has been added. Calling the subroutine DEACTIVATE_DERIVATIVE with a multiindex as an argument will deactivate the calculation of the partial derivative belonging to that multiindex, and of all partial derivatives it can feed into. Similarly, calling the subroutine ACTIVATE_DERIVATIVE will activate the calculation of the partial derivative belonging to its argument, and of all partial derivatives that can feed into it.
Moreoever, it is possible to turn off the computation of mixed derivatives altogether by setting Diagonal_taylors to .TRUE.. It should be noted that any change of Diagonal_taylors or Taylor_order invalidates all existing taylor objects.
To aid the better integration of TaylUR into the HPSrc library [4], routines SET_DERIVATIVE and SET_ALL_DERIVATIVES are provided as a means of manually constructing a taylor object with given derivatives.

Restrictions:
Memory and CPU time constraints may restrict the number of variables and Taylor expansion order that can be achieved. Loss of numerical accuracy due to cancellation may become an issue at very high orders.

Unusual features:
These are the same as in previous versions, but are enumerated again here for clarity.
The complex conjugation operation assumes all independent variables to be real. The functions REAL and AIMAG do not convert to real type, but return a result of type taylor (with the real/imaginary part of each derivative taken) instead. The user-defined functions VALUE, REALVALUE and IMAGVALUE, which return the value of a taylor object as a complex number, and the real and imaginary part of this value, respectively, as a real number are also provided.
Fortran 95 intrinsics that are defined only for arguments of real type (ACOS, AINT, ANINT, ASIN, ATAN, ATAN2, CEILING, DIM, FLOOR, INT, LOG10, MAX, MAXLOC, MAXVAL, MIN, MINLOC, MINVAL, MOD, MODULO, NINT, SIGN) will silently take the real part of taylor-valued arguments unless the module variable Real_args_warn is set to .TRUE., in which case they will return a quiet NaN value (if supported by the compiler) when called with a taylor argument whose imaginary part exceeds the module variable Real_args_tol.
In those cases where the derivative of a function becomes undefined at certain points (as for ABS, AINT, ANINT, MAX, MIN, MOD, and MODULO), while the value is well defined, the derivative fields will be filled with quiet NaN values (if supported by the compiler).

Additional comments:
This version of TaylUR is released under the second version of the GNU General Public License (GPLv2). Therefore anyone is free to use or modify the code for their own calculations. As part of the licensing, it is requested that any publications including results from the use of TaylUR or any modification derived from it cite refs. [1,2] as well as this paper. Finally, users are also requested to communicate to the author details of such publications, as well as of any bugs found or of required or useful modifications made or desired by them.

Running time:
The running time of TaylUR operations grows rapidly with both the number of variables and the Taylor expansion order. Judicious use of the masking facility to drop unneeded higher derivatives can lead to significant accelerations, as can activation of the Diagonal_taylors variable whenever mixed partial derivatives are not needed.

References:
[1] G. M. von Hippel, TaylUR, an arbitrary-order diagonal automatic differentiation package for Fortran 95, Comput. Phys. Commun. 174 (2006) 569.
[2] G. M. von Hippel, New version announcement for TaylUR, an arbitrary-order diagonal automatic differentiation package for Fortran 95, Comput. Phys. Commun. 176 (2007) 710.
[3] G. M. Constantine, T. H. Savits, A multivariate Faa di Bruno formula with applications, Trans. Amer. Math. Soc. 348 (1996) 2:503.
[4] A. Hart, G. M. von Hippel, R. R. Horgan, E. H. Müller, Automated generation of lattice QCD Feynman rules, Comput. Phys. Commun. (2009), doi:10.1016/j.cpc.2009.04.021 [arXiv:0904.0375].