I want to integrate a function which looks like
f <- function(x) 1.96 * sqrt(t(c(1,x)) %*% m %*% c(1,x))
where m is
m <- matrix(c(3.855, -0.206, -0.206, 0.01), nrow = 2, ncol = 2, byrow = T)
Since the matrix multiplication inside my function produces a scalar, for any value of x
, this is just a one-dimensional integration for f(x)
. How can I solve this smoothly?
Simply with integrate
and Vectorize
:
integrate(Vectorize(f), lower = 0, upper = 1)