Wikipedia:Reference desk/Archives/Mathematics/2015 September 21

= September 21 =

Factoring without quadratic formula
Here's the problem,

(√2)x^2-4x+2√2=0

I tried squaring both sides and I got,

2x^4-16x^2+8=0

Then I took out a 2,

2(x^4-8x^2+4)=0

But I don't think I can factor any further without using the quadratic formula. Did I do this correctly? Is it possible to factor it nicely? ScienceApe (talk) 01:40, 21 September 2015 (UTC)


 * My gut feeling is to get everything in terms of root(2). So change 4 into 2 * 2 into root(2) * root(2) * root(2) * root(2)
 * (√2)x^2-4x+2√2=0
 * becomes
 * (√2)x^2 - (√2)*(√2)*(√2)*(√2) * x +  (√2)*(√2)*(√2) = 0
 * Next you can divide everything by (√2)
 * x^2 - (√2)*(√2)*(√2) * x +  (√2)*(√2) = 0
 * then use the Quadratic_equation — Preceding unsigned comment added by 175.45.116.61 (talk) 02:38, 21 September 2015 (UTC)
 * Next you can divide everything by (√2)
 * x^2 - (√2)*(√2)*(√2) * x +  (√2)*(√2) = 0
 * then use the Quadratic_equation — Preceding unsigned comment added by 175.45.116.61 (talk) 02:38, 21 September 2015 (UTC)
 * x^2 - (√2)*(√2)*(√2) * x +  (√2)*(√2) = 0
 * then use the Quadratic_equation — Preceding unsigned comment added by 175.45.116.61 (talk) 02:38, 21 September 2015 (UTC)
 * then use the Quadratic_equation — Preceding unsigned comment added by 175.45.116.61 (talk) 02:38, 21 September 2015 (UTC)

175.45.116.61 (talk) 02:29, 21 September 2015 (UTC)


 * (√2x-2)(x-√2)=0 ? Ssscienccce  (talk) 02:45, 21 September 2015 (UTC)


 * You did not perform your first operation correctly. You attempted to "square both sides", but you didn't properly square the left hand side. $$(a+b+c)^2 \neq a^2+b^2+c^2 $$. Put another way, $$(Ax^2+Bx+C)^2$$ has a term ABx^3 in it. So in your first step you're missing a few terms. If this were a binomial, you'd use the FOIL method. Since it's a trinomial, you just have to use the distributive property more carefully. SemanticMantis (talk) 03:42, 21 September 2015 (UTC)
 * It's 2ABx&sup3;, not ABx&sup3;. (There are two terms ABx&sup3; that get added.) --174.88.134.156 (talk) 01:25, 23 September 2015 (UTC)
 * Just divide everything by $$\sqrt{2}$$ at the beginning, i.e., $$x^2-2\sqrt{2}x+2=0$$. This factors into $$(x-\sqrt{2})^2=0$$, etc. -- Kinu  t/c 03:53, 21 September 2015 (UTC)
 * I don't understand how does dividing -4x by $$\sqrt{2}$$ equal -2sqrt(2x)?ScienceApe (talk) 00:46, 22 September 2015 (UTC)
 * Note (with the negative and x omitted) that $$\dfrac{4}{\sqrt 2} = \dfrac{4}{\sqrt 2}\cdot\dfrac{\sqrt 2}{\sqrt 2} = \dfrac{4 \sqrt 2}{2} = 2\sqrt 2$$. -- Kinu  t/c 15:24, 22 September 2015 (UTC)
 * The technique of Completing the square comes to mind. Bubba73 You talkin' to me? 05:15, 21 September 2015 (UTC)
 * I tried completing the square. My final answer is 2/2√2 +- √(2-2√2/√2). It doesn't look right to me. :( ScienceApe (talk) 18:12, 21 September 2015 (UTC)
 * - yes, you can tell that solution is incorrect by substituting in to the original equation, and seeing that you don't get zero. Take IP 175's and Kinu's advice aboce - take the original equation, multiply both sides by root two. Then divide both sides by two. You should be left with $$x^2-2\sqrt{2}x+2=0$$. When you complete the square, you'll see that this happens to be a perfect square, so there's no extra constant term. You can check your factorization on wolfram alpha, like so  or like so . Does that make sense now? SemanticMantis (talk) 18:53, 21 September 2015 (UTC)

I tried dividing everything by sqrt(2). I got x^2-(4x/sqrt2)+2=0. I then found the square which is (x-2/sqrt(2))^2=0. I then took the square root of both sides and ended up with x-2/sqrt(2)=0 and then x=2/sqrt(2), but I know this is wrong. The right answer is sqrt(2), what did I do wrong? *edit* Wait I just realized 2/sqrt(2) simplifies to sqrt(2). ScienceApe (talk) 01:09, 22 September 2015 (UTC)

Electric field between a round pipe and a larger rectangular pipe co-axial with the round pipe :2
I asked this question recently (now expired), and Ruslik_Zero responded with a website explaining electrostatics. However the website assumed a level of speciallised math knowlege I don't have, and it didn't cover the case I'm interested in.

I need a formula for calculating the electric field (volts per metre) just outside a round pipe located coaxially inside a larger rectangular section pipe. Let's say the radius of the inner round pipe is r metres, the inside dimensions of the square section pipe is m metres and n metres. There is a voltage y volts imposed between the round pipe and the square pipe.

Intuitively, providing the diameter of the round inner pipe is small compared to the rectangular pipe dimensions, the electric field close to the round inner pipe will be evenly distributed around it.

I have consulted a number of books on electrostatics. They all give a formula for a round outer pipe ( Er1 = y / [r1 Ln(r2/r1)] ) but none that I have found analyse the case of a rectangular outer pipe. 124.178.180.54 (talk) 02:50, 21 September 2015 (UTC)
 * Not really my area of expertise but if no one else is going to answer I might as well at least try to explain why it's not a simple problem. The basic idea is to find a non-constant harmonic function (the potential) on the rectangle minus the origin which is constant on the boundary. Turns out it's much easier to do this for a circle than a square, in other words there is a nice, simple function which works for the circle, but rectangles require a lot more work, which is why textbooks normally don't do rectangles. The standard method of solution, afaik, is to apply a Schwarz–Christoffel mapping which maps the region in question (the rectangle) to a half plane. For rectangles you get an elliptic integral, so not an elementary function. On top of that, the integral is actually the inverse of the function you need. This is where elliptic functions come in but it's going to be hard to understand what these are without some understanding of the theory of functions of complex variables. You mentioned 'specialized math' but much of the reason this math was invented was to answer exactly the kind of question you're asking. --RDBury (talk) 00:30, 22 September 2015 (UTC)


 * Ah, right. What I call the school teacher effect - what goes in the textbooks is what can be easily derived, and thus easy to teach, not necessarily what is actually useful in the real world!  Rectangular boundaries (boxes, enclosures) are everywhere.
 * But, surely, there is a formula? Something with sinh's and cosh's in it?  Even if it is only an approximation? 121.215.27.68 (talk) 07:31, 22 September 2015 (UTC)


 * What do you mean by "close to the round inner pipe"? Within a certain range, or do you simply care about the maximum gradient? If you only want to know whether the maximum field gradient stays below some value, then you can simply use the formula, using the worst case scenario (replace the rectangle with an inscribed circle). The field will indeed be homogeneous (very) close to the inner pipe, it can't be otherwise (assuming the pipe is really round). Ssscienccce.
 * The field is maximum where the field "flux" is most concentrated, and it's most concentrated at the surface of the smallest conductor i.e., the small round pipe. That's where I want to calculate the field. 121.215.27.68 (talk) 07:53, 22 September 2015 (UTC)
 * For a square, distance from center to corner will be √2 longer than from center to side. Ln(√2) = 0.346, result becomes: Er1=y/r1(0.346 + Ln(r2/r1)). Depending on r2/r1, this may be an acceptable error margin. Ssscienccce.
 * Intuitively, I don't think that's right. Electric flux will concentrate at the nearest part of the outer pipe i.e., the middle of the wider sides.  Just as most current finds the shortest path.  But it's not a situation where half the flux lands at the middle and half at the corners. 121.215.27.68 (talk) 07:53, 22 September 2015 (UTC)
 * ?? I didn't say it did. You say you want the gradient at the surface at the small conductor, I say if you replace the rectangle with an inscribing circle, you get an upper limit for that value. And if you assume an outside circle, the formula will give you a lower limit. The real value will be somewhere in between. I'm not saying half the current will land at the corners?! You only want to know it at the inner conductor. And for that it doesn't matter where on the outer conductor the field lines will be concentrated. Your inner conductor is round, it is an equipotential surface, the field lines are perpendicular to the surface and the field strength is the same all around.
 * Look at the image on the Equipotential page, the distance between equipotential lines (surfaces) indicates the voltage gradient. closer together means higher gradient. For the equipotential lines around the "+", it's clear that at greater distance, the gradient drops much more rapidly above the + than below it, but close to the surface of the +, the gradient wil be the same in all directions. Ssscienccce  (talk) 10:00, 22 September 2015 (UTC)
 * That doesn't seem terribly useful. A typical rectangular pipe/enclosure might have cross section dimensions m & n where m = 2 to 3 times n.  So the outside circle is approx 2.2 to 3.1 times the size of the inscribed circle.  So the electric field strength for the limit circles varies in the same ratio. A formula that is accurate to 1 or 2 percent would be nice. 121.215.27.68 (talk) 15:24, 22 September 2015 (UTC)
 * It's not arbitrary. Scribe a circle with the same perimeter as the rectangle and solve for static field. The sum total is equal by Gauss Law.  Once you have the field it's a matter of apportioning it.  the rectangle will have a stronger gradient at perpendicular and falls off as the hypotenuse changes and is weaker at the corner.  You only have to integrate along the short edge followed by the long edge.  The integral has to equal the equivalent perimeter circle. -DHeyward (talk)


 * Must say I'm a bit curious about the purpose.  Ssscienccce  (talk) 07:20, 22 September 2015 (UTC)
 * Round enclosures of things that are hot (electrically or thermally) are very common. So are rectangular enclosures.
 * I know, but electric field strength wouldn't be a concern to me, unless I was dealing with several thousand volts. Ssscienccce  (talk) 10:00, 22 September 2015 (UTC)


 * It's electrostatics so I think the only difference is that field varies because the distance varies. You can first calculate the field as if the surrounding square pipe were round with perimeter 2m+2n. Guass' law says this same perimeter contains the same field regardless of shape. So now you have the total field. That must equal the sum of the four triangles created by the vertices of the rectangle (draw an X). The field will be split by the ratio of the triangles perimeter. It will vary in strength with the radial angle to edge of the rectangle pipe. Now that solution is for the inner pipe having no radius. But because it is round, the change in radial distance varies by the radius of the pipe and is constant subtraction so it just subtracts from the calculated hypotenuse distance. A circle inside a square not as hard as square inside a square. I hate wikimath so I hope that helps. I think the key is calculate it as a circle for the outer structure with equivalent perimeter and then using gauss law to equate them. Symmetry and ratios then give enough to solve the square. You end up solving $$ -\int_a^b{\vec{E}\cdot \mathrm{d}\vec \ell} = \phi(\vec a).$$ using E from the solved circular case and using the ratios and symmetry. $$\ell$$ is the distance that changes with angle and $$\phi(\vec a)$$ is the voltage. In the circular case, $$\ell$$ is constant so solve for E. In the rectangle case, E is the same as round case, and $$\ell$$ varies along perimeter. Superposition allows the solving for different sides and summing. --DHeyward (talk) 08:27, 22 September 2015 (UTC)


 * This situation can be estimated via the method of images. The interior electric field will be approximately the same as the electric field near a central cylinder with no box but surrounded by eight other cylinders of varying charges / voltages.  For example:

+        -          +       -         +          -        +         -          +


 * If the surrounding box you want to estimate is m x n, the surrounding cylinders should be placed to cover a space of 2m x 2n. Then one just has to do the vector superposition of the nine fields.  The solution is still only approximate, but should be pretty good close to the inner cylinder.  Dragons flight (talk) 16:28, 22 September 2015 (UTC)
 * Would not the approximation be more correctly done with just four image cylinders? One reflection for each of the four sides of the rectangular enclosure? Would not adding four more off each corner almost double the apparent central field strength? Texbooks on electrostatics usually give a formula for the field abutting on a round pipe between two parallel plates.  One could calaculate the field from superimposing that for two parallel vertical plates and two horizontal plates.  But if the rectangular enclosure is actually square (m = n), there will be serious error?  Intuitively, a square enclosure will result in a field only slightly less intense than that of an inscribed round enclosure (diameter = m = n).124.178.79.198 (talk) 01:26, 23 September 2015 (UTC)
 * The images contribute nothing at all to the field at the exact center, since equal fields in opposite directions will cancel. However, having the corner images provides a more accurate field in the vicinity of the box corners.  Actually you can be even more accurate by extending the images to a larger lattice.  Dragons flight (talk) 07:18, 23 September 2015 (UTC)
 * I don't follow that. Let's say the central round pipe is positive with respect to the rectangular enclosure.  Clearly the field is most intense where it impinges on the round pipe's surface.  To use the method of images, all the images/reflections are positive.  Supeimposing x many positives (at the centre) just makes a composite positive. 1.122.73.59 (talk) 08:47, 23 September 2015 (UTC)
 * Fields have both intensity and direction. In the above configuration, at the center (0, 0), the field from the image at (n, 0) is equal in magnitude but opposite in direction to the field from the image at (-n, 0).  Hence those contributions cancel at the exact center.  Similar cancellation happens for other opposing pairs of images and the images contribute nothing at the exact center.  Obviously they contribute more as you move away from that exact center, but you still expect only small corrections near the surface of the round pipe.  Dragons flight (talk) 09:11, 23 September 2015 (UTC)
 * Er... The field intensity is maximum at the surface of the inner pipe.  After all, the electric flux emerges from the round pipe due to the charge on it, concentrated due to the samll circumference. This isn't changed by making the inner pipe smaller and smaller in diameter.  That seems at odds with your view that the field is zero at thecentre. 1.122.59.34 (talk) 13:09, 23 September 2015 (UTC)
 * You misunderstand. I am saying the field from the image charges is zero at the center, which implies the field near the center is nearly identical to that of the pipe by itself (with no box).  This is spelled out more concretely below.  Dragons flight (talk) 13:55, 23 September 2015 (UTC)
 * If I recall, images are valid only when the plane approaches infinity (effectively when the field falls off relative to closest point). You really can solve it with second circular pipe with radius R=(2m+2n)/2*pi.  That gives you the field that is relatively easy to solve.  With the field solved, you can integrate over each side of the rectangle.  The integral of the rectangle must equal the integral of the circle. --DHeyward (talk)


 * The method of images is exact for an infinite plane. They can be a useful approximation for other cases.  Dragons flight (talk) 07:18, 23 September 2015 (UTC)
 * Yes, I see that. And that trucating the infinite planes to the length of the long ans short sides of the rectangular enclosure results in an error.  The question is: how much error, approximately?  for a range of rectangular dimensions restricted to what is commonly encountered (say m = n to m = 4n) can a simple correction factor be applied? 1.122.73.59 (talk) 08:47, 23 September 2015 (UTC)

see Gaussian surface and scroll to infinitely long cylinder. --DHeyward (talk) 04:05, 23 September 2015 (UTC)

Using the method of images, outlined above, let's say that the center is (0,0), the dimensions n x m, and the radius of the inner pipe $$r_0$$. For simplicity, let's say the electric field at the surface of a similarly large cylinder in isolation is $$E_0$$, which implies it has an electric field $$\vec E = E_0 {r_0 \over r} \hat r$$. I get that the magnitude of the electric field at (x, 0) over the range r <= x <= n/2 is:


 * $$E(x,0) = E_0 {r_0 \over x} + E_0 {r_0 \over n-x} - E_0 {r_0 \over n + x} - 2 E_0 {r_0 \over \sqrt{x^2 + m^2}}{x \over \sqrt{x^2 +m^2}} - 2 E_0 {r_0 \over \sqrt{(n-x)^2+m^2}}{n-x \over \sqrt{(n-x)^2 + m^2}} + 2 E_0 {r_0 \over \sqrt{(n+x)^2 + m^2}}{n+x \over \sqrt{(n+x)^2 + m^2}}$$
 * $$= E_0 {r_0 \over x} \left( 1 + {2x^2 \over n^2+x^2} - {2x^2 \over m^2 + x^2} + {2 x (n+x) \over (n+x)^2 + m^2} - {2 x (n-x) \over (n-x)^2 + m^2} \right) $$

By swapping n and m, you can of course also estimate the field on the y-axis. Dragons flight (talk) 10:09, 23 September 2015 (UTC)

Probability that at most n distinct choices are made among m independent choices, given the probability distribution of choices
I need a formula for the probability that at most n distinct choices are made among m independent choices, given that the probability distribution of the choices is described by an inverse power law.

Say a restaurant offers N items on its menu. The popularity of the items can be described using an inverse power law: the probability of the i-th most popular item being picked by a customer is $$p\cdot r^{(i-1)}$$. During the lunch hour of a given day, m customers choose from the menu independently. What is the probability that at most n distinct choices are made?

Thanks.

--134.242.92.2 (talk) 16:14, 21 September 2015 (UTC)

First step. The total probability that the customer choses an item is
 * $$1=p\cdot (1+r+r^2+\cdots + r^{N-1})=p\cdot(1-r)^{-1}(1-r^N)$$

so the normalizing factor is
 * $$p=(1-r^N)^{-1}(1-r)$$

and the probability of the i-th most popular item being picked by a customer is
 * $$(1-r^N)^{-1}(r^{i-1}-r^i)$$ for $$i=1, 2,\cdots, N$$

Second step. With N items and m costumers each chosing one item there are $$N^m$$ possible outcomes:
 * $$i=(i_1, i_2, \cdots, i_m)$$

Assuming that the costumers choose independently, the probability that the outcome is i is the product
 * $$(1-r^N)^{-m}\prod_{k=1}^m (r^{i_k-1}-r^{i_k})$$

Third step. The number of times item number v was chosen is
 * $$\sum _{k=1}^m [i_k=v]$$

where the Iverson bracket is: [true]=1 and [false]=0.

The number of distinct choises in outcome i is
 * $$\sum _{v=1}^N \left[ 0<\sum _{k=1}^m [i_k=v] \right] $$

The probability that at most n distinct choices are made
 * $$(1-r^N)^{-m} \sum_i \left(\prod_{k=1}^m (r^{i_k-1}-r^{i_k})\right) \cdot [ n \ge \sum_{v=1}^N \left[ 0 < \sum_{k=1}^m [i_k=v] \right] ] $$

where the outer summation is over all possible outcomes i.

That's all, I guess. Bo Jacoby (talk) 18:29, 21 September 2015 (UTC).


 * Encoding a description of the desired value as a formula is not the hard part. What I need is a formula that can be evaluated efficiently to give the answer. Can you help with the latter?
 * (Edited to add) BTW, your expression for the number of distinct choices in i doesn't look right.
 * --134.242.92.2 (talk) 18:50, 21 September 2015 (UTC)

I corrected an error before I read your comment. I hope it looks right now. Bo Jacoby (talk) 19:21, 21 September 2015 (UTC).

The formula is programmed and tested like this: p=. 3 : 0 'N m n r'=.y  y=.|:(m#N)#:i.N^m n=.n>:+/|:0<+/y=/i.N n=.+/n**/(r^y)*1-r n%m^~1-r^N )  p 4 5 0 0.5 0   p 4 5 1 0.5 0.0445432   p 4 5 2 0.5 0.462716   p 4 5 3 0.5 0.924148   p 4 5 4 0.5 1 Bo Jacoby (talk) 01:30, 22 September 2015 (UTC).
 * Thanks. The type of solution I'm looking for is a closed formula, but you got me curious about the code. What language is it in? --134.242.92.2 (talk) 13:34, 22 September 2015 (UTC)


 * Depending on the application, it may be useful to note that the probability can be bounded. The probability P of m customers selecting at most n items from menu of N items must be greater than $$P_a^m$$ where $$P_a$$ is the maximum sum of probabilities achieved by choosing n distinct items.  In your case, with $$p_i = r^{i-1}{1-r \over 1-r^N}$$, that gives


 * $$P_a = \sum_{i=1}^n r^{i-1}{1-r \over 1-r^N} = {1-r^n \over 1-r^N}$$


 * So, $$P \ge \left({1-r^n \over 1-r^N}\right)^m$$. In practice, that might not be a very useful constraint, but since you haven't said the application, I'm not sure if it is or isn't useful.  Dragons flight (talk) 12:45, 22 September 2015 (UTC)


 * For the example given by Bo Jacoby above:


 * n = 0: $$P \ge \left({1-r^0 \over 1-r^4}\right)^5 = 0$$
 * n = 1: $$P \ge \left({1-r^1 \over 1-r^4}\right)^5 \approx 0.043$$
 * n = 2: $$P \ge \left({1-r^2 \over 1-r^4}\right)^5 \approx 0.33$$
 * n = 3: $$P \ge \left({1-r^3 \over 1-r^4}\right)^5 \approx 0.71$$
 * n = 4: $$P \ge \left({1-r^4 \over 1-r^4}\right)^5 = 1$$


 * Dragons flight (talk) 12:45, 22 September 2015 (UTC)


 * I got an inkling that generating functions might help solve the problem analytically in this case. Can someone adept with them offer some help? --134.242.92.2 (talk) 13:49, 22 September 2015 (UTC)

I used the programming language J. That is convenient for lazy programmers who do not want to write big programs in order to solve small problems. Why do you think that the solution is not a closed formula? Bo Jacoby (talk) 15:30, 22 September 2015 (UTC).

The formula
 * $$\sum_{i=0}^{N-1}r^i=(1-r)^{-1}(1-r^N)$$

is no good for r = 1. So the first step above was not a good idea. Omitting it makes the program even smaller. p =. 3 : 0 'N m n r'=.y  y=.|:(m#N)#:i.N^m +/(n>:+/|:0<+/y=/N)**/y{(%+/)r^N=.i.N ) Bo Jacoby (talk) 23:27, 24 September 2015 (UTC).
 * For the benefit of those who are not familiar with J, could you explain how the program encodes the logic for computing the answer? Thanks. --134.242.92.2 (talk) 13:43, 25 September 2015 (UTC)

Here are the intermediate results. 'N m n r'=.4 5 3 2 N 4 m 5 n 3 r 2 N^m 1024  m#N 4 4 4 4 4  $(m#N)#:i.N^m NB. All outcomes. 1024 rows, 5 columns 1024 5  $|:(m#N)#:i.N^m NB. Transpose. 5 rows, 1024 columns 5 1024  y=.|:(m#N)#:i.N^m NB. remember under the name y  30{."1 y NB. display 30 outcomes 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3 0 0 0 0 1 1 1 1 2 2 2 2 3 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1   N=.i.N NB. reusing letter N.   N NB. value of the new N  0 1 2 3   r^N NB. powers 1 2 4 8   +/r^N NB. sum of powers 15   (%+/)r^N NB. Probabilities: divide (%) by the sum (+/) 0.0666667 0.133333 0.266667 0.533333   x:(%+/)r^N NB. display as fractions 1r15 2r15 4r15 8r15   $y{(%+/)r^N NB. 2D probability matrix 5 1024   x:12{."1 y{(%+/)r^N NB. show the first 12 outcomes as fractions 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 1r15 2r15 2r15 2r15 2r15 4r15 4r15 4r15 4r15 1r15 2r15 4r15 8r15 1r15 2r15 4r15 8r15 1r15 2r15 4r15 8r15 x:8{.*/y{(%+/)r^N NB. Multiply. Show 8 results. 1r759375 2r759375 4r759375 8r759375 2r759375 4r759375 8r759375 16r759375 +/*/y{(%+/)r^N NB. Check that the probability sum is unity 1  $y=/N NB. 3D boolean matrix 5 1024 4  $+/y=/N NB. 2D integer matrix 1024 4  $0<+/y=/N NB. 2D boolean matrix 1024 4   $|:0<+/y=/N NB. transpose 4 1024  $+/|:0<+/y=/N NB. counting distinct choices 1024  30{.+/|:0<+/y=/N NB. showing 30 elements 1 2 2 2 2 2 3 3 2 3 2 3 2 3 3 2 2 2 3 3 2 2 3 3 3 3 3 4 3 3  $n>:+/|:0<+/y=/N NB. is the number of choices <= n? 1024 30{.n>:+/|:0<+/y=/N NB. showing 30 answers 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1  +/n>:+/|:0<+/y=/N NB. number of outcomes <=n 784  $(n>:+/|:0<+/y=/N)**/y{(%+/)r^N NB. 1024 probabilities 1024  +/(n>:+/|:0<+/y=/N)**/y{(%+/)r^N NB. total probability 0.924148  p 4 5 3 2 NB. Summary 0.924148  p 4 5 3 2x NB. exact fraction 3119r3375

Bo Jacoby (talk) 21:43, 25 September 2015 (UTC).
 * By the way, what does the program look like in your favorite programming language? Bo Jacoby (talk) 06:28, 27 September 2015 (UTC).