Unexpected behavior of the procedure `Area` on the object 'Polygon' The Next CEO of Stack OverflowHow to ContourPlot a Table?Unexpected behavior of Unevaluatedis there a way to construct a pattern that would trigger when an expression is used as a held/unevaluated in some form?How to copy text from InputField without adding spurious spaces?many indefinite integrals do not evaluate in 10.1, looking for the causeWhat is the difference between GenerateDocument and TemplateApply[NotebookTemplate[Comparing exact expressions for equality — is it really OK if I get wrong answer?Simple arithmetic with Irrationals failsFinding area of intersection regionsWhy Area give the wrong results when the region cannot be formed?

Grabbing quick drinks

Why do remote companies require working in the US?

Clustering points and summing up attributes per cluster in QGIS

India just shot down a satellite from the ground. At what altitude range is the resulting debris field?

Is a stroke of luck acceptable after a series of unfavorable events?

Is HostGator storing my password in plaintext?

Would a galaxy be visible from outside, but nearby?

How do you know when two objects are so called entangled?

I believe this to be a fraud - hired, then asked to cash check and send cash as Bitcoin

What can we do to stop prior company from asking us questions?

Why is there a PLL in CPU?

How to Reset Passwords on Multiple Websites Easily?

Robert Sheckley short story about vacation spots being overwhelmed

How to safely derail a train during transit?

Only print output after finding pattern

Would this house-rule that treats advantage as a +1 to the roll instead (and disadvantage as -1) and allows them to stack be balanced?

How long to clear the 'suck zone' of a turbofan after start is initiated?

What does this shorthand mean?

How to write papers efficiently when English isn't my first language?

If/When UK leaves the EU, can a future goverment do a referendum to join EU

How to be diplomatic in refusing to write code that breaches the privacy of our users

What is the difference between Sanyaas and Vairagya?

Increase performance creating Mandelbrot set in python

What is the purpose of the Evocation wizard's Potent Cantrip feature?



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



The Next CEO of Stack OverflowHow to ContourPlot a Table?Unexpected behavior of Unevaluatedis there a way to construct a pattern that would trigger when an expression is used as a held/unevaluated in some form?How to copy text from InputField without adding spurious spaces?many indefinite integrals do not evaluate in 10.1, looking for the causeWhat is the difference between GenerateDocument and TemplateApply[NotebookTemplate[Comparing exact expressions for equality — is it really OK if I get wrong answer?Simple arithmetic with Irrationals failsFinding area of intersection regionsWhy Area give the wrong results when the region cannot be formed?










10












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







  • 4




    $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
















10












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







  • 4




    $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














10












10








10





$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 Mar 22 at 17:18









kirma

10.2k13058




10.2k13058










asked Mar 22 at 14:22









Slepecky MamutSlepecky Mamut

635111




635111







  • 4




    $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













  • 4




    $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








4




4




$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


















9












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




















    7












    $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









      9












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

















        9












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















          9












          9








          9





          $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 Mar 22 at 17:02

























          answered Mar 22 at 16:23









          kirmakirma

          10.2k13058




          10.2k13058





















              7












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

















                7












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















                  7












                  7








                  7





                  $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 Mar 22 at 16:49









                  Carl WollCarl Woll

                  71.9k395186




                  71.9k395186



























                      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

                      Adding axes to figuresAdding axes labels to LaTeX figuresLaTeX equivalent of ConTeXt buffersRotate a node but not its content: the case of the ellipse decorationHow to define the default vertical distance between nodes?TikZ scaling graphic and adjust node position and keep font sizeNumerical conditional within tikz keys?adding axes to shapesAlign axes across subfiguresAdding figures with a certain orderLine up nested tikz enviroments or how to get rid of themAdding axes labels to LaTeX figures

                      Tähtien Talli Jäsenet | Lähteet | NavigointivalikkoSuomen Hippos – Tähtien Talli

                      Do these cracks on my tires look bad? The Next CEO of Stack OverflowDry rot tire should I replace?Having to replace tiresFishtailed so easily? Bad tires? ABS?Filling the tires with something other than air, to avoid puncture hassles?Used Michelin tires safe to install?Do these tyre cracks necessitate replacement?Rumbling noise: tires or mechanicalIs it possible to fix noisy feathered tires?Are bad winter tires still better than summer tires in winter?Torque converter failure - Related to replacing only 2 tires?Why use snow tires on all 4 wheels on 2-wheel-drive cars?