R/fnorm.R

Defines functions fnorm

Documented in fnorm

##
##  f n o r m .R  Function Norm
##


fnorm <- function(f, g, x1, x2, p = 2, npoints = 100) {
    stopifnot(is.numeric(x1), length(x1) == 1,
              is.numeric(x2), length(x2) == 1, x1 < x2,
              is.numeric(npoints), length(npoints) == 1, npoints >= 2)

    f <- match.fun(f)
    g <- match.fun(g)

    x  <- seq(x1, x2, length.out = npoints)
    yf <- f(x)
    yg <- g(x)
    if (length(yf) != npoints || length(yg) != npoints)
        stop("Arguments 'f' and 'g' must be vectorized functions.")

    fd <- Norm(yf - yg, p = p)
    return(fd)
}

Try the pracma package in your browser

Any scripts or data that you put into this service are public.

pracma documentation built on March 19, 2024, 3:05 a.m.