# Distribution of quadratic equation roots where coefficients are generated uniformly

We draw two points $p$ and $q$ at random from the interval $[−1, 1]$.

Let $x_1$ and $x_2$ denote the roots of the equation $x^2 + px + q = 0$.

Find the probability that, $x_1, x_2 \in \mathbb{R}$,

Given that, $x^2 + px + q = 0$, $\Delta = p^2-4q$.

$x_1, x_2 \in \Bbb R \Rightarrow \Delta \ge 0$

$\Omega = [-1, 1]^2 = \{(p,q) \in \Bbb R^2: p,q \in [-1,1]\}$

$A$ = roots exist.

$A = \{(p,q) \in [-1,1]^2 : p^2 -4q \ge 0 \}$

$x^2 - 4y \ge 0$

$y \le \frac{x^2}{4}$

$\Bbb P(A) = \frac{area-under-the-parabola}{4} = \frac{2 + 2 \cdot half-of-parabola }{4}$

$= \frac{1}{2} + \frac{1}{2} \cdot \int_{0}^{1}\frac{x^2}{4}\, dx$

$= \frac{13}{24}$

I have several questions regarding the aforementioned solution,

1. How did the author of the solution know that the parabola passing through the center of the axes and is situated at the positive side of the x-axis?

2. How was the area between the half of the parabola and the x axis calculated?

3. What was the mistake with this solution?

• please add the self-study tag and read its tag-wiki, if necessary modifying the question to follow the guidelines there. Oct 15, 2016 at 2:54
• Closely related: stats.stackexchange.com/questions/25661.
– whuber
Oct 15, 2016 at 16:43
• What do you mean by the "second method of solution"?
– whuber
Oct 24, 2016 at 12:51
• @whuber, quora.com/… Oct 24, 2016 at 17:40

There are two steps in any question of this nature: (1) find a useful way to characterize the event and (2) compute the probability of this event (in general, by integrating a probability density over it). When the probability is uniform, the integral is proportional to the area of the event.

I wish to emphasize the technique. It includes

• Drawing a picture of the event to keep focused on the key ideas.

• Minimizing the calculations performed.

• Delaying calculation as much as possible until the end, in the hope of simplification along the way.

### 1. Find a useful characterization of the event.

You need to relate the roots $$x_1, x_2$$ to the coefficients $$p$$ and $$q$$. That is done by comparing coefficients in the expansion

$$x^2 - (x_1+x_2) x + x_1 x_2 = (x-x_1)(x-x_2) = x^2 + px + q,$$

whence

$$p=-(x_1+x_2).\tag{1}$$

By completing the square you can establish a criterion for both roots to be real:

$$x^2 + px + q = (x - p/2)^2 + q - p^2/4 = \frac{4q - p^2}{4}.$$ This is zero if and only if

$$(x-p/2)^2 = \frac{p^2 - 4q}{4}.\tag{2}$$

Since the left hand side, which is a square of a real number when the roots are real, is non-negative, and all non-negative numbers have real square roots, both roots are real if and only if the right hand side is non-negative. Equivalently, its numerator must be non-negative.

We can now characterize the event of the problem in directly in terms of $$p$$ and $$q$$:

1. From $$(2)$$, both roots are real if and only if $$p^2 - 4q \ge 0$$.

2. From $$(1)$$, their sum $$x_1+x_2$$ is less than $$1$$ if and only if $$-p = x_1+x_2 \lt 1$$; more simply, $$p \gt -1$$.

Here is the graph of the set determined by (1) and (2). It is the blue region, including all portions of its boundary except a vertical line segment along the left side.

### 2. Find the probability of the event.

In this figure, which uses $$(p,q)$$ for coordinates, the probability is uniform. That means the probability of any event is its relative area. The total area of the square is $$4$$, while the area of the event itself is the area between the parabola $$q = p^2/4$$ and the line $$q=-1$$, from $$p=-1$$ to $$p=1$$. This area is

$$A = \int_{-1}^1 (p^2/4 - (-1)) dp = \frac{1}{4}\int_{-1}^1 p^2 dp + \int_{-1}^1 dp = \frac{1}{4}\left(\frac{p^3}{3}\big|_{-1}^1\right) + p\big|_{-1}^1=\frac{1}{6}+2.$$

Therefore the probability is

$$\Pr\left(x_1,x_2\in\mathbb{R},\ x_1+x_2\lt 1\right) = \Pr\left(p^2-4q \ge 0,\ -p \lt 1\right) = \frac{A}{4}=\frac{\frac{1}{6} + 2}{4} = \frac{13}{24}.$$

This value, which is slightly greater than $$12/24=1/2$$, is consistent with the visual impression from the picture that the blue area slightly exceeds $$1/2$$.

Incidentally, one mistake in the posted solution occurred at the very last line: the lower limit of integration over $$q$$ should be $$-1$$ rather than $$0$$. Drawing the picture makes this obvious. That solution contains several other mistakes, of which the most important is the misquoting of the Quadratic Formula: the expressions for the roots are wrong. They need to be divided by $$2$$.

It's possible the answer is a bit confusing because the question starts with one parabola (involving $p, q, x$), and the solution uses a different parabola (which should involve $p, q$, but the answer switches the variables to $x, y$, even though the second use of $x$ is unrelated to the first).

If the quadratic equation is $x^2 + px + q = 0$, then to have real roots, the discriminant must be non-negative, i.e., $p^2 \ge 4q$, or $q \le \frac{p^2}{4}$. Now consider the following digram in the $pq$ plane:

Here, $p$ is the horizontal axis, and $q$ is the vertical axis. The red square indicates the admissible area for $p, q$ values (the corners are where $p, q = \pm 1, \pm 1$). The parabola $q < \frac{p^2}{4}$ is indeed symmetric around the vertical $q$ axis. Note that this parabola is unrelated to the original one. The grey region is the region where the discriminant is positive, and, from simple geometric considerations concerning uniform distribution, the ratio of its area to that of the red square is the requested probability.

The area in the square is $4 = (1 - (-1))^2$. The grey area can be found by calculating $\int_{-1}^1\frac{p^2}{4}dp + 2$ (the sum of the two lower grey squares is 2).

For the second part of the question, note that the sum of roots is $-p$.

• "this parabola is unrelated to the original one" --- why? And, if that is true, how do you explain the relationship of both parabolas? Oct 15, 2016 at 0:07
• The second parabola is just a parabola describing the discriminant of the first one - that is the only connection between them. Otherwise, they are different parabolas over different variables. Oct 15, 2016 at 0:09
• What was the mistake with this solution? quora.com/… Oct 15, 2016 at 1:30
• @anonymous Offhand, the internal integral $\int_{-1}^1\int_0^{\frac{p^2}{4}}\frac{1}{4}dpdq$ has a mistake: it integrated from 0, and not from -1. That ignored the two lower grey squares. Oct 15, 2016 at 6:26

OP

Looks like I found you again. The incorrect solution snapshot above is mine, and I apologize. Apparently I do not know integration limits and the quadratic equation, but that's besides the point. Here's the corrections.

• Could you please answer this? quora.com/… Nov 30, 2016 at 7:35