polygon_average, a Python code which demonstrates a process of repeatedly averaging and normalizing the vertices of a polygon, illustrating a property of the power method.

The process can be analyzed in terms of the power method, and the eigenvalues of the matrix that carries out the averaging process.

A polygon is represented by a list of N vertices. An averaging step involves:

If the averaging process is carried out recursively, the resulting polygon rapidly converges to an ellipse at a 45 degree tilt.

The direction of the tilt, and the ratio between the major and minor axis lengths, vary depending on the initial polygon.


The computer code and data files made available on this web page are distributed under the MIT license


polygon_average is available in a MATLAB version and an Octave version and a Python version.

Related Data and Programs:

polygon, a Python code which carries out geometric calculations on polygons, including angles, area, centroid, containment of a point, diameter, integrals of monomials, convexity, distance to a point, sampling, triangulation.

power_method, a Python code which carries out the power method for finding a dominant eigenvalue and its eigenvector.


  1. Charles Van Loan, Daisy Fan,
    Insight Through Computing,
    SIAM Publishing, 2010,
    ISBN: 978-0-898716-91-7
  2. Adam Elmachtoub, Charles Van Loan,
    From Random Polygon to Ellipse: An Eigenanalysis,
    SIAM Review,
    Volume 52, Number 1, March 2010, pages 151-170.

Source Code:

Last revised on 02 September 2022.