Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article

An efficient overloaded method for computing derivatives of mathematical functions in MATLAB

Published: 03 May 2013 Publication History

Abstract

An object-oriented method is presented that computes without truncation the error derivatives of functions defined by MATLAB computer codes. The method implements forward-mode automatic differentiation via operator overloading in a manner that produces a new MATLAB code that computes the derivatives of the outputs of the original function with respect to the differentiation variables. Because the derivative code has the same input as the original function code, the method can be used recursively to generate derivatives of any order desired. In addition, the approach developed in this article has the feature that the derivatives are generated by simply evaluating the function on an instance of the class, thus making the method straightforward to use while simultaneously enabling differentiation of highly complex functions. A detailed description of the method is presented and the approach is illustrated and shown to be efficient on four examples.

References

[1]
Abramowitz, M. and Stegun, I. 1965. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables. Dover, New York.
[2]
Benson, D. A., Huntington, G. T., Thorvaldsen, T. P., and Rao, A. V. 2006. Direct trajectory optimization and costate estimation via an orthogonal collocation method. J. Guidance, Control, Dynam. 29, 6, 1435--1440.
[3]
Betts, J. T. 2009. Practical Methods for Optimal Control and Estimation Using Nonlinear Programming. SIAM, Philadelphia, PA.
[4]
Biegler, L. T. and Zavala, V. M. 2008. Large-scale nonlinear programming using IPOPT: An integrating framework for enterprise-wide optimization. Comput. Chem. Eng. 33, 3, 575--582.
[5]
Bischof, C. H., Bücker, H. M., Lang, B., Rasch, A., and Vehreschild, A. 2002. Combining source transformation and operator overloading techniques to compute derivatives for MATLAB programs. In Proceedings of the 2nd IEEE International Workshop on Source Code Analysis and Manipulation (SCAM'02). IEEE, Los Alamitos, CA, 65--72.
[6]
Bischof, C. H., Carle, A., Corliss, G. F., Griewank, A., and Hovland, P. D. 1992. ADIFOR: Generating derivative codes from Fortran programs. Sci. Program. 1, 1, 11--29.
[7]
Bischof, C. H., Carle, A., Khademi, P., and Mauer, A. 1996. ADIFOR 2.0: Automatic differentiation of Fortran 77 programs. IEEE Comput. Sci. Eng. 3, 3, 18--32.
[8]
Cayuga Research 2008--2009. ADMAT: Automatic Differentiation Toolbox User's Guide, Version 2.0. Cayuga Research.
[9]
Coleman, T. F. and Verma, A. 1998a. ADMAT: An automatic differentiation toolbox for MATLAB. Tech. rep., Computer Science Department, Cornell University.
[10]
Coleman, T. F. and Verma, A. 1998b. ADMIT-1: Automatic differentiation and MATLAB interface toolbox. ACM Trans. Math. Softw. 26, 1, 150--175.
[11]
Darby, C. L., Hager, W. W., and Rao, A. V. 2011a. Direct trajectory optimization using a variable loworder adaptive pseudospectral method. J. Spacecraft Rockets 48, 3, 433--445.
[12]
Darby, C. L., Hager, W. W., and Rao, A. V. 2011b. An hp--adaptive pseudospectral method for solving optimal control problems. Optimal Control Appl. Meth. 32, 4, 476--502.
[13]
Dobmann, M., Liepelt, M., and Schittkowski, K. 1995. Algorithm 746: PCOMP: A Fortran code for automatic differentiation. ACM Trans. Math. Softw. 21, 3, 233--266.
[14]
Duff, I. S. 2004. MA57—A code for the solution of sparse symmetric definite and indefinite systems. ACM Trans. Math. Softw. 30, 2, 118--144.
[15]
Forth, S. A. 2006. An efficient overloaded implementation of forward mode automatic differentiation in MATLAB. ACM Trans. Math. Softw. 32, 2, 195--222.
[16]
Forth, S. A., Tadjouddine, M., Pryce, J. D., and Reid, J. K. 2004. Jacobian code generated by source transformation and vertex elimination can be as efficient as hand--coding. ACM Trans. Math. Softw. 30, 4, 266--299.
[17]
Garg, D., Hager, W. W., and Rao, A. V. 2011a. Pseudospectral methods for solving infinite-horizon optimal control problems. Automatica 47, 4, 829--837.
[18]
Garg, D., Patterson, M. A., Darby, C. L., Francolin, C., Huntington, G. T., Hager, W. W., and Rao, A. V. 2011b. Direct trajectory optimization and costate estimation of finite-horizon and infinite horizon optimal control problems via a Radau pseudospectral method. Comput. Optim. Appl. 49, 2, 335--358.
[19]
Garg, D., Patterson, M. A., Hager, W. W., Rao, A. V., Benson, D. A., and Huntington, G. T. 2010. A unified framework for the numerical solution of optimal control problems using pseudospectral methods. Automatica 46, 11, 1843--1851.
[20]
Griewank, A. 2008. Evaluating Derivatives: Principles and Techniques of Algorithmic Differentiation. Frontiers in Appl. Mathematics. SIAM, Philadelphia, PA.
[21]
Griewank, A., Juedes, D., and Utke, J. 1996. Algorithm 755: ADOL-C, a package for the automatic differentiation of algorithms written in c/c++. ACM Trans. Math. Softw. 22, 2, 131--167.
[22]
Hascoët, L. and Pascual, V. 2004. TAPENADE 2.1 User's Guide. Rapport Technique 300, INRIA, Sophia Antipolis.
[23]
Kharche, R. V. 2011. MATLAB automatic differentiation using source transformation. Ph.D. dissertation, Department of Informatics, Systems Engineering, Applied Mathematics, and Scientific Computing, Cranfield University.
[24]
Kharche, R. V. and Forth, S. A. 2006. Source transformation for MATLAB automatic differentiation. In Computational Science, Lecture Notes in Computer Science, vol. 3994, N. Alexandrov et al. Eds., Springer, Berlin, 558--565.
[25]
Lantoine, G., Russell, R. P., and Dargent, T. 2012. Using multicomplex variables for automatic computation of high-order derivatives. ACM Trans. Math. Softw. 38, 3, 16:1--16:21.
[26]
Martins, J. R. R. A., Sturdza, P., and Alonso, J. J. 2003. The complex-step derivative approximation. ACM Trans. Math. Softw. 29, 3, 245--262.
[27]
MathWorks. 2010. Version R2010b. The MathWorks Inc., Natick, MA.
[28]
Monagan, M. B., Geddes, K. O., Heal, K. M., Labahn, G., Vorkoetter, S. M., Mccarron, J., and Demarco, P. 2005. Maple 10 Programming Guide. Maplesoft, Waterloo ON, Canada.
[29]
Neidinger, R. D. 2010. Introduction to automatic differentiation and MATLAB object-oriented programming. SIAM Rev. 52, 3, 545--563.
[30]
Padulo, M., Forth, S. A., and Guenov, M. D. 2008. Robust aircraft conceptual design using automatic differentiation in MATLAB. In Advances in Automatic Differentiation, C. H. Bischof et al. Eds., Lecture Notes in Computer Science, vol. 64, Springer, Berlin, 271--280.
[31]
Patterson, M. A. and Rao, A. V. 2012. Exploiting sparsity in direct collocation pseudospectral methods for solving continuous-time optimal control problems. J. Spacecraft Rockets, 49, 2, 364--377.
[32]
Rao, A. V., Benson, D. A., Christopher Darby, M. A. P., Francolin, C., Sanders, I., and Huntington, G. T. 2010. Algorithm 902: GPOPS, A MATLAB software for solving multiple-phase optimal control problems using the Gauss pseudospectral method. ACM Trans. Math. Softw. 37, 2, 22:1--22:39.
[33]
Rao, A. V., Benson, D. A., Darby, C. L., Mahon, B., Francolin, C., Patterson, M. A., Sanders, I., and Huntington, G. T. 2011. User's Manual for GPOPS Version 4.x: A MATLAB Software for Solving Multiple-Phase Optimal Control Problems Using hp--Adaptive Pseudospectral Methods. http://www.gpops.org.
[34]
Rump, S. M. 1999. Intlab -- INTerval LABoratory. In Developments in Reliable Computing, T. Csendes, Ed., Kluwer, Amsterdam, 77--104.
[35]
Shampine, L. F. 2007. Accurate numerical derivatives in MATLAB. ACM Trans. Math. Softw. 33, 4, 26:1--26:17.
[36]
Speelpenning, B. 1980. Compiling fast partial derivatives of functions given by algorithms. Ph.D. dissertation, University of Illinois at Urbana-Champaign.
[37]
Tadjouddine, M., Forth, S. A., Pryce, J. D., and Reid, J. K. 2002. Performance issues for vertex elimination methods in computing jacobians using automatic differentiation. In Proceedings of the International Conference on Computational Science-Part II. ICCS'02. Springer, Berlin, 1077--1086.
[38]
Waechter, A. and Biegler, L. T. 2006. On the implementation of a primal-dual interior-point filter line search algorithm for large-scale nonlinear programming. Math. Program. 106, 1, 575--582.
[39]
Wolfram. 2008. Mathematica Edition: Version 7.0. Wolfram Research, Champaign, IL.

Cited By

View all
  • (2024)A comparative study of Filon-type rules for oscillatory integralsJournal of Numerical Analysis and Approximation Theory10.33993/jnaat531-138053:1(132-145)Online publication date: 6-Mar-2024
  • (2023)DRL-based Path Planner and its Application in Real Quadrotor with LIDARJournal of Intelligent and Robotic Systems10.1007/s10846-023-01819-0107:3Online publication date: 13-Mar-2023
  • (2021)Implementation of Dual Number Automatic Differentiation with John Newman’s BAND AlgorithmJournal of The Electrochemical Society10.1149/1945-7111/ac3274168:11(113501)Online publication date: 8-Nov-2021
  • Show More Cited By

Index Terms

  1. An efficient overloaded method for computing derivatives of mathematical functions in MATLAB

      Recommendations

      Comments

      Information & Contributors

      Information

      Published In

      cover image ACM Transactions on Mathematical Software
      ACM Transactions on Mathematical Software  Volume 39, Issue 3
      April 2013
      149 pages
      ISSN:0098-3500
      EISSN:1557-7295
      DOI:10.1145/2450153
      Issue’s Table of Contents
      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      Published: 03 May 2013
      Accepted: 01 September 2012
      Revised: 01 August 2012
      Received: 01 December 2011
      Published in TOMS Volume 39, Issue 3

      Permissions

      Request permissions for this article.

      Check for updates

      Author Tags

      1. Automatic differentiation
      2. MATLAB
      3. applied mathematics
      4. numerical methods
      5. scientific computation

      Qualifiers

      • Research-article
      • Research
      • Refereed

      Funding Sources

      Contributors

      Other Metrics

      Bibliometrics & Citations

      Bibliometrics

      Article Metrics

      • Downloads (Last 12 months)13
      • Downloads (Last 6 weeks)1
      Reflects downloads up to 09 Feb 2025

      Other Metrics

      Citations

      Cited By

      View all
      • (2024)A comparative study of Filon-type rules for oscillatory integralsJournal of Numerical Analysis and Approximation Theory10.33993/jnaat531-138053:1(132-145)Online publication date: 6-Mar-2024
      • (2023)DRL-based Path Planner and its Application in Real Quadrotor with LIDARJournal of Intelligent and Robotic Systems10.1007/s10846-023-01819-0107:3Online publication date: 13-Mar-2023
      • (2021)Implementation of Dual Number Automatic Differentiation with John Newman’s BAND AlgorithmJournal of The Electrochemical Society10.1149/1945-7111/ac3274168:11(113501)Online publication date: 8-Nov-2021
      • (2021)Adaptive Hamiltonian Variational Integrators and Applications to Symplectic Accelerated OptimizationSIAM Journal on Scientific Computing10.1137/20M138383543:4(A2949-A2980)Online publication date: 19-Aug-2021
      • (2021)Computation of higher order Lie derivatives on the Infinity ComputerJournal of Computational and Applied Mathematics10.1016/j.cam.2020.113135383(113135)Online publication date: Feb-2021
      • (2020)Algorithm 1008ACM Transactions on Mathematical Software10.1145/337854246:2(1-26)Online publication date: 19-May-2020
      • (2020)Knee abduction moment is predicted by lower gluteus medius force and larger vertical and lateral ground reaction forces during drop vertical jump in female athletesJournal of Biomechanics10.1016/j.jbiomech.2020.109669(109669)Online publication date: Jan-2020
      • (2020)On Dynamic Substructuring of Systems with Localised NonlinearitiesDynamic Substructures, Volume 410.1007/978-3-030-47630-4_9(105-116)Online publication date: 13-Sep-2020
      • (2019)Ultrasound-Based Optimal Parameter Estimation Improves Assessment of Calf Muscle–Tendon Interaction During WalkingAnnals of Biomedical Engineering10.1007/s10439-019-02395-xOnline publication date: 5-Nov-2019
      • (2018)Adaptive Continuation Strategy for Indirect Hypersonic Trajectory OptimizationJournal of Spacecraft and Rockets10.2514/1.A3401355:4(818-828)Online publication date: Jul-2018
      • Show More Cited By

      View Options

      Login options

      Full Access

      View options

      PDF

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader

      Figures

      Tables

      Media

      Share

      Share

      Share this Publication link

      Share on social media