1
$\begingroup$

In order to calculate the volume of the solid defined by

$$\frac{51}{100} (\cos x \cos y+\cos x \cos z+\cos y \cos z)+\cos x+\cos y+\cos z+1\le0$$

where $x,y,z\in[0,2\pi]$

enter image description here

I used the following code (in MATLAB)

f = @(x, y, z) double(1 + cos(x) + cos(y) + cos(z) + 0.51*(cos(x).*cos(y)  + cos(x).*cos(z) + cos(y).*cos(z))<=0)
q = 8*integral3(f, 0, pi, 0, pi, 0, pi)

but gives warning message and NaN

Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.

How to obtain the desired result in as high as possible precision?

Update:

It seems Gauss-Kronrod Rule solves this problem correctly; a further variable substitution, $u_i=\cos x_i$ with Jacobian determinant involved may cause computation efficiency.

$\endgroup$
5
  • 3
    $\begingroup$ While I don't know any clever quadrature methods for your type of problem, you could always stick this into a routine using Monte Carlo integration to compute the volume fairly trivially. $\endgroup$
    – spektr
    May 24, 2017 at 23:28
  • $\begingroup$ thank you. The only concern is Monte carlo method has poor accuracy. $\endgroup$ May 25, 2017 at 0:16
  • 3
    $\begingroup$ Finding the volume of a semi-algebraic set (which is very similar to what you have, except with polynomial inequalities) is known to be a hard problem in general, so yours is harder. It's possible that there wouldn't be anything much better than MC. Also, could you please include the full output, not just "gives error message". In particular, what is the exact error message? $\endgroup$
    – Kirill
    May 25, 2017 at 0:27
  • 3
    $\begingroup$ @LCFactorization Naïve MC might have a slow convergence of $O(n^{-1/2})$, where $n$ is the nunmber of samples, but you might be able to find some more adaptive MC approaches that could make your computation more accurate in a feasible time. The Wikipedia page mentions a few: en.wikipedia.org/wiki/Monte_Carlo_integration $\endgroup$
    – spektr
    May 25, 2017 at 0:49
  • 7
    $\begingroup$ Could you triangulate (tetrahedralize?) your domain? Using high-order elements to follow the curved boundary would the use of a great number of quadrature tools commonly used in finite element methods. They also have the nice property that the result will converge to the correct result as you refine the mesh. This could allow you to get a close approximation to the volume in a very short amount of time, provided that you have a capable mesh generation program at your disposal. I might suggest the "Distmesh 3d" package as a starting point for mesh generation in matlab. $\endgroup$ May 25, 2017 at 2:27

1 Answer 1

4
$\begingroup$

I would do what @Tyler Olsen suggesting; you can mesh that. The right tool would be CGAL http://www.cgal.org, linear elements is easiest to use, in fact, all is almost done, just follow example 3D Mesh Generation, the section about 3D Domains Bounded by Implicit Isosurfaces. With mesh refinement you will converge to exact solution.

Another way is to generate surface mash only and apply Divergence theorem (Gauss's theorem - Ostrogradsky's theorem). $$ V = \frac{1}{3}\int_S x\cdot n \textrm{d}S $$

You can as well generate surface patches, and implicitly calculate mapping for those surface and integrate them one by one using Gauss's theorem.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.