Keith, Very interesting! I will have to study your message carefully, but I just wanted to mention something Ed Pegg pointed out. Sylvester looked at this question, see https://mathworld.wolfram.com/SylvestersFour-PointProblem.html For a square, his theorem is that the prob. of getting a convex quadrilateral is 25/36 , which is exactly the value you found! On Sun, Jun 28, 2020 at 11:05 AM Keith F. Lynch <kfl@keithlynch.net> wrote:
Neil Sloane <njasloane@gmail.com> wrote:
If we take an m X n rectangular grid of points, and choose four of them (in binomial(m*n,4) ways), there are four possibilities:
(i) the 4 points are collinear, (ii) 3 points are collinear and one point is not on that line, (iii) 3 points form a triangle of positive area and the other point is in the interior of that triangle, (iv) the 4 points form a convex quadrilateral of nonzero area.
. . .
Which is more likely, (iii) or (iv)?
This inspired me to look at the limiting case where m and n are large. Your i and ii disappear. The values of iii and iv don't depend on the aspect ratio of the rectangle.
I'm not smart enough to find a closed-form solution. (Is one known?)
I generated 64 billion (pseudo-)random sets of four points in a square, using Unix's "random()" function, which generates 31-bit integers. Since that function repeats after about 2^35 (about 34 billion), after every 2 billion sets (16 billion random numbers), I exclusive-ored every random() with a different row of an order-32 Hadamard matrix (with the -1s turned into 0s, and the first column (which was all 1s) stripped off). Every one of the 32 rows differs in exactly 16 bit positions from every other of the 32 rows. I was amused, when I went searching for Hadamard matrices, that I found a table of them on your website.
So, how do I determine, given the x and y coordinates of four points, whether they form a convex quadrilateral or not? After some thought, I decided to check, for every one of the six line segments between two of the four points, whether it intersects the unique other segment which has no endpoints in common with it. If they intersect, it's a convex quadrilateral. If they don't, it's a triangle with a point inside. That's 3 checks, not 6, since if I know whether A intersects B, I don't need to check whether B intersects A.
I get triangles 0.305556 of the time, and convex quadrilaterals 0.694444 of the time. (The last digit may be off by 1.)
In 193 of the 64 billion cases, one of the lines was vertical, and my program divided by zero. To speed things up, I didn't bother to special-case that, or even to figure out what the program would do there, since whatever it did would be lost in the noise, changing at worst the 9th digit of a 6 digit number.
I also checked for parallel lines, the other possible source for division by zero. But there were never any parallel lines.
But wait, there's more!
If the four points happened to all be within the circle inscribed in the square, I also used them to find the solution for a circle instead of a rectangle. This time I got a triangle 0.295517 of the time, and a convex quadrilateral 0.704483 of the time. (Again, the last digit may be off by 1.) This was from 24352319646 circles, compared to an expected (pi/4)^4 * 64 billion = 24352272758 circles. Those numbers agree to six digits, or two parts in a million, which gives me confidence in the random number generator.
But wait, there's more!
That was so much fun, I decided to go one better. *Five* points. There are three non-infinitesimal possibilities: A triangle with two points in it, a convex quadrilateral with one point in it, or a convex pentagon.
With that many points per set, the program was generating random numbers like they were going out of style. So I used a new row of the Hadamard matrix every billion sets, for a total of just 32 billion sets. Nevertheless, with the additional computation per set, the program took longer to run than the 4-point program.
Again, I counted intersections between line segments which didn't share any endpoint. This time there were 15, rather than 3, such tests to be made per set. If there's 1 intersection, it's a triangle with two points in it. If there are 3 intersections, it's a convex quadrilateral with one point in it. It there are 5 intersections, it's a convex pentagon. There is never any other number of intersections.
This time there were 165 vertical lines. Still no parallel lines.
And here are the results:
Triangle: 0.104167 Quadrilateral: 0.555559 Pentagon: 0.340274
That's within a rectangular boundary. Here are the results for a circular boundary:
Triangle: 0.094992 Quadrilateral: 0.548827 Pentagon: 0.356181
That's with 9563216295 circles, vs. an expected (pi/4)^5 * 32 billion = 9563115149 circles, the same to within about 10 parts in a million.
Higher polygons? The number of pairs of segments which share no endpoints seems to be given by A050534, with an offset. So, 45 for six points, 105 for seven, etc.
What's the limiting case? For N points, where N is large, just how unlikely is it that they comprise a convex N-gon? And what's the expected order of the bounding polygon? Does it scale with the square root of N? With the natural log of N? Has anyone explored this stuff? Thanks.
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun