TITLE: If $a+b=x$ and $ab=y$, what is the quickest way to solve for $a$ and $b$?
QUESTION [5 upvotes]: 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?

REPLY [2 votes]: 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$.