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 $2$ numbers $a, b$. I need a formula (or a how to) to find which $2$ numbers $c,d$ will add together to give a and times together to give $b$. So

$c + d = a$
$c \cdot d = b$

share|cite|improve this question
You will end up with a quadratic equation when you replace either of c or d in the first equation with something derived from the second equation. – J. M. Sep 22 '10 at 23:25
A typical contest question with this setup asks for the sum of the squares (or cubes) of c and d. – Isaac Sep 23 '10 at 0:11
up vote 3 down vote accepted

Consider the quadratic

$$(x-c)(x-d) = x^2 -(c+d)x + cd = x^2 - ax +b$$

Thus the roots of $$x^2 -ax + b = 0$$ are your numbers $c$ and $d$.

The roots are given by

$$\frac{ a \pm \sqrt{a^2 -4b}}{2}$$

Check this page out for more information: Quadratic Equation.

share|cite|improve this answer
Short version: it's the Vieta formulae for the quadratic case. – J. M. Sep 22 '10 at 23:54

Since I'm not so smart to imagine that the solution has anything to do with Vieta formulae or roots of polynomials, ;-) I'd try the following. First, let me call your unknowns $c,d$ with letters that look like unkowns (I've tried to do the problem with $c,d$ and at a certain point I forgot which among $a,b,c,d$ were the unkowns and which the data). So let $x = c$ and $y =d$. Your system becomes

$$ \begin{align} x + y &= a \\ xy &= b \ . \end{align} $$

Now, do what you would do in those cases. For instance, solve the first equation for $x$ in terms of $y$:

$$ x = a -y \ . $$

Then substitute this expression for $x$ into the second equation:

$$ (a-y)y = b \ . $$

And, surprise!, you've got a polynomial equation

$$ y^2 -ay + b = 0 $$

that looks like the ones I've been told. (So this Vieta must have been a really smart guy, but you've rediscovered his trick.)

And, of course, once you've got the solutions $y$ of this second degree equation, you should use $x = a-y$ to find $x$... (Just to find out that if $y$ is one of the roots of the last polynomial equation, $x$ is the other one.)

share|cite|improve this answer
"So this Vieta must have been a really smart guy, but you've rediscovered his trick." -LOL, thanks for making my day, Agusti! +1. – J. M. Sep 23 '10 at 3:59
My pleasure. :-) – a.r. Sep 23 '10 at 7:43
how did you do the fancy algebraic letters? surely it will be y^2 - ay - b = 0 – Jonathan. Sep 24 '10 at 22:02
sorry I've tried what you said as best as I could but I don't reall understand, could you possibly do an example where a = 7 and b = 10 – Jonathan. Sep 24 '10 at 22:45
@Jonathan. Well, in this case you'll obtain x= 5 and y=2: 5+2= 7 and 5 x 2 = 10. As for the letters, I'm using LateX: click on the link beside "edited" and then on the one that says "view source". – a.r. Sep 25 '10 at 0:57

HINT $\rm\quad (X - c)\: (X - d) \; =\; X^2 - a\ X + b $

share|cite|improve this answer

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.