Finding 2 numbers from their product and sum

Given two real numbers r and s, if u is their sum and p their product, r and s are:

    \[\frac{u}{2} \pm \frac{\sqrt{u^2-4p}}{2}\]

This is basically the quadratic formula – note that (x-r)(x-s)=x^2-(r+s)x+rs.

Derivation using quadratic formula

u=r+s and p=rs, so:

    \begin{align*} r&=p/s=u-s\\ p&=s(u-s)=su-s^2\\ s^2-su+p&=0\\ s&=\frac{u\pm\sqrt{u^2-4p}}{2} \end{align*}

Since r and s are symmetrical in u and p, the same equation gives r.

Graphical derivation

Rendered by

The difference in area between the red square (r-s)^2 and the largest square u^2=(r+s)^2 is evidently equal to 4 of the green rectangles each of area rs=p. (See in the right picture that the dark green overlap s^2 is equal in area to the square at top right not covered.)

    \begin{align*} r&=u-s\\ r-s&=u-2s\\ (r-s)^2&=(u-2s)^2 \\ &=(2s-u)^2\\ &=u^2-4p \quad \text{as shown above}\\ \text{So } 2s-u&=\pm\sqrt{u^2-4p}\\ s&=\frac{u\pm\sqrt{u^2-4p}}{2}\\ \end{align*}

Since similarly s-r=u-2r, and (r-s)^2=(s-r)^2, the RHS also gives r.

Pic from E. Hairer and G. Wanner, Analysis by its History, 2008.

Graph of x+y and xy:

Leave a Reply

Your email address will not be published. Required fields are marked *