# Integration over implicit region

**URL:** https://discourse.julialang.org/t/integration-over-implicit-region/112729
**Category:** Numerics
**Created:** [April 9, 2024, 1:56pm UTC](https://discourse.julialang.org/t/integration-over-implicit-region/112729 "2024-04-09T13:56:31Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![jabru](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jabru/32/205670_2.png) [@jabru](https://discourse.julialang.org/u/jabru)
#### Post date: [April 9, 2024, 1:56pm UTC](https://discourse.julialang.org/t/integration-over-implicit-region/112729/1 "2024-04-09T13:56:31Z")

</div>

Hi there,

this is more of a package existence than anything else. There is one functionality in Wolfram Mathematica, which I have never seen implemented in any open source software package. Neither for Julia nor for any other language. That is the integration over an implicit region. In Mathematica, it is possible to integrate over an implicit region as easily as

```julia
NIntegrate[f(x), x \in R];

```

where `R` is the implicit region. A more thorough and comprehensive example can be found here: [https://www.wolfram.com/mathematica/new-in-10/basic-and-formula-regions/integrate-over-regions.html](https://www.wolfram.com/mathematica/new-in-10/basic-and-formula-regions/integrate-over-regions.html)

Now I find this feature really immensely useful, and therefore would like to have something similar in Julia. Therefore I would like to know if there is something like and if yes, where. If no, if anyone has an idea, how to implement something like this.

Thank you in advance!

---

<div class="post-metadata">

### Author: ![lxvm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lxvm/32/50010_2.png) [@lxvm](https://discourse.julialang.org/u/lxvm)
#### Post date: [April 12, 2024, 1:39am UTC](https://discourse.julialang.org/t/integration-over-implicit-region/112729/2 "2024-04-12T01:39:41Z")

</div>

As far as I know, there isn’t a single package to do all of the things available in Mathematica, however some packages may give you partial capabilities. For example, DomainIntegrals.jl has an interface for domains, but not implicit domains. IteratedIntegration.jl also has an interface for domains that require either an explicit parameterization or that can be represented as polyhedra. This could also be extended to implicit domains or manifolds, since the only requirement for the iterated integration algorithm is to be able to perform optimization over the domain to find the extremal points along the coordinate axes, and to perform elimination of one variable at a time.

What I just mentioned is relevant to numerical integration. It would also be interesting to find out what algorithm Mathematica is using for the symbolic integration in the examples posted.

The boundary integral equation community has also developed methods for integrals over implicit surfaces, for example [this paper](https://arxiv.org/abs/2210.03699) and [this thesis](https://www.diva-portal.org/smash/record.jsf?pid=diva2%3A1701791&dswid=-4646), but building reliable, general-purpose algorithms is often a substantial undertaking, or a research problem, that would need some motivation.

---

<div class="post-metadata">

### Author: ![yangxucmt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yangxucmt/32/208425_2.png) [@yangxucmt](https://discourse.julialang.org/u/yangxucmt)
#### Post date: [April 12, 2024, 2:14am UTC](https://discourse.julialang.org/t/integration-over-implicit-region/112729/3 "2024-04-12T02:14:24Z")

</div>

Hello, I have also been looking for stuff like that for some while. I think the C++ package CGAL is ideally suited to to that. The central idea is to generate a triangulated mesh of the implicit region (see this:[CGAL 5.6.1 - Surface Mesh: User Manual](https://doc.cgal.org/latest/Surface_mesh/index.html)) and then sum the target function over central point of triangles weighted by their areas. There’s also a julia wrapper for CGAL ([GitHub - rgcv/CGAL.jl: CGAL meets Julia](https://github.com/rgcv/CGAL.jl)), though I haven’t used that yet.

---

<div class="post-metadata">

### Author: ![jabru](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jabru/32/205670_2.png) [@jabru](https://discourse.julialang.org/u/jabru)
#### Post date: [May 15, 2024, 9:31pm UTC](https://discourse.julialang.org/t/integration-over-implicit-region/112729/4 "2024-05-15T21:31:10Z")

</div>

Thanks a lot!

I will try that out when I have time!

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [May 16, 2024, 1:17am UTC](https://discourse.julialang.org/t/integration-over-implicit-region/112729/5 "2024-05-16T01:17:07Z")

</div>

> [@yangxucmt](#):
>
> The central idea is to generate a triangulated mesh of the implicit region

That seems not ideal for quadrature, since for numerical integration you usually want to be able to integrate smooth functions to nearly machine precision. A triangulated mesh will have low-order accuracy.

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [May 16, 2024, 1:20am UTC](https://discourse.julialang.org/t/integration-over-implicit-region/112729/6 "2024-05-16T01:20:33Z")

</div>

> [@lxvm](#):
>
> The boundary integral equation community has also developed methods for integrals over implicit surfaces,

In that field they are solving even more difficult problems involving singular integrands. For smooth integrands the algorithms should be easier.

This 2015 algorithm looks promising, just using recursive 1d quadrature and root finding: [https://math.lbl.gov/~saye/96629.pdf](https://math.lbl.gov/~saye/96629.pdf)
