Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have to solve the system :

$$\begin{align*} a+b &= S\\ a\times b&= P\\ \end{align*}$$

Someone told me it was equivalent to solve the equation $x^2-S.x+P=0$. I think it's linked with the formula of sum and product of the roots of a second-degree polynomial but I can't figure out why exactly this works.

share|cite|improve this question
up vote 8 down vote accepted

From the first equation you have $b=S-a$; substituting this into the second equation gives you $a(S-a)=P$, which is easily rearranged to yield $a^2-aS+P=0$. This tells you that $a$ must be a solution of $x^2-Sx+P=0$. Since the original system is symmetric in $b$, you know that the same must be true of $b$. And since $x^2-Sx+P=0$ has just two solutions, they must be precisely $a$ and $b$.

And indeed you can write out the factorization: $$(x-a)(x-b)=x^2-(a+b)x+ab=x^2-Sx+P\;.$$

share|cite|improve this answer
Thank you for your answer ! – Skydreamer Mar 12 '12 at 19:47
The above does not correctly handle the case $\rm\:a = b.\:$ Either you need to assume $\rm\:a\ne b\:$ or else account for multiplicity when you say "just two solutions". – Bill Dubuque Mar 12 '12 at 19:47
@Bill: Of course I’m accounting for multiplicity. – Brian M. Scott Mar 12 '12 at 19:54
I don't see any such accounting. – Bill Dubuque Mar 12 '12 at 19:56
@Bill: It’s implicit in what I wrote that I’m counting the roots by multiplicity. – Brian M. Scott Mar 12 '12 at 20:03

We describe how late Babylonian pupils (circa $500$ BCE) were shown how to solve the system of equations $a+b=S$, $ab=P$. We use the computer screen instead of incisions on a clay tablet, so our solution will be much shorter-lived than theirs. To make the derivation more familiar, we use algebraic notation that came a couple of thousand years later. But we give a correct description of the algorithm that was taught.

We have $(a+b)^2=S^2$. Subtract $4ab$. We get that $(a-b)^2=S^2-4P$. Take the square root(s). We get $a-b=\pm \sqrt{S^2-4P}$ (but there were no negative numbers back then either, those were the good old days). Now we know $a+b$ and $a-b$. Add and subtract, divide by $2$, to find $a$ and $b$.

So we have solved a "quadratic equation" without using the quadratic formula, indeed without writing down the equation. You will recognize the procedure as a slightly hidden completing the square. Which reminds me, for al-Khwarizmi and many years after that, completing the square meant completing a geometric figure made up of a square with a square bite taken out of a corner to a real geometric square.

share|cite|improve this answer
Interesting algorithm indeed. – Skydreamer Mar 13 '12 at 15:49

Both Brian M. Scott's and Andre Nicolas's answers are cool, but you can also consider the Vieta's formulae which for second degree polynomial $\alpha x^2 + \beta x + \gamma = 0$ are: \begin{align*} x_1 + x_2 &= -\frac{\beta}{\alpha} &&& x_1 * x_2 &= \frac{\gamma}{\alpha} \end{align*}

where $x_1$ and $x_2$ are the roots of that polynomial. However, that is just like your equations, where $\alpha = 1$, $\beta = -S$ and $\gamma = P$!

Have fun!

share|cite|improve this answer
That was the proof I was trying to find myself. Thank you ! – Skydreamer Mar 13 '12 at 15:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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