| Title: | An Interface to the C++ Automatic Differentiation Library 'autodiff' |
|---|---|
| Description: | Provides an interface from R to the 'autodiff' library <https://autodiff.github.io/>, a modern header-only C++ library for automatic differentiation. Unlike numerical differentiation, automatic differentiation computes derivatives of functions to machine precision without truncation error, using either forward or reverse mode. The 'autodiff' header files are shipped with this package so that other R packages can use them by including 'Rcppautodiff' in the 'LinkingTo' field of their 'DESCRIPTION' file. Example programs demonstrate computing derivatives of single-variable and multi-variable functions, gradient vectors, Jacobian matrices and derivatives with respect to parameters, using 'Rcpp' and 'RcppEigen'. |
| Authors: | Satyaprakash Nayak [aut, cre] (ORCID: <https://orcid.org/0000-0001-7225-1317>) |
| Maintainer: | Satyaprakash Nayak <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 0.1.0 |
| Built: | 2026-07-19 15:41:36 UTC |
| Source: | https://github.com/cran/Rcppautodiff |
Example function to show differentiation w.r.t. a single variable
autodiff_single_var(input)autodiff_single_var(input)
input |
Value of independent variable (must be greater than 0) |
A named list with two elements, value (the function
evaluated at input) and
derivative (the derivative of evaluated at input).
res <- autodiff_single_var(2.0) res$value # f(2) = 1 + 2 + 4 + 0.5 + log(2) res$derivative # f'(2) = 1 + 4 - 0.25 + 0.5 = 5.25res <- autodiff_single_var(2.0) res$value # f(2) = 1 + 2 + 4 + 0.5 + log(2) res$derivative # f'(2) = 1 + 4 - 0.25 + 0.5 = 5.25