I am trying to plot a Fourier integral, but I get error while integrating
X <- seq(-10, 10, by = 0.05)
f_fourier <- function(X) {
Y <- sapply(X, function(x) {
integrand <- function(l) {
y <- (2 / pi) * cos(l * x) / (l^2 + 1)
}
integrate(integrand, lower = 0, upper = Inf)$value
})
}
plot(X,f_fourier(X))
Error:
maximum number of subdivisions reached
I found out that "cos(l * x)" causes this error but Wolfram gives me normal result. Can you suggest something?