4
$\begingroup$

I have the following problem. Let's say we have a 2D region, let me be very explicit:

R = ImplicitRegion[
  Cos[x] + Cos[y] + Cos[z] == 
   1.5, {{x, -π, π}, {y, -π, π}, {z, -π, π}}];

I'd like to integrate some function over this surface (looks like potato), for example it's area is given by integral over the surface of function equal to 1:

NIntegrate[1, {x, y, z} ∈ R]

Unfortunately, the result is the input, i.e. Mathematica doesn't know how to do the integration. Never mind, we can always discretize region:

dR = DiscretizeRegion[R, MaxCellMeasure -> 100]

Now, it works!

NIntegrate[1, {x, y, z} ∈ dR]

gives

46.2047

Some odd function:

NIntegrate[x, {x, y, z} ∈ dR]

gives:

0.0000340503

Should be zero from (anti)symmetry, but nevermind, it's the matter of discretization step.

But now, when I try (the result should also be close to zero):

NIntegrate[Sin[x], {x, y, z} ∈ dR]

The output is rather lengthy and intriguing error "tdlen: Objects of unequal length in \ {NIntegrateSimplexQuadratureDumpU$14954[1], ..." and "Could not complete external evaluation at instruction 186; proceeding \ with uncompiled evaluation." - what does it mean? How different is Sin[x] from x? The result after listing those errors is -0.000115624 (sounds likely), but it takes longer (significantly). How can I integrate ANY function over ANY 2D implicit region (the one I chose is something that can't be done analytically to demonstrate nature of this error)? What's nature of these errors? Did someone else run into the same or similar problem as me? Thanks.

P.S.: I tried with f[x_,y_,z_]:= (Sin[x]^2+Sin[y]^2+Sin[z]^2)^(-1/2) and for this function the result is not even a number, it's lot of errors and the input.

I have Mathematica student version 10.0.2.0 running on Win 10.

$\endgroup$
7
  • $\begingroup$ NIntegrate[Sin[x], {x, y, z} ∈ R] works for me. $\endgroup$
    – J. M.'s torpor
    May 9 '16 at 16:21
  • $\begingroup$ Wow, how? For me it doesn't. Which version of M are you using? $\endgroup$
    – user16320
    May 9 '16 at 16:24
  • $\begingroup$ I am using 10.4.1, on Xubuntu Trusty. You might want to include your version number and OS in your question. $\endgroup$
    – J. M.'s torpor
    May 9 '16 at 16:26
  • $\begingroup$ As a workaround, have you tried reformulating your integral to use Boole[] instead? $\endgroup$
    – J. M.'s torpor
    May 9 '16 at 16:32
  • 1
    $\begingroup$ i opened a post on the same question and i obtained a satisfying answer. $\endgroup$
    – lakehal
    Nov 29 '16 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.