skip to main content
research-article

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

Published:03 May 2013Publication History
Skip Abstract Section

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.Google ScholarGoogle Scholar
  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.Google ScholarGoogle Scholar
  3. Betts, J. T. 2009. Practical Methods for Optimal Control and Estimation Using Nonlinear Programming. SIAM, Philadelphia, PA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle ScholarCross RefCross Ref
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Cayuga Research 2008--2009. ADMAT: Automatic Differentiation Toolbox User's Guide, Version 2.0. Cayuga Research.Google ScholarGoogle Scholar
  9. Coleman, T. F. and Verma, A. 1998a. ADMAT: An automatic differentiation toolbox for MATLAB. Tech. rep., Computer Science Department, Cornell University. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Coleman, T. F. and Verma, A. 1998b. ADMIT-1: Automatic differentiation and MATLAB interface toolbox. ACM Trans. Math. Softw. 26, 1, 150--175. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle ScholarCross RefCross Ref
  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.Google ScholarGoogle ScholarCross RefCross Ref
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Forth, S. A. 2006. An efficient overloaded implementation of forward mode automatic differentiation in MATLAB. ACM Trans. Math. Softw. 32, 2, 195--222. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Griewank, A. 2008. Evaluating Derivatives: Principles and Techniques of Algorithmic Differentiation. Frontiers in Appl. Mathematics. SIAM, Philadelphia, PA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Hascoët, L. and Pascual, V. 2004. TAPENADE 2.1 User's Guide. Rapport Technique 300, INRIA, Sophia Antipolis.Google ScholarGoogle Scholar
  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.Google ScholarGoogle Scholar
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. MathWorks. 2010. Version R2010b. The MathWorks Inc., Natick, MA.Google ScholarGoogle Scholar
  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.Google ScholarGoogle Scholar
  29. Neidinger, R. D. 2010. Introduction to automatic differentiation and MATLAB object-oriented programming. SIAM Rev. 52, 3, 545--563. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle Scholar
  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.Google ScholarGoogle ScholarCross RefCross Ref
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle Scholar
  34. Rump, S. M. 1999. Intlab -- INTerval LABoratory. In Developments in Reliable Computing, T. Csendes, Ed., Kluwer, Amsterdam, 77--104.Google ScholarGoogle Scholar
  35. Shampine, L. F. 2007. Accurate numerical derivatives in MATLAB. ACM Trans. Math. Softw. 33, 4, 26:1--26:17. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Speelpenning, B. 1980. Compiling fast partial derivatives of functions given by algorithms. Ph.D. dissertation, University of Illinois at Urbana-Champaign. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Wolfram. 2008. Mathematica Edition: Version 7.0. Wolfram Research, Champaign, IL.Google ScholarGoogle Scholar

Index Terms

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

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      • 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

        Copyright © 2013 ACM

        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: 3 May 2013
        • Accepted: 1 September 2012
        • Revised: 1 August 2012
        • Received: 1 December 2011
        Published in toms Volume 39, Issue 3

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Qualifiers

        • research-article
        • Research
        • Refereed

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader