# simple usage
x <- dual( c(1,2) )
x
d(x)
x <- dual(matrix(c(1,2,3,4), 2, 2))
x
d(x, "x1.1")
# using an object with names
x <- dual( c(a = 1, b = 2) )
x
d(x)
# generate a constant
x <- dual(1, varnames = c("x1", "x2"), constant = TRUE)
# specify dx
x <- dual(c(1,2), dx = list(x1 = c(1,1)))
x
d(x)
# this is equivalent to :
x <- dual(1)
x <- c(x, x + 1)
x
d(x)
Run the code above in your browser using DataLab