Question comes from “Introduction to Probability” by Charles M. Grinstead.
Let \(U\) be a uniformly distributed random variable on \([0, 1]\). What is the probability that the equation:
\[ x^2 + 4Ux + 1 = 0 \]
has two distinct real roots \(x_1\) and \(x_2\)?
Solution:
The discriminant \(D\) of a quadratic can be used to determine the types of its roots, namely if \(D>0\) then we know that the quadratic has two distinct real roots. Given that \(D=b^2 - 4ac\):
\[ \begin{align} (4U)^2 - 4(1)(1) &> 0 \\ 16U^2 - 4 &> 0 \\ (4U^2 - 1) &> 0 \\ (2U + 1)(2U - 1) > 0 \end{align} \]
Thus we have that \(U>\frac{1}{2}\) or \(U<-\frac{1}{2}\). Given that \(U\) exists only on the range \([0, 1]\), we can say that the quadratic will have two real roots if \(U\) is in the range \((\frac{1}{2}, 1]\). Since this is exactly half the total range of \(U\), the probability of the quadratic having two distinct real roots is 0.5.
We can confirm this empirically via the following R code:
set.seed(seed = 1234)
sims <- 10000
Us <- runif(sims)
num_real_distinct <- 0
for (U in Us){
poly_coef <- c(1, 4 * U, 1)
roots <- polyroot(poly_coef)
check_z <- round(Im(roots[1]), 10) == 0 & round(Im(roots[1]), 10) == 0
check_distinct <- roots[1] != roots[2]
if (check_z & check_distinct){
num_real_distinct <- num_real_distinct + 1
}
}
table(Us > 0.5)
##
## FALSE TRUE
## 4990 5010
print(num_real_distinct/10000)
## [1] 0.501
Using 10,000 simulations, we get that the quadratic had two distinct, real solutions 50.1% of the time.