if (interactive()) {
# Surface z = x^2 + y^2 on [-1,1] x [-1,1]
gfun <- function(x, y) x^2 + y^2
# Scalar field phi(x,y,z) = 1 (surface area of the patch)
phi <- function(x, y, z) 1
# Vector field F = (0, 0, 1), flux through the surface
Fvec <- function(x, y, z) c(0, 0, 1)
res <- surface_integral_z(
gfun,
xlim = c(-1, 1),
ylim = c(-1, 1),
nx = 60, ny = 60,
scalar_phi = phi,
vector_F = Fvec,
orientation = "up",
plot = FALSE
)
res$area_density_integral
res$flux_integral
}
Run the code above in your browser using DataLab