Description Usage Arguments Value Author(s) Examples
View source: R/num.deriv.fct.R
Computes the numerical derivative of the transpose of the vector-valued function f evaluated at the point m, based on the central difference formula.
If f is a mapping from R^p to R^q, then the result is a p-by-q matrix. i.e. The result is an approximation to \partial f'(m)/\partial m.
1 | num.deriv.fct(f.fct, m)
|
f.fct |
An R function object that defines a vector-valued function f. |
m |
A vector, indicating the point m at which the numerical derivative is to be computed. |
num.deriv.fct
returns a matrix, which is the numerical
derivative of the transpose of the function f evaluated at m.
Joseph B. Lang
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # Let x = (x[1], x[2], x[3])', and
# f(x) = (x[1]^3 - 2 * x[2] + 1, sin(x[1] * x[3]), log(x[2] + x[3]))'.
# Approximate d f^{T}(x) / d x at x = (1, 2, 3)'.
# The true value of the derivative is
# [ 3 3cos(3) 0
# -2 0 0.2
# 0 cos(3) 0.2] .
f.fct <- function(x) {
c(x[1]^3 - 2 * x[2] + 1,
sin(x[1] * x[3]),
log(x[2] + x[3]))
}
num.deriv.fct(f.fct, c(1, 2, 3))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.