$a$, $b$, $c$ are random integer numbers between $1$ and $100$ (including $1$ and $100$, and uniformly distributed). What is the probability that the equation $ax^2 + bx + c = 0$ has real solutions?

This is from a final high school math exam, and I don't know how to get the answer without using computer.

  • 1
    $\begingroup$ Ohh, $0.249222$ ? A really weird number, but close to $1/4$. $\endgroup$ – Alexey Burdin May 20 '15 at 21:09
  • 1
    $\begingroup$ Yeah, I got the same with a quick Python script, but there is no way students could do this without a computer. Maybe there is a neat argument that it is close to 1/4, but then it probably is way too hard for a high school exam. $\endgroup$ – Lukas Geyer May 20 '15 at 21:22
  • $\begingroup$ @AlexeyBurdin Are you sure your number is correct, because there are $100^3$ values for $a,b,c$, how can it be a repeating decimal $\endgroup$ – qwr May 20 '15 at 21:34
  • $\begingroup$ @qwr No repeating, sum (1 for a in xrange(1,101) for b in xrange(1,101) for c in xrange(1,101) if b*b-4*a*c>=0), 249222 $\endgroup$ – Alexey Burdin May 20 '15 at 21:35
  • $\begingroup$ @AlexeyBurdin ah, ok $\endgroup$ – qwr May 20 '15 at 21:37

Interesting question. What kind of class was this?

We can approximate this in the continuous case by letting $(a, b, c)$ reside in the open unit cube in the positive octant. Given any value of $b$ in the interval $(0, 1)$, the allowable values of $(a, c)$ are those in the region of the first-quadrant unit square "inside" the curve $4ac = b^2$. The area of this region is

$$ \frac{b^2}{4} + 2\int_{a=b/2}^1 \frac{b^2}{4a} \, da = \frac{b^2}{4}-\frac{b^2}{2}\ln\frac{b}{2} $$

We can then integrate this area over $b \in (0, 1)$:

$$ P = \int_{b=0}^1 \left( \frac{b^2}{4}-\frac{b^2}{2} \ln \frac{b}{2} \right)\,db = \left. \frac{5b^3}{36}-\frac{b^3}{6}\ln\frac{b}{2} \right]_{b=0}^1 = \frac{5+6\ln 2}{36} \doteq 0.25441 $$

But I'm not sure how you get this in the discrete case without some extensive counting.

  • $\begingroup$ This has to be the best way to do it! Your result should be the exact answer if the numbers are drawn from $\{1,2,\ldots, n\}$ in the limit $n\to \infty$. $\endgroup$ – Winther May 21 '15 at 0:29

The only way I can think of doing it, short of doing a numerical simulation, may be approximating it with a triple integral, i.e. approximating this probability by the probability that the quadratic has solutions if a, b, and c can take any real values between 1 and 100: $$\int_1^{100}\int_1^{100}\int_1^{\frac{b^2}{4a}}\frac{1}{99^3}\,dc\,da\,db=\frac{\int_1^{100}\int_1^{100}(\frac{b^2}{4a}-1)da\,db\,}{99^3}=\frac{\int_1^{100}(\frac{b^2}{4}\ln(100)-99)\,db}{99^3}=\frac{\frac{\ln(100)}{12}(100^3-1)-99^2}{99^3}\approx0.374$$ where $\frac{1}{99^3}\,dc\,da\,db$ is the probability that the point $(a,b,c)$ is in a box with side lengths da, db, and dc.

  • $\begingroup$ you're counting too much volume, e.g. $b=100,a=1\Rightarrow c=2500>100$ $\endgroup$ – yoyo May 20 '15 at 23:28
  • $\begingroup$ @yoyo Oh, you're right. I just tried setting up the correct integral, by making the upper bound $max(\frac{b^2}{4a},100)$, and it becomes much more complicated; you have to integrate $b^2 ln(b)$ by parts at some point. $\endgroup$ – Keshav Srinivasan May 21 '15 at 1:37

To get a real solution, the discriminant $b^2-4ac\geq0$, so $b\geq 2 \sqrt{ac}$, and $\frac{b^2}{4}\geq ac$. All of our variables are real so there is no need to consider negatives.

Values of $a$ and $b$ can range from $1$ to $n$. The probability of each separate combination is $\frac{1}{n}*\frac{1}{n}$. Considering each combination of $a$ and $b$ separately:

The number of values for $c$ that will give a real solution is $\bigg\lfloor \lfloor \frac{b^2}{4} \rfloor / a \bigg\rfloor$ (restricted to less than 100), so the probability that a random $c$ will give a real solution is $\bigg\lfloor \lfloor \frac{b^2}{4} \rfloor / a \bigg\rfloor * \frac{1}{n}$.

The probability that a random $a$ and random $c$ will give a real solution is $\bigg\lfloor \lfloor \frac{b^2}{4} \rfloor / a \bigg\rfloor * \frac{1}{n} * \frac{1}{n}$.

So, for each possible value of $b$, the probability of a real solution existing is $\frac{1}{n^2}\sum_{a=1}^{n} \bigg\lfloor \lfloor \frac{b^2}{4} \rfloor / a \bigg\rfloor$.

Then, for all possible values of b, the probability of a real solution existing is $\frac{1}{n^3}\sum_{b=1}^{100}\sum_{a=1}^{100} \bigg\lfloor \lfloor \frac{b^2}{4} \rfloor / a \bigg\rfloor$.

I calculated this in Excel for $n=100$ and also got $0.249222$ as did several commenters. I do not see how one would be expected to do this by hand. There is no immediately obvious pattern. Perhaps trying smaller $n$ might offer insight.


protected by Community Jul 16 '15 at 6:53

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.