Unexpected behavior of the procedure `Area` on the object 'Polygon'












9












$begingroup$


Sometimes get a results, sometimes left unevaluated.



For instance



 Area@Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}] 



12




Transpose@(a.b.Transpose[#]) & /@ Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}] 


(a,b - some 2x2 matrices)




Polygon[{{0, 0}, {8, -64}, {18, -24}, {36, -48}, {28, 16}}]




Area@(Transpose@(a.b.Transpose[#]) & /@ Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}] )



Area[Polygon[{{0, 0}, {8, -64}, {18, -24}, {36, -48}, {28, 16}}]]




Area@Polygon[{{0, 0}, {8, -64}, {18, -24}, {36, -48}, {28, 16}}]


(copy and paste)




1440




How to guess when a calculation will give a result and when it will not be evaluated? And why does it not evaluate?










share|improve this question











$endgroup$








  • 3




    $begingroup$
    What are the definitions of a and b?
    $endgroup$
    – MarcoB
    Mar 22 at 14:36










  • $begingroup$
    If you want to experiment with this and I haven't made a mistake then it looks like his a.b == {{2,7},{-16,4}} This seems to reproduce his results.
    $endgroup$
    – Bill
    Mar 22 at 16:15


















9












$begingroup$


Sometimes get a results, sometimes left unevaluated.



For instance



 Area@Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}] 



12




Transpose@(a.b.Transpose[#]) & /@ Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}] 


(a,b - some 2x2 matrices)




Polygon[{{0, 0}, {8, -64}, {18, -24}, {36, -48}, {28, 16}}]




Area@(Transpose@(a.b.Transpose[#]) & /@ Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}] )



Area[Polygon[{{0, 0}, {8, -64}, {18, -24}, {36, -48}, {28, 16}}]]




Area@Polygon[{{0, 0}, {8, -64}, {18, -24}, {36, -48}, {28, 16}}]


(copy and paste)




1440




How to guess when a calculation will give a result and when it will not be evaluated? And why does it not evaluate?










share|improve this question











$endgroup$








  • 3




    $begingroup$
    What are the definitions of a and b?
    $endgroup$
    – MarcoB
    Mar 22 at 14:36










  • $begingroup$
    If you want to experiment with this and I haven't made a mistake then it looks like his a.b == {{2,7},{-16,4}} This seems to reproduce his results.
    $endgroup$
    – Bill
    Mar 22 at 16:15
















9












9








9





$begingroup$


Sometimes get a results, sometimes left unevaluated.



For instance



 Area@Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}] 



12




Transpose@(a.b.Transpose[#]) & /@ Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}] 


(a,b - some 2x2 matrices)




Polygon[{{0, 0}, {8, -64}, {18, -24}, {36, -48}, {28, 16}}]




Area@(Transpose@(a.b.Transpose[#]) & /@ Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}] )



Area[Polygon[{{0, 0}, {8, -64}, {18, -24}, {36, -48}, {28, 16}}]]




Area@Polygon[{{0, 0}, {8, -64}, {18, -24}, {36, -48}, {28, 16}}]


(copy and paste)




1440




How to guess when a calculation will give a result and when it will not be evaluated? And why does it not evaluate?










share|improve this question











$endgroup$




Sometimes get a results, sometimes left unevaluated.



For instance



 Area@Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}] 



12




Transpose@(a.b.Transpose[#]) & /@ Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}] 


(a,b - some 2x2 matrices)




Polygon[{{0, 0}, {8, -64}, {18, -24}, {36, -48}, {28, 16}}]




Area@(Transpose@(a.b.Transpose[#]) & /@ Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}] )



Area[Polygon[{{0, 0}, {8, -64}, {18, -24}, {36, -48}, {28, 16}}]]




Area@Polygon[{{0, 0}, {8, -64}, {18, -24}, {36, -48}, {28, 16}}]


(copy and paste)




1440




How to guess when a calculation will give a result and when it will not be evaluated? And why does it not evaluate?







bugs evaluation computational-geometry polygons packed-arrays






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago









kirma

10.2k13058




10.2k13058










asked Mar 22 at 14:22









Slepecky MamutSlepecky Mamut

630110




630110








  • 3




    $begingroup$
    What are the definitions of a and b?
    $endgroup$
    – MarcoB
    Mar 22 at 14:36










  • $begingroup$
    If you want to experiment with this and I haven't made a mistake then it looks like his a.b == {{2,7},{-16,4}} This seems to reproduce his results.
    $endgroup$
    – Bill
    Mar 22 at 16:15
















  • 3




    $begingroup$
    What are the definitions of a and b?
    $endgroup$
    – MarcoB
    Mar 22 at 14:36










  • $begingroup$
    If you want to experiment with this and I haven't made a mistake then it looks like his a.b == {{2,7},{-16,4}} This seems to reproduce his results.
    $endgroup$
    – Bill
    Mar 22 at 16:15










3




3




$begingroup$
What are the definitions of a and b?
$endgroup$
– MarcoB
Mar 22 at 14:36




$begingroup$
What are the definitions of a and b?
$endgroup$
– MarcoB
Mar 22 at 14:36












$begingroup$
If you want to experiment with this and I haven't made a mistake then it looks like his a.b == {{2,7},{-16,4}} This seems to reproduce his results.
$endgroup$
– Bill
Mar 22 at 16:15






$begingroup$
If you want to experiment with this and I haven't made a mistake then it looks like his a.b == {{2,7},{-16,4}} This seems to reproduce his results.
$endgroup$
– Bill
Mar 22 at 16:15












2 Answers
2






active

oldest

votes


















8












$begingroup$

EDIT: Reported to WRI as CASE:4237867 - and apparently should work on V12. :)



Seems like a bug in my opinion. Consider the following:



With[{poly0 = Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]}, 
With[{poly = Transpose[IdentityMatrix[2].Transpose@#] & /@ poly0},
{poly0 === poly, Area /@ {poly0, poly}}]]



{True, {12, Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]}}




Although the Mma considers poly0 and its transformed but identical copy (coordinates transformed using IdentityMatrix) identical, they produce different results.



Probably the internal representation of poly is not the same as poly0. At the same time its output form is identical, which actually transforms it to other form if you copy and paste it.



This can be further simplified to show that from the perspective of Polygon two semantically identical coordinate lists can differ:



With[{coord0 = {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}}, 
With[{coord = Transpose[IdentityMatrix[2].Transpose@coord0]},
{coord0 === coord, Area@*Polygon /@ {coord0, coord}}]]



{True, {12, Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]}}




I suspect there's something wrong with the way Polygon reads the internal representation of a list!



EDIT: I think there's a good chance this problem is caused by the fact coord is a packed array, while coord0 is not:



With[{coord0 = {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}}, 
With[{coord = Transpose[IdentityMatrix[2].Transpose@coord0]},
{coord0 === coord, Developer`PackedArrayQ /@ {coord0, coord},
Area@*Polygon /@ {coord0, Developer`FromPackedArray@coord}}]]



{True, {False, True}, {12, 12}}




So, you can use FromPackedArray on the transformed coordinate list as a workaround.






share|improve this answer











$endgroup$





















    6












    $begingroup$

    This is a packed array issue:



    Area @ Polygon[Developer`ToPackedArray @ {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]



    Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]




    This will be fixed in M12.






    share|improve this answer









    $endgroup$













      Your Answer





      StackExchange.ifUsing("editor", function () {
      return StackExchange.using("mathjaxEditing", function () {
      StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
      StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
      });
      });
      }, "mathjax-editing");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "387"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f193772%2funexpected-behavior-of-the-procedure-area-on-the-object-polygon%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      8












      $begingroup$

      EDIT: Reported to WRI as CASE:4237867 - and apparently should work on V12. :)



      Seems like a bug in my opinion. Consider the following:



      With[{poly0 = Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]}, 
      With[{poly = Transpose[IdentityMatrix[2].Transpose@#] & /@ poly0},
      {poly0 === poly, Area /@ {poly0, poly}}]]



      {True, {12, Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]}}




      Although the Mma considers poly0 and its transformed but identical copy (coordinates transformed using IdentityMatrix) identical, they produce different results.



      Probably the internal representation of poly is not the same as poly0. At the same time its output form is identical, which actually transforms it to other form if you copy and paste it.



      This can be further simplified to show that from the perspective of Polygon two semantically identical coordinate lists can differ:



      With[{coord0 = {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}}, 
      With[{coord = Transpose[IdentityMatrix[2].Transpose@coord0]},
      {coord0 === coord, Area@*Polygon /@ {coord0, coord}}]]



      {True, {12, Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]}}




      I suspect there's something wrong with the way Polygon reads the internal representation of a list!



      EDIT: I think there's a good chance this problem is caused by the fact coord is a packed array, while coord0 is not:



      With[{coord0 = {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}}, 
      With[{coord = Transpose[IdentityMatrix[2].Transpose@coord0]},
      {coord0 === coord, Developer`PackedArrayQ /@ {coord0, coord},
      Area@*Polygon /@ {coord0, Developer`FromPackedArray@coord}}]]



      {True, {False, True}, {12, 12}}




      So, you can use FromPackedArray on the transformed coordinate list as a workaround.






      share|improve this answer











      $endgroup$


















        8












        $begingroup$

        EDIT: Reported to WRI as CASE:4237867 - and apparently should work on V12. :)



        Seems like a bug in my opinion. Consider the following:



        With[{poly0 = Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]}, 
        With[{poly = Transpose[IdentityMatrix[2].Transpose@#] & /@ poly0},
        {poly0 === poly, Area /@ {poly0, poly}}]]



        {True, {12, Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]}}




        Although the Mma considers poly0 and its transformed but identical copy (coordinates transformed using IdentityMatrix) identical, they produce different results.



        Probably the internal representation of poly is not the same as poly0. At the same time its output form is identical, which actually transforms it to other form if you copy and paste it.



        This can be further simplified to show that from the perspective of Polygon two semantically identical coordinate lists can differ:



        With[{coord0 = {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}}, 
        With[{coord = Transpose[IdentityMatrix[2].Transpose@coord0]},
        {coord0 === coord, Area@*Polygon /@ {coord0, coord}}]]



        {True, {12, Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]}}




        I suspect there's something wrong with the way Polygon reads the internal representation of a list!



        EDIT: I think there's a good chance this problem is caused by the fact coord is a packed array, while coord0 is not:



        With[{coord0 = {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}}, 
        With[{coord = Transpose[IdentityMatrix[2].Transpose@coord0]},
        {coord0 === coord, Developer`PackedArrayQ /@ {coord0, coord},
        Area@*Polygon /@ {coord0, Developer`FromPackedArray@coord}}]]



        {True, {False, True}, {12, 12}}




        So, you can use FromPackedArray on the transformed coordinate list as a workaround.






        share|improve this answer











        $endgroup$
















          8












          8








          8





          $begingroup$

          EDIT: Reported to WRI as CASE:4237867 - and apparently should work on V12. :)



          Seems like a bug in my opinion. Consider the following:



          With[{poly0 = Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]}, 
          With[{poly = Transpose[IdentityMatrix[2].Transpose@#] & /@ poly0},
          {poly0 === poly, Area /@ {poly0, poly}}]]



          {True, {12, Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]}}




          Although the Mma considers poly0 and its transformed but identical copy (coordinates transformed using IdentityMatrix) identical, they produce different results.



          Probably the internal representation of poly is not the same as poly0. At the same time its output form is identical, which actually transforms it to other form if you copy and paste it.



          This can be further simplified to show that from the perspective of Polygon two semantically identical coordinate lists can differ:



          With[{coord0 = {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}}, 
          With[{coord = Transpose[IdentityMatrix[2].Transpose@coord0]},
          {coord0 === coord, Area@*Polygon /@ {coord0, coord}}]]



          {True, {12, Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]}}




          I suspect there's something wrong with the way Polygon reads the internal representation of a list!



          EDIT: I think there's a good chance this problem is caused by the fact coord is a packed array, while coord0 is not:



          With[{coord0 = {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}}, 
          With[{coord = Transpose[IdentityMatrix[2].Transpose@coord0]},
          {coord0 === coord, Developer`PackedArrayQ /@ {coord0, coord},
          Area@*Polygon /@ {coord0, Developer`FromPackedArray@coord}}]]



          {True, {False, True}, {12, 12}}




          So, you can use FromPackedArray on the transformed coordinate list as a workaround.






          share|improve this answer











          $endgroup$



          EDIT: Reported to WRI as CASE:4237867 - and apparently should work on V12. :)



          Seems like a bug in my opinion. Consider the following:



          With[{poly0 = Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]}, 
          With[{poly = Transpose[IdentityMatrix[2].Transpose@#] & /@ poly0},
          {poly0 === poly, Area /@ {poly0, poly}}]]



          {True, {12, Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]}}




          Although the Mma considers poly0 and its transformed but identical copy (coordinates transformed using IdentityMatrix) identical, they produce different results.



          Probably the internal representation of poly is not the same as poly0. At the same time its output form is identical, which actually transforms it to other form if you copy and paste it.



          This can be further simplified to show that from the perspective of Polygon two semantically identical coordinate lists can differ:



          With[{coord0 = {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}}, 
          With[{coord = Transpose[IdentityMatrix[2].Transpose@coord0]},
          {coord0 === coord, Area@*Polygon /@ {coord0, coord}}]]



          {True, {12, Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]}}




          I suspect there's something wrong with the way Polygon reads the internal representation of a list!



          EDIT: I think there's a good chance this problem is caused by the fact coord is a packed array, while coord0 is not:



          With[{coord0 = {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}}, 
          With[{coord = Transpose[IdentityMatrix[2].Transpose@coord0]},
          {coord0 === coord, Developer`PackedArrayQ /@ {coord0, coord},
          Area@*Polygon /@ {coord0, Developer`FromPackedArray@coord}}]]



          {True, {False, True}, {12, 12}}




          So, you can use FromPackedArray on the transformed coordinate list as a workaround.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 2 days ago

























          answered 2 days ago









          kirmakirma

          10.2k13058




          10.2k13058























              6












              $begingroup$

              This is a packed array issue:



              Area @ Polygon[Developer`ToPackedArray @ {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]



              Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]




              This will be fixed in M12.






              share|improve this answer









              $endgroup$


















                6












                $begingroup$

                This is a packed array issue:



                Area @ Polygon[Developer`ToPackedArray @ {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]



                Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]




                This will be fixed in M12.






                share|improve this answer









                $endgroup$
















                  6












                  6








                  6





                  $begingroup$

                  This is a packed array issue:



                  Area @ Polygon[Developer`ToPackedArray @ {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]



                  Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]




                  This will be fixed in M12.






                  share|improve this answer









                  $endgroup$



                  This is a packed array issue:



                  Area @ Polygon[Developer`ToPackedArray @ {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]



                  Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]




                  This will be fixed in M12.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 2 days ago









                  Carl WollCarl Woll

                  71.5k394186




                  71.5k394186






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Mathematica Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      Use MathJax to format equations. MathJax reference.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f193772%2funexpected-behavior-of-the-procedure-area-on-the-object-polygon%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      He _____ here since 1970 . Answer needed [closed]What does “since he was so high” mean?Meaning of “catch birds for”?How do I ensure “since” takes the meaning I want?“Who cares here” meaningWhat does “right round toward” mean?the time tense (had now been detected)What does the phrase “ring around the roses” mean here?Correct usage of “visited upon”Meaning of “foiled rail sabotage bid”It was the third time I had gone to Rome or It is the third time I had been to Rome

                      Bunad

                      Færeyskur hestur Heimild | Tengill | Tilvísanir | LeiðsagnarvalRossið - síða um færeyska hrossið á færeyskuGott ár hjá færeyska hestinum