If $a+b=x$ and $ab=y$, what is the quickest way to solve for $a$ and $b$?

2.3k Views Asked by At

The mechanistic approach would be to simply substitute $b=y/a$ in the first equation to obtain a quadratic in $a$. But seeing the simplicity of the givens, I feel that there must be some better and elegant ways to do this.

The best way I could think of is this:

$(a-b)^2 = (a+b)^2 - 4ab \iff (a-b)^2 = x^2 - 4y \iff a-b = \pm\sqrt{x^2 - 4y}$

Solving this with $a+b=x$, we get the result.

It might be the case that there aren't many ways other than this, but that's okay. If there are, I'd be interested to read them.

Edit: Also, if we know that both $a$ and $b$ are non-negative, can we use this information for a better solution?

3

There are 3 best solutions below

2
On BEST ANSWER

We would always get a quadratic.

Maybe one bit easier if we use the following observation (Viète's formulas): $$(Z-a)(Z-b)=Z^2-(a+b)Z+ab\,.$$ So, $a,b$ are just the solutions of $Z^2-xZ+y=0$.

0
On

Method $1$: The quadratic equation method

Method $2$ : The one you mentioned in your question.

Method $3$ : (Special Cases)

Always check for special cases and special conditions first before going about solving.

Conditions like $(a,b)$ are integers might help out. Condition like $(a,b)$ are positive might also help in some cases where you can use AM $\geq$ GM and the solution might turn out to be the equality case.

0
On

A standard approach (Buchberger's algorithm to find a Grobner basis) to solving systems of polynomial equations involves cancelling monomials. We can use $a$ in one equation to cancel out $ab$ as follows:

$$b (a+b) - ab = b x - y $$ $$ b^2 = bx - y$$

and then solve the quadratic equation for $b$.