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












7












$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
    13 hours ago










  • $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
    12 hours ago


















7












$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
    13 hours ago










  • $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
    12 hours ago
















7












7








7





$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 11 hours ago









kirma

10.2k13058




10.2k13058










asked 14 hours ago









Slepecky MamutSlepecky Mamut

618110




618110








  • 3




    $begingroup$
    What are the definitions of a and b?
    $endgroup$
    – MarcoB
    13 hours ago










  • $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
    12 hours ago
















  • 3




    $begingroup$
    What are the definitions of a and b?
    $endgroup$
    – MarcoB
    13 hours ago










  • $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
    12 hours ago










3




3




$begingroup$
What are the definitions of a and b?
$endgroup$
– MarcoB
13 hours ago




$begingroup$
What are the definitions of a and b?
$endgroup$
– MarcoB
13 hours ago












$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
12 hours ago






$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
12 hours ago












2 Answers
2






active

oldest

votes


















6












$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$





















    4












    $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









      6












      $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$

        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












          6








          6





          $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 11 hours ago

























          answered 12 hours ago









          kirmakirma

          10.2k13058




          10.2k13058























              4












              $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$


















                4












                $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$
















                  4












                  4








                  4





                  $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 11 hours ago









                  Carl WollCarl Woll

                  71.2k394185




                  71.2k394185






























                      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

                      How to make a Squid Proxy server?

                      Is this a new Fibonacci Identity?

                      19世紀