4
$\begingroup$

Bug introduced in 11.1 and fixed in 11.2.0


I solved for the centroid of $x^2+y^2+\sin(4x)+\sin(4y)=4$

J = RegionCentroid[
  DiscretizeRegion[
   ImplicitRegion[
    x^2 + y^2 + Sin[4*x] + Sin[4*y] == 4, {{x, -3, 3}, {y, -3, 3}}], 
   AccuracyGoal -> 8]]

But end up with

{-1.90037, 0.230247}

With a lower accuracy

J = RegionCentroid[
      DiscretizeRegion[
       ImplicitRegion[
        x^2 + y^2 + Sin[4*x] + Sin[4*y] == 4, {{x, -3, 3}, {y, -3, 3}}], 
       AccuracyGoal -> 4]]

I still get

{-1.90035, 0.230246}

Which makes no sense.

enter image description here


Edit

DescretizeRegion doesn't work without adding bounds {{-3,3},{-3,3}}

DiscretizeRegion[
 ImplicitRegion[
  x^2+y^2+Sin[4x]+Sin[4y]==4, {{x, -3, 3}, {y, -3, 3}}], {{-3, 
   3}, {-3, 3}}, AccuracyGoal -> 8]

enter image description here

This was presented in a previous question


However, with RegionCentroid I still get

{-1.90037, 0.230247}

$\endgroup$
7
  • 2
    $\begingroup$ Please only tag things [bugs] if they've been confirmed by WRI. It's a community standard, but makes our lives better. $\endgroup$
    – b3m2a1
    Jan 14 '18 at 0:30
  • $\begingroup$ Your AccuracyGoal is throwing things off. The curve is over-discretized. Drop it and it'll work for you. $\endgroup$
    – b3m2a1
    Jan 14 '18 at 0:36
  • $\begingroup$ I tried that but it didn't work. I get {-1.90035, 0.230246} $\endgroup$
    – Arbuja
    Jan 14 '18 at 0:38
  • 3
    $\begingroup$ Bug as heck - all proposed solutions, and the OP's code, work fine on v10.4; v11.1 messes things up. Adding the tag. $\endgroup$
    – corey979
    Jan 14 '18 at 6:58
  • 2
    $\begingroup$ I reproduce the issue with version 11.1.1 on Windows 7 x64. Version 10.4.1 and 11.2.0 produce the expected result: {-0.108616, -0.108616}. So the bug was introduced in version 11.1 and fixed in 11.2.0. Added the bug header. $\endgroup$ Jan 15 '18 at 0:53
5
$\begingroup$

DescretizeRegion works fine

I cannot reproduce this. To me, it seems that the bug lies clearly with the DiscretizeRegion function:

$Version
DiscretizeRegion[
 ImplicitRegion[
  x^2 + y^2 + Sin[4*x] + Sin[4*y] == 4, {{x, -3, 3}, {y, -3, 3}}]]
(* "11.1.1 for Mac OS X x86 (64-bit) (May 30, 2017)" *)

enter image description here

Given the above region, RegionCentroid is behaving properly,

Show[%, Graphics @ Point @ RegionCentroid@%]

enter image description here

On MacOS, this bug is fixed in version 11.2

$\endgroup$
4
  • $\begingroup$ Actually, with DescretizeRegion I added the bounds {{-3,3},{-3,3}] to DiscretizeRegion[ ImplicitRegion[ S16[x, y] == 0.4, {{x, -2.5, 1}, {y, -2.5, 2.5}}], {{-2.5, 1}, {-2.5, 2.5}}, AccuracyGoal -> 8] but with RegionCentroid this does not work. $\endgroup$
    – Arbuja
    Jan 14 '18 at 21:42
  • $\begingroup$ This was mentioned in my previous question $\endgroup$
    – Arbuja
    Jan 14 '18 at 21:44
  • $\begingroup$ Never mind, in my first comment, RegionCentroid does work but still gives the incorrect output. $\endgroup$
    – Arbuja
    Jan 14 '18 at 21:56
  • $\begingroup$ I get the correct output from your DescretizeRegion code with versions 10.0.1, 10.4.1, 11.1.1 and 11.2.0 on Windows 7 x64. The behavior seems to be platform-dependent. $\endgroup$ Jan 15 '18 at 0:46
3
$\begingroup$

Try <=4

    r = ImplicitRegion[x^2 + y^2 + Sin[4*x] + Sin[4*y] <= 4, {x, y}];
    center = RegionCentroid[DiscretizeRegion[r]];
    Show[RegionPlot[r, PlotRange -> {{-3, 3}, {-3, 3}}], Graphics[Point@center]]

center={-0.0848068, -0.084911}

enter image description here

$\endgroup$
5
  • $\begingroup$ Can you even reproduce the original issue? I can't. $\endgroup$
    – b3m2a1
    Jan 14 '18 at 0:44
  • $\begingroup$ Can you get the coordinates? $\endgroup$
    – Arbuja
    Jan 14 '18 at 0:46
  • $\begingroup$ coordinates is RegionCentroid[DiscretizeRegion[r]] $\endgroup$ Jan 14 '18 at 0:47
  • 1
    $\begingroup$ RegionCentroid[ DiscretizeRegion[ ImplicitRegion[ x^2 + y^2 + Sin[4*x] + Sin[4*y] == 4, {{x, -3, 3}, {y, -3, 3}}]]] produces {-1.89998, 0.230282} on my machine with MMA 11.1 $\endgroup$ Jan 14 '18 at 0:48
  • 1
    $\begingroup$ @OkkesDulgerci I get the same with version 11.1.1 on Windows 7 x64. Version 11.2.0 produces {-0.108357, -0.108372}. $\endgroup$ Jan 15 '18 at 0:56

Your Answer

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

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