Automatic Differentiation

I have created an automatic differentiation class for Octave.

It can handle the basic operators, most core functions, matrix factorizations, and functions. See the link for a complete list. The code is in a single file that can be downloaded from the ‘implementation and how to use it’ section of the page linked above. I also have another file, not on the website testing all (I think) of the code paths. It currently does not support complex numbers. They can be used but incorrect results may be returned. Is this something that you would like incorporated into Octave as a package?

It only finds the first derivative bug #59718 Broadcasting does not work with sparse matrices discouraged me from attempting the second derivative.

The automatic differentiation method I implemented is part of a large group of tutorials on numerical methods available on the same site

As part of writing these tutorials, I have found several bugs and provided solutions (I’m sure I’ve missed a few):

  • #59705 repelem error with sparse matrix input
  • #60738 logm returning incorrect result with some real non-symmetric matrices
  • #60786 mpower: negative scalar to power of matrix containing non-integers returns nan
  • #60797 sqrtm: returns nan for matrix of ones with rows and columns >=4
  • #60817 log2 documentation incorporate X=F*2^E
  • #61191 eval can cause a crash to desktop

I have also implemented several new functions:

  • #59850 Add missing function “uniquetol”
  • #10019 [octave forge] (statistics) slicesample implementation
  • #10016 [octave forge] (statistics) mhsample implementation (over from bug #59924)
  • #10023 bvp4c and bvpinit

No decision has been made about which of the three different algorithms to use in bvp4c so I have not finished the implementation.

1 Like