d {dfdr} | R Documentation |
Differentiate a function for a single variable.
Description
Differentiate a function for a single variable.
Usage
d(f, x, derivs = NULL)
Arguments
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 |
Details
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.
Value
For example function f and symbol x:
df/dx
Examples
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)
[Package dfdr version 0.2.0 Index]