## How many quadratic equations with real roots are there? (Part II)

In the last post, we started looking at the question: of all possible quadratic equations with real coefficients, what fraction of them, $f_{real}$, have real roots?

To review, the roots of a quadratic equation, $ax^2+bx+c$ are given by the quadratic formula: $x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}$. The roots are real when the thing inside the square-root, the discriminant, $D=b^2-4ac$ is positive.

Last time, we tried using some probability arguments to see if we could make sense of $f_{real}$, but we didn’t get anywhere useful.  This time, let’s explore what we learn by noting that the condition that the disciminant is positive for real roots defines a surface in $(a,b,c)$-space that separates sets that give real roots from those that don’t, and so the ratio of the volume of the real-root space to the whole space ought to give us the fraction of possible quadratics with real roots.

How big is the volume of $(a,b,c)$-space? Infinite.  Let’s avoid that by assuming the space is finite and then we’ll take the limit to infinity later.  Specifically, let’s treat the space as a cube bounded in each direction by $\pm r$.  Then, the volume of $(a,b,c)$-space is:

$V_{abc}=8r^3.$

Now, to the space of real roots.  The condition that the discriminant is positive corresponds to the region defined by:

$a\le \frac{b^2}{4c}.$

The volume of this region is given by an integral:

$\begin{array}{ll} V_{real} &=\displaystyle \int_{-r}^r dc \int_{-r}^ db \int_{-r}^{\frac{b^2}{4c}} da \\&\\&=\displaystyle \int_{-r}^r dc \int_{-r}^r db \left(\frac{b^2}{4c}+r\right) \\&\\ &=\displaystyle \int_{-r}^r dc \left(\frac{r^3}{6c}+2r^2\right) \\&\\& = 4r^3+\frac{r^3}{6}\left(\text{ln}(r)-\text{ln}(-r)\right) \\&\\& =4r^3+\frac{r^3}{6}\text{ln}(-1).\end{array}$

Hmm, that’s funny.  What’s that $\text{ln}(-1)$ doing there?  Doesn’t $\text{ln}(-1)=i\pi$?  But volume had better be real.  Did we make a silly mistake?

If we take a look at the calculation above, the only place shenanigans might show up is from the integration over $c$.  Let’s take a closer look.  One thing we ought to be able to do is split the integral like this:

$\displaystyle \int _{-r}^r \frac{dc}{c}=\int_{-r}^0\frac{dc}{c}+\int_0^r\frac{dc}{c}.$

Furthermore, in the integral over the negative range, we can make a change of variable:

$\begin{array}{l} u=-c \\ dc=-du, \end{array}$

and so we can rewrite the integral as:

$\displaystyle\int_{-r}^r\frac{dc}{c}=\int_{r}^0\frac{du}{u}+\int_0^r\frac{dc}{c},$

but there’s no reason we can’t also call the symbol $u$ the symbol $c$ instead!  So, let’s make that change and do a couple extra things to find:

$\begin{array}{ll} \displaystyle\int_{-r}^r\frac{dc}{c} &=\displaystyle\int_{r}^0\frac{dc}{c}+\int_0^r\frac{dc}{c} \\ &\\&= \displaystyle-\int_{0}^r\frac{dc}{c}+\int_0^r\frac{dc}{c} \\&\\ & =0 .\end{array}$

What the … happened?  Where’s the $\text{ln}(-1)$?  On the bright side, if this integral is zero, then $V_{real}=4r^3$, which is real.  And, on top of that, we find for the fraction of quadratics with real coefficients with real roots:

$f_{real}=\frac{V_{real}}{V_{abc}}=1/2,$

which is to say that there are exactly as many quadratics with real roots as without!

Since we’re asking a question about volumes, the answer had to be real, and so the second version of the integral over $c$ as got to be right.  It’s also the answer you’d get if you picture the volume defined by $a\le\frac{b^2}{4c}$ and think hard for a couple minutes.

But wait, so the integral of $\frac{1}{c}$ over a symmetric domain should be zero you say, but we still have that result from before that $\text{ln}(r)-\text{ln}(-r)=\text{ln}(-1)\not= 0$.  What do we do about that?

Let’s take a look at what we mean by $\text{ln}$.  The logarithm is defined by:

$\text{ln}\left(e^x\right)=x.$

So, for what value of $x$ do we get $e^x=-1$? Euler tells us that $e^{i\theta} = \text{cos}(\theta)+i\text{sin}(\theta)$ (and it’s not too hard to prove it, but the proof is reasonably rigorous, and thus has no place in this post!).  We get $-1$ for $\theta = \pi$, and so $\text{ln}(-1)=i\pi$.

But wait! We also get $e^x=-1$ for $x=-i\pi$ or, most generally, for $x= (2n+1)i\pi$ for all integer $n$.

So, $\text{ln}(-1)=(2n+1)i\pi$!  So many answers, and none are zero!

I bet Euler would say, if we’ve got an infinite number of perfectly good answers, the average is really what we’re looking for.  What’s the average answer? For every positive answer, there’s a corresponding negative answer, and so the average is zero!

So there you have it, another reason to think that $\displaystyle \int_{-r}^r\frac{dc}{c}=0$. (In general this answer for that integral is known as it’s Cauchy Principle Value.)

If it’s not clear by now, I don’t understand how modern mathematicians’ clear this confusion up.  For the problem of interest, we get zero for that integral three ways (change of variables, picturing the volume, and averaging the multivalued function), but not all ways.  Anyone care to explain?

To to summarize, if you shenanigan the integral correctly, one finds that the fraction of quadratics with real coefficients that have real roots is a half.

And if you’re still unhappy, there’s (at least) one more reason to believe that $f_{real}=\frac{1}{2}$.  For every choice of $(b,c)$ a choice of $a$ is either above or below the boundary set by $a=\frac{b^2}{4c}$.  Since the space of possible $a$ is infinite, then partioning that space at any one point yields two semi-infinite spaces, and so half of the total space leads to real roots.

How fun is it that such a simple question leads to such sneaky mathematics?

Next time, let’s look at something a little less messy.

Update (5/4/2009):  The internet has a little chatter about this question and it seems $f_{real}=1/2$ is not the most popular answer.  Take a look at this thread or this one to see why

$f_{real}=\frac{1}{2} + \frac{1}{12} \left(\frac{5}{6}+ \text{ln}(2)\right)\approx 0.627$

Question for the masses: how can there be multiple good answers?

### 4 Responses to “How many quadratic equations with real roots are there? (Part II)”

1. Carnival of Mathematics #52 « The Number Warrior Says:

[…] Here’s a series asking a simple question with complex ramifications: how many quadratic equations with real roots are there? (Part one, Part two) […]

2. VK Says:

The probability of real roots has to be greater than 0.5 since in half the space a and c have opposite signs and thus D > 0 irrespective of sign of b. In the other half (where a and c have the same sign) there are regions where b^2 > 4ac and thus probability of real roots is non-zero. Hence overall probability is greater than half (and is actually equal to the 0.627 mentioned in the threads).

3. Philip Petrov Says:

Hello,
I did a completely different approach in solving this problem. Here is what I did – I looked at two cases a>0 and a0, I did divide the equation by “a” and made p=b/a and q=c/a. Then I solved the problem as the general geometric probability problem for quadratic equation where p^2>4q

Next, when a0 and a<0) I get exactly 1/2!

Here is it (in Bulgarian): http://www.cphpvb.net/probability/8386-real-roots-of-quadratic-equation/

4. Philip Petrov Says:

Hello,
I did a completely different approach in solving this problem. Here is what I did – I looked at two cases a>0 and a<0, With a>0 I did divide the equation by “a” and take p=b/a and q=c/a. Then I solved the problem as the general geometric probability problem for quadratic equation where p^2>4q

Next for a<0 I divide the equation by -a (!!!). It is important to NOT change the sign in front of “b” and “c”. If we change both “b” and “c” signs (when “a” is negative number and we divide to it) we do not change the b^2 sign in “D” but we do change the c sign in “D”. Next I take p=-b/a and q=-c/a. Then I solve the problem like the general geometric probability problem.

When I combine the two cases I get exactly 1/2. In the first case (a>0) the probability is going to infinity but in the other case (a<0) it’s going to 0. Guess what – they are exactly opposite :)

Here is it (in Bulgarian): http://www.cphpvb.net/probability/8386-real-roots-of-quadratic-equation/

P.S. I double-commented because on my previous comment it took html code and scrambled it.

P.S.2. I was not able to use my normal e-mail address in the comment form because it looks like I have some stupid gravatar registration which I can’t login into and I can’t cancel. If you wish to get in touch with me please contact me through the website