Package 'Rcppautodiff'

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

Help Index


autodiff_single_var

Description

Example function to show differentiation w.r.t. a single variable

Usage

autodiff_single_var(input)

Arguments

input

Value of independent variable (must be greater than 0)

Value

A named list with two elements, value (the function f(x)=1+x+x2+1/x+log(x)f(x) = 1 + x + x^2 + 1/x + \log(x) evaluated at input) and derivative (the derivative of ff evaluated at input).

Examples

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.25