View source: R/differentiate.R
d | R Documentation |
Differentiate a function for a single variable.
d(f, x, derivs = NULL)
f |
The function to differentiate. |
x |
The variable that f should be differentiated with respect to. |
derivs |
An S4 class of type fcts that defines additional derivatives. See |
The following functions are already supported:
sin, sinh, asin, cos, cosh, acos, tan, tanh, atan, exp, log, sqrt, c, vector, numeric, rep and matrix.
Notably, for the functions: c, vector, numeric, rep and matrix the function is ignored during differentiation.
For example function f and symbol x:
df/dx
library(dfdr) d(sin, x) f <- function(x) -sin(x) d(f, x) # Initialize list lst <- dfdr::fcts() # The function which should be added f <- function(x) x^2 # The dervative function of f f_deriv <- function(x) 2*x # add new entry to list lst <- fcts_add_fct(lst, f, f_deriv) g <- function(z) f(z) d(g, z, lst)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.