I am trying to convert the below integral implementation in Mathematica into R syntax:
xprime = 0.5;
yprime = 3;
dimx = 20/1000;
dimy = 20/1000;
NIntegrate[Boole[Abs[x - xprime] < dimx/2 && Abs[y - yprime] < dimy/2] 1/(20 Pi Sqrt[x^2 + y^2]),
{x, y} \[Element] Region[Disk[{0, 0}, 10]]]
My code so far is below. It runs without producing an error but is not actually implementing the above integral. I think I'm getting stuck on restricting the set to the disk region.
library(calculus)
# Parameters
xprime <- 0.5
yprime <- 3
dimx <- 20/1000
dimy <- 20/1000
# Function
pb_function5km <- function(x, y) {
result <- ifelse(sqrt(x^2 + y^2) <= 5, 1/(10 * pi * sqrt(x^2+y^2)), 0)
return(result)
}
# Integrate
integral(pb_function5km,
list (x = c(xprime+dimx/2, xprime-dimx/2),
y = c(yprime+dimy/2, yprime-dimy/2)))
Thanks in advance for any help!