Saturday, January 27, 2024

How many diagonals does a polygon have?

I came across another problem I never learned how to solve... how many diagonals does a 13-gon have?

Geez, I nerver learned the formula of how many diagonals in a polygon, let's see if I can derive on the fly.. Start with the triangle. nope, no diagonals. The square: 2. The pentagon: 5. The hexagon: 9. It is kinda hard to draw and count bigger ones. So I have a f(3)=0, f(4)=2, f(5)=5, f(6)=9.. and yikes I can't easily obsere a pattern and derive this formula on the fly.

But I kinda observe, something to do with n-2... because can't connect a point to its neighbors and call it diagonal... and sadly I have to give up and look the formula up. Yes I admit.

And it takes I think a bit genius to reach this observation:

The nunber of diagonals is simply number of segments connecting every pair of points, EXCEPT the edges of the polygon.

So it is the Combination n choose 2, minus n: nC2 - n

    n! 
---------  - n
 2! (n-2)!


  n (n-1)
= ------- - n
    2

= n^2-n - 2n
  ----------
     2

= n^2 - 3n
  --------
     2
     
= n(n-3)
  ------
    2
So there are 13(13-3)/2 = 65 diagonals for the 13-gon.

This formula n(n-3)/2 I'd keep it in my treasure chest where I put other not-so-obvious formulas like volumne/surface area of a sphere, volume of a pyramid, etc.

Waita minute, although my initial observation is not going anywhere but somewhat of a good start. For each point on the polygon, do not count the 2 neighbors including the point itself, so n-3 diagonals for each point. Go around each point of the polygon, so it is n(n-3), but by that time you would have counted twice the number of diagonals, so divide by 2. There you are: n(n-3)/2.