Processing math: 100%

Sunday, November 10, 2024

Snoring while sorting

You are waiting in line to be sorted into one of the four houses of Logwarts (a posh wizarding boarding school in the Scottish highlands) by an anthropomorphic sorting hat. The hat is a bit of a snob about the whole matter, and refuses to sort two students in a row into the same house. If a student requests a certain house, but the previously sorted student was already sorted into that same house, then the hat chooses randomly from among the three remaining houses.

You are standing 10th in line, and you make plans to request Graphindor house for yourself. As for the other students in line, you can assume that they have random preferences from among the four houses. The first student steps up, and has a brief, quiet conversation with the hat. After a few moments, the hat proclaims, “Graphindor!” At this point, what is the probability that you will be sorted into Graphindor?

Let's define our probability space such that it will be useful for the this problem. Of course, as stated there are three other houses with fanciful names (perhaps Hufflepath, Ravenndiagram and Slytheorem), but as far as you're concerned it is Graphindor or bust, so luckily all of these outcomes are indistinguishable to you. Let pi,k be the probability that the ith wizardling on line is sorted into Graphindor, subject to the fact that the kth wizardling on line was the last one to actually be sorted to Graphindor.

As far as you are concerned, you get to Graphindor as long as the 9th wizard is not sorted there, since you will always ask the hat to sort you into Graphindor. So, given that the 1st wizardling on line was just sorted into Graphindor, the probability that you will be sorted into Graphindor is p=1p9,1. All that remains now is to divine what the formula for pi,k is anyway.

Let's say that we know pi,k for some 1ki. There are two ways for the (i+1)th wizardling to end up sorted into Graphindor: either (a) the ith wizard is sorted to some ``not Graphindor'' house and the (i+1)th wizardling requested Graphindor; or (b) the ith wizard is sorted to some ``not Graphindor'' house and the (i+1)th wizardling requested that same ``not Graphindor'' house. In both cases, the probability of event (a) is 1/4 while the probability of event (b) is 1/12=1/41/3. Putting these two together, we get the recursion relationship pi+1,k=14(1pi,k)+112(1pi,k)=1pi,k3,for ik1. By construction, we have pk,k=1, for each k1.

This recursive formula leads to the explicit formula pi,k=14(1+3(3)ki),for all ik1. We see that for i=k1 that we recover pk,k=14(1+3(3)0)=1, as our base case. If we assume that the formula holds for some ik1, then from the recursive formula we see that pi+1,k=1pi,k3=114(1+3(3)ki)3=3434(3)ki3=14(1+33(3)ki)=14(1+3(3)ki1), which follows formula for the case i+1. Thus by induction we have proven the formula. This therefore allows us to answer that if you are 10th in line and have resolved to request Graphindor no matter what that your probability of getting sorted into Graphindor after the first wizard is sorted into Graphindor is p=1p9=114(1+3(3)19)=3374=65608748=164021870.7498856882....

Now, instead of being 10th in line, suppose you are Nth in line, where N is some value much greater than 10. Because so many students are being sorted in front of you, you decide you’ll take a nap. You wake up without any idea of how long you were out—it could have been a second, or it could have been an hour, you’re just not sure. It’s still not your turn to be sorted yet, but you see a student wearing the hat. After a brief moment, the hat shouts, “Graphindor!”

What is the smallest value of N such that your probability of being sorted into Graphindor is greater than p? (To be clear, when you wake up, the student being sorted is anywhere from first in line to immediately before you in line with equal probability.)

OK, so now it becomes a little clearer why I chose such obscure nomenclature for the earlier problem. However, in this case where you are sitting at Nth in line and then dozed off only to wake up as the wizardling in uniformly randomly distributed position M is sorted into Graphindor, so we have the expected probability of being sorted into Graphindor is still dependent on whether or not the person immediately in front of you is sorted into Graphindor, that is q=1pN1,M. However, here since M is random we have q=1pN1,M=1N1i=1P{M=i}pN1,i=11N1N1i=114(1+3(3)iN+1)=343(3)1N4(N1)N1i=1(3)i=343(3)1N4(N1)(3)(3)N1(3)=34(19(3)N+34(N1))=3164N79(3)NN1 If we then want to know what is the minimal N such that q=q(N)>p=16402187, we need get a nonlinear, monotonically increasing equation that we can just as easily guess and check for a solution.

In particular, if we solve the approximation where we ignore that pesky exponential function and equally ignore the integrality of N, we get ˜q(x)=3(4x7)16(x1). If we were to solve ˜q(x)=3(4x7)16(x1)=p for a non-integer value of x, we get x=2116p1216p=196874=4921.75. This seems like a very good place to start hunting and pecking with N=x=4922. Let's first check ˜q(N)=3(449227)164921=59043787360.7498856939....., which is roughly 6×109 larger than p. Since 9(3)N109, we can confirm that N=4922 is the smallest integer value such that if you fell asleep and randomly woke up to some wizardling ahead of you in line is being sorted to Graphindor then your probability of also getting sorted to Graphindor is q(N)>p=16402187.

Monday, November 4, 2024

Is that what squaring the circle means?

A pseudo-square has the following properties:

  1. It is a simple, closed curve.
  2. It has four sides, all the same length.
  3. Each side is either a straight line segment or the arc of a circle.
  4. The four sides are joined at four corners, with each corner having an internal angle of 90 degrees or 270 degrees.

The pseudo-square pictured above has two straight sides, which run radially between arcs of two concentric circles. Assuming this is a unit pseudo-square (i.e., each side has length 1), what is its area?

As you can see, I've pre-doctored the image from the prompt with some parameters. Let r be the radius of the smaller circle and let θ be the angle inscribed between the two straight line edges. From here, if the shape is a unit pseudo-square then the larger radius is 1+r, so we can find the formula for the area of the shape in terms of r and θ, as A(r,θ)=πr2+12θ((1+r)2r2)=πr2+12θ(1+2r). That is all well and good, but we now have to find the particular value of r and theta that allow for this shape to be unit pseudo-square. In particular, the length of the arc on the larger of the two concentric circles is =θ(1+r). The length of the other arc is ˜=(2πθ)r. Since the shape is a unit pseudo-square we have the nonlinear system of equations θ(1+r)=1(2πθ)r=1. By setting θ=(1+r)1 and plugging into the second equation we get (2π11+r)r=1, which is equivalent to the quadratic equation 2πr2+2(π1)r1=0. Thus, if the shape is a unit pseudo-square then the smaller radius r is equal to r=1π+1+π22π.

By plugging θ=(1+r)1 into the area formula we get A(r)=πr2+1+2r2(1+r), so plugging in r from above we get the area of the unit psuedo-square with two straight lines is A=A(r)=π(1π+1+π22π)2+1+21π+1+π22π2(1+1π+1+π22π)=1+1+π22π0.683874197466......

Can you find a unit pseudo-square that has three curved sides and just one straight side? What is the area of your new unit pseudo-square?

Without loss of generality, we can assume that the one flat side is positioned along the bottom. We would need to have two curved sides connected to this flat bottom that curve towards each other, with there being a third circle that is tangent to the circular arcs. The resulting shape is sort of like the shape of some pawns in chess. See the figure below. We again insert some parameters. Let the flat side be the line segment from (12,0) to (12,0). Let the two symmetric sides attached to flat bottom be arcs of the circles centered at (a,0) and (a,0), respectively, each with radius a+12, with subtended angle θ. Let the final arc be from the circle centered (0,b) with radius r and subtended angle 2(πθ).

Let's first try to figure out how to quantify the area of the pseudo-square with three curved sides. The region denoted by B has area given by AB=12(πθ)r2. The region denoted by C has area given by AC=12r2tanθ. Finally, the region denoted by D has aread given by AD=12θ(a+12)212a2tanθ. The area of the entire pseudo-square with three curved sides is thus A=A(a,r,θ)=2(AB+AC+AD)=(πθ+tanθ)r2+θ(a+12)2a2tanθ.

With some creative trigonometry we can obtain r=r(a,θ), thus reducing the dimensions of the problem a smidge. The region denoted by C is a triangle whose height is r and base β, which is some portion of line segment of total length a+12, since that line segment is a radius of the circle centered at (a,0) of radius a+12. Since the line segment, negative x-axis and positive y-axis form a triangle, we can compute β as β=a+12asecθ. Since r=βcotθ, we have r=r(a,θ)=((a+12)asecθ)cotθ=(a+12)cosθasinθ. Therefore, we have A=A(a,θ)=(πθ+tanθ)((a+12)cosθasinθ)2+θ(a+12)2a2tanθ.

OK, now that that significantly more intricate foundational work is out of the way, we need to ensure that each of these curves sides is unit length. Since the more vertical arcs are symmetric, we only need to quantify =(a+12)θ and ˜=2(πθ)r, and set them both equal to 1 to obtain the nonlinear system of equations (a+12)θ=12(πθ)r=(πθ)(a+1/2)cosθasinθ=1 Solving for a in the second equation and then plugging back into the first we get sinθπ+θ2(πθ)(cosθ1)θ=1. This non-linear equation is solved with θ0.74960359... which leads to a=2θ2θ0.8340377... which ultimately leads to the area of a unit pseudo-square with three curved sides of A=A(a,θ)0.8317044...