What is the maximum number of regions produced, i.e. $f(n)$, by joining all vertexes with line segments of a convex polygon with $n$ sides? What is the maximum number of regions produced, i.e. $f(n)$, by joining all vertexes with line segments of a convex polygon with $n$ sides?




For example, for the hexagon on the left, number of regions is 24, but the one on right is 25, which I think is in fact $f(n)$ for the case $n=6$.

So is there any way to find the general equation for $f(n)$?

Thank you.
Let $v$ be the number of vertices, $e$ the number of edges and $f$ the number of faces (not counting the exterior of the given $n$-gon $P$) in the resulting configuration. Then by Euler's formula
$$v+f = e+1\ .$$
On the other hand the number of vertices is given by
$$v=n+{n\choose 4}\ ,$$
because any four vertices of $P$ determine a unique vertex in the interior of $P$. Finally the number of edges satisfies
$$2e=n(n-1)+4{n\choose 4}\ ,$$
because each vertex of $P$ has degree $n-1$ and each inner vertex has degree $4$.

Solving these three equations for $f$ we get
$$f={n(n-1)\over2}+2{n\choose 4}-n-{n\choose 4}+1={1\over24}(n^4-6n^3+23n^2-42n+24)\ .$$
The most convenient expression for f(n) is
f(n) = n(n-1)(n-2)(n-3)/24 + (n-1)(n-2)/2 which, of course, is f(n) for any irregular polygon with n sides (or any regular 'odd-sided' polygon}. For regular 'even-sided' polygons it is necessary to reduce the value given by f(n)
by counting the number of 6,8,10,12 ... nodes produced by the intersecting diagonals. For each 6-node the number of regions is reduced by one, for each
8-node by 3, each 10 node by 6, each 12 -node by 10 and so on in a triangle number sequence. For example, in an 18-sided regular polygon there are 216 6-nodes, 54 8-nodes, 54 10 nodes and one central 18-node ('hides' 28 regions). The f(n) value of 3196 is thus reduced by 730 to give the 'observed'(!) value of 2466.