You have a set of shapes:
Figure 1: Square
Figure 2: Pentagon
Figure 3: Hexagon
Figure 4: Heptagon
Figure 5: ...
And so on. For each of these shapes, each corner point has a line connecting to every other corner point. You are counting the number of intersection points where lines meet/cross. This includes the outline.
Data set I have so far:
X Y
1 | 5
2 | 10
3 | 19
4 | 41
5 | 54
I asked my teacher and he said he had no idea. I would love any help.
For shapes with an even number of sides, you have to worry about parallel lines, so I am ignoring that case for the time being. Supposing the number of sides $n$ is odd (corresponding to $x=2,4,\dots$ from your dataset), supposing the number of sides $n$ is at least $5$, and supposing we are talking about regular polygons, one way to proceed is as follows:
First we count the total number of lines being drawn. Consider $n=5$ as a simple example. There are five vertices, and call them $A,B,C,D,E$. The possible lines being drawn are extensions of the line segments:
AB AC AD AE
BC BD BE
CD CE
DE
Giving us a total of $4+3+2+1=10$ total lines. Call this number $N$. Note that $N$ is a triangular number equal to $\frac{n(n-1)}{2}$. This pattern can be shown to continue for larger $n$.
The next step is to count the total number of intersections of these lines. None of the lines are parallel, so any two different lines intersect. Some might have the same intersection points, but we will still count the total number of intersections, and then later subtract any which we counted more than once.
Counting the total number of intersections works similarly to counting the total number of lines. Just like we "paired points" together to "create" lines before, we can "pair lines" together to "create" intersection points, and we will have the triangular number $\frac{N(N-1)}{2}$ total intersection points.
We overcounted though. Each vertex of the regular polygon has $n-1$ lines passing through it, yielding the triangular number $m=\frac{(n-1)((n-1)-1)}{2}$ intersections we counted which all yield that vertex, so $m-1$ of those were extra for each vertex, so we overcounted by at least $n(m-1)$ vertices.
Since for odd $n\geq5$ no two pairs of lines intersect at the same place other than a vertex, we haven't overcounted by anything more, and we have
\begin{align*} \frac{N(N-1)}{2}-n(m-1)&=\frac{\left(\frac{n(n-1)}{2}\right)\left(\left(\frac{n(n-1)}{2}\right)-1\right)}{2}-n\left(\left(\frac{(n-1)((n-1)-1)}{2}\right)-1\right)\\ &=\frac{1}{8}n(n^3-6n^2+11n+2)\\ \end{align*}
distinct intersection points.
Notice this number does not agree with your dataset. For example, when $n=5$, the function yields $20$. This is because not all lines intersect inside or on the regular polygon (and I assume you gathered your data by counting intersection points in complete $k$-graphs).
A reasonable question then is, how many pairs intersect on the outside of the regular polygon? For the pentagon, this can be reasoned to be $10$ with an accurate drawing, yielding $20-10=10$ distinct intersection points on the complete $5$-graph, as you already found with $x=2$. For larger $n$ though, drawing a representative picture will not suffice. I haven't yet figured out an easy way to count these "outer" intersections, though this ought to serve as a good starting point for you.