#' Center difference for numeric vectors
#'
#' @param y numeric vector to differentiate
#' @param h step-size
#'
#' @description {Center difference approximationt to first derivative for a numeric vector representing a function evaluated on a grid.}
#' @details {Details are well known. At each point we take the next and previous, their difference and divided by the step-size.}
#' @return vector
#' @export fd_central
fd_central <- function(y, h)
{
n <- length(y)
z <- matrix(0, nrow = n-2)
for(i in 2:(n-1))
{
z[i-1] <- (y[i+1]-y[i-1])/(2*h)
}
return(z)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.