Learn R Programming

salad (version 1.2)

d: get list of derivatives

Description

Get value, differential of a dual object, and the names of associated variables.

Usage

d(x, varnames)

value(x)

# S3 method for dual value(x)

# S3 method for numeric value(x)

varnames(x)

# S3 method for dual varnames(x)

# S3 method for numeric varnames(x)

Value

A named list of derivatives.

Arguments

x

a dual (or numeric) oject

varnames

(optional) a vector or varnames to take derivatives along

Details

If `varnames` is provided to the function `d`, a list of derivatives along the given variables will be sent back. In general, it sends back the derivatives along all associated variables.

The `varnames` function sends back the names of all variables for which a derivative is defined.

Examples

Run this code
x <- dual(c(3,2))
varnames(x^2)
x**2
value(x**2)
d(x**2)
d(x**2, "x1")
# you can use these methods with a numerical constant
value(1)
varnames(1)
d(1, "x1")

Run the code above in your browser using DataLab