A very useful procedure to find the area of ​​any irregular polygon is through the Gauss determinant.

It involves drawing the figure on a Cartesian plane, setting the coordinates of each of the vertices of the polygon.

Drawing of the choice and enumeration of the irregular pentagon points for the Gauss determinant.

Any of them is chosen at random and the pairs are placed in the following formula. The polygon must be traversed counterclockwise, taking into account that the first pair of coordinates corresponds to the chosen vertex and, after traveling all the vertices counterclockwise, the last pair must be the initial torque


Let the vertices of the polygon be: (x1, y1), (x2, y2), ..., (xN, yN). The formula is as follows:


Formula of the irregular polygon area using the Gauss Determinant

Solving it by the known procedure, we will have quickly found the area of ​​the irregular polygon.

This method is applicable to any polygon with any number of sides, both in the case of concave and convex polygons.

My question is how can I create a script that asks me a) Number of Vertices (n) b) Ask me to enter the n points between those n vertices that is $$(x_1, y_1)$$ $$(x_2, y_2)$$ ........................ $$(x_n, y_n)$$ c) Can calculate the area given the formula stated

n = Input["Number of Vertices", n] (Input (x1,y1) ,(x2,y2).....(xn,yn)) ?? ?? A=(1/2)det[x1,y1) ,(x2,y2).....(xn,yn] ???

can you help me ? , I searched the forum but I can't find any example that I can adapt


1 Answer 1


What you describe is known as the shoelace formula. It has previously been implemented by J.M. here.

I can find no way to improve on J.M.'s implementation, so I will simply repeat it:

pts = CirclePoints[6];
area = Total[Det /@ Partition[pts, 2, 1, 1]]/2

(3 Sqrt[3])/2


(3 Sqrt[3])/2

Another implementation is provided by Chip Hurst here. A 3D version of the shoelace formula can be found here, by george2079.

  • $\begingroup$ @ C.E. thank Hello I tried to run this code that you indicated mathematica.stackexchange.com/a/181526/731 (the one with the green ticket) without results, it marks me in red "Multicells" (I have math 11.3), you would be so kind to check why it doesn't work for me, maybe with a tiny example $\endgroup$
    – wally
    Commented Oct 17, 2019 at 0:31
  • $\begingroup$ First of all, the link that you mention does not indicate the answer with the green tick. It specifically references the answer by Chip Hurst and I also mention him by name in my answer. Second, that Multicells is colored red in notebook input cells does not mean that it doesn't work. It does work, but it's an undocumented option. $\endgroup$
    – C. E.
    Commented Oct 17, 2019 at 4:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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