Consider quadratic equations $Ax^2 + Bx + C = 0$ in which $A$, $B$, and $C$ are independently distributed $\mathsf{Unif}(0,1)$. What is the probability that the roots of such an equation are real?

This problem is from Chapter 3 of Rice: Mathematical Statistics and Data Analysis (editions 1 through 3). Until recent printings of 3e, the incorrect answer 1/9 was given for this problem.

However, Horton (2015) http://www3.amherst.edu/~nhorton/precursors/precursors.pdf points out that the correct answer is slightly above 1/4, as can be verified by a simple simulation. (Horton and his colleagues are concerned with elements of an undergraduate curriculum to prepare students in the mathematical sciences to cope with modern data science.)

In a somewhat more practical setting, one might consider a discrete version of this problem. A program that produces random drill problems on quadratic equations $Ax^2 + Bx + C = 0,$ selects values for $A, B,$ and $C$ at random and independently from among the ten equally likely values $0.1, 0.2, \dots, 1.0$. What proportion of such equations have real roots? And what proportion have only one root?

The initial Answer sketches the exact analytic solution of the original problem and shows numerical and graphical results from simulation. A simulated result for the discrete version is also shown.

Additional answers using other methods or discussing related topics are welcome.


3 Answers 3


If $B$ is uniformly distributed over $[0,1]$ and $X=B^2$, the pdf of $X$ can be computed through:

$$\mathbb{P}[X\leq t] = \mathbb{P}[B\leq\sqrt{t}], $$ from which $f_X(x)=\frac{\mathbb{1}_{(0,1)}(x)}{2\sqrt{x}}$. In a similar way, if $A,C$ are uniformly distributed over $(0,1)$, independent, and $Y=AC$, $$\mathbb{P}[Y\leq t]=\int_{0}^{1}\mathbb{P}\left[C\leq\frac{t}{u}\right]\,du=\int_{0}^{1}\min\left(1,\frac{t}{u}\right)\,du=t-t\log(t)$$ hence $f_Y(y) = -\mathbb{1}_{(0,1)}(y)\cdot\log(y)$. It follows that:

$$\mathbb{P}[B^2\geq 4AC] = \int_{0}^{1}\frac{1}{2\sqrt{x}}\int_{0}^{x/4}-\log(y)\,dy\,dx =\color{red}{\frac{5+6\log 2}{36}\approx 25,44\%}.$$

  • $\begingroup$ (5 + log(64))/36 and (5 + 6*log(2))/36 both give 0.2544134 $\endgroup$
    – BruceET
    Jan 10, 2016 at 22:29
  • 2
    $\begingroup$ @BruceET: no wonder, since $64=2^6$. $\endgroup$ Jan 10, 2016 at 22:35
  • 1
    $\begingroup$ Of course, just didn't want anyone to think there was a difference of opinion as to the correct answer. $\endgroup$
    – BruceET
    Jan 10, 2016 at 22:38

Sketch of analytic solution. An analytic solution is based on noting that the density of $Q = B^2$ is $f(q) = \frac{1}{2\sqrt{q}},$ for $q \in (0,1),$ the density of $X = 4AC$ is $g(x) = \frac{-\log(x/4)}{4},$ for $x \in (0,4).$

An appropriate double integration of the joint density $h(q, x) = f(q)g(x)$ gives $P(\text{Real Roots}) = P(Q > X) = \frac{5 + \log(64)}{36} = 0.254413.$ [Note: Details of the integration are shown in Horton (2015) referenced in the Question, and in a subsequent Answer.]

Simulation. A simulation based on a million simulated equations is shown below.

 m = 10^6
 a = runif(m);  b = runif(m);  c = runif(m) 
 q = b^2;  x = 4*a*c
 d = q - x    # discriminant
 real = (d > 0)
 ## 0.254302  # approximates analytic result

The following figure is based on 30,000 simulated equations. Histograms of simulated values of $Q$ and $X$ show the theoretical density curves. The brown lines in the scatterplot and histogram of values of the discriminant $D\,$ separate equations with real (blue) and complex solutions.

enter image description here

Alternate discrete version. The following simulation of the discrete version of the problem shows that a little over 20% of the computer generated quadratic equations have real roots.

 m = 10^6;  val=seq(.1, 1.0, by=.1)
 a = sample(val,m,rep=T)
 b = sample(val, m, rep=T)
 c = sample(val, m, rep=T)
 q = b^2;  x = 4*a*c
 d = q - x    # discriminant
 real = (d > 0)
 ## 0.206176
 single = (d == 0)
 ## 0.007964

The final result suggests that eight of the 1000 possible equations have only a single root. It is not difficult to see that the discriminant can be zero only if $B = .2, .4, .8,$ or $1.0$. From there, simple arithmetic shows that there are indeed eight possible combinations of values of $A$ and $C$ that produce $D = 0.$

A complete analytic solution to the discrete version would seem to involve some tedious bookkeeping, beginning with the ten possible values of $B^2.$ Perhaps there is a clever way to get an exact analytic solution using convolutions of discrete distributions in Matlab.


Someone asked almost this a few days ago. I did want to point out that a cube is not the most natural shape to consider for this problem, although it was the one chosen. Better, in some ways, to consider the ball $A^2 + B^2 + C^2 \leq R^2.$ In that case we take rotated coordinates $$ u = B; v = (A - C)/ \sqrt 2; w = (A + C)/ \sqrt 2. $$

Then the condition $B^2 \geq 4AC$ becomes $u^2 + 2 v^2 \geq 2 w^2.$ It makes no difference here whether we use volume or surface area, so we are asking for the total surface area of the two peculiar elliptical patches $u^2 + 2 v^2 \geq 2 w^2$ on the sphere $u^2 + v^2 + w^2 = 1,$ divided by $4 \pi.$ On second thought, the figure we want is one minus this, the funny annular region.

Not sure I know how to calculate this.

  • $\begingroup$ We can generate a random point $(u, v, w)$ on the sphere by taking $X, Y, Z$ independent random standard normals and then taking $(u, v, w) = (X, Y, Z)/\sqrt{X^2+Y^2+Z^2}$. I simulated $10^6$ points on the sphere and found that $351503$ of them had $u^2 + 2v^2 \le 2w^2$, so the probability is in the neighborhood of $0.352$. This hopefully helps confirm an analytic solution if someone attempts it. $\endgroup$ Jan 11, 2016 at 18:41
  • $\begingroup$ @MichaelLugo thank you $\endgroup$
    – Will Jagy
    Jan 11, 2016 at 19:38

Not the answer you're looking for? Browse other questions tagged .