Find non-negative real $a,b$ such that $a+b=d, ab=d$ for non-negative integer $d$

230 Views Asked by At

Find non-negative real $a,b$ such that $a+b=d, ab=d$ for non-negative integer $d$

I know the correct approach here is to take $d/x+x=d$ and the solutions for $x$ will be the solutions for $a,b~(\neq0)$. Note that $a,b$ DNE for $d=1, 2, 3$, and $a=b=0$ for $d=0$.

Now, I proceeded to solve this question by an alternate method:

$$ \begin{align} &d^2=(a+b)^2\tag{1}\\ &\implies d^2=a^2+b^2+2ab\tag{2}\\ &\implies d^2-2d=a^2+b^2\tag{3}\\ &\implies d^2-2d-a^2=b^2\tag{4} \end{align} $$

Now, for, say sufficiently large $d$ (s.t. $d^2-2d-2 \geq0\implies d\geq3$), we can put $a=\sqrt{2}$ and then solve for $b$ as $b=\sqrt{d^2-2d-2}$ (rejecting the negative solution of the square root).

However, this consistently gives me incorrect answers. For example, for $d=1000$, I get $b=999.497874$. Notice that while $a+b= 1000.91$ is a small inaccuracy, $ab=1413.50$ is off by miles!

I have been trying this question for over an hour now. What is wrong with my second approach?

3

There are 3 best solutions below

2
On BEST ANSWER

The answer is simple...

The problem isn't in squaring..The wrong answer occurs because

For any value of $a$ that you choose , you automatically fix the values $b$ and $d$ can take for solving both equations simultaneously and correctly.

And after fixing $a$ , if you try to put any value of $d$ it might satisfy one equation but it doesn't satisfy the other.. which is what is happening..

So, you are correct until you write $b=\sqrt{(d^2-2d-2)}$ but don't forget you have also got an additional relation namely $\sqrt2b=d$ and there is only correct solution to both of these..

4
On

It is codeforces contest problem http://codeforces.com/contest/1076/problem/C. $a+b=d,\;ab=d=>a,\;b$ is a root the quadratic polynom $$ \\x^2-dx+d=0 $$

6
On

Just because $a+b=d,\;ab=d$ implies $b=\sqrt{d^2-2d-a^2}$, that does not mean that for all $a,b,d$ that satisfy $b=\sqrt{d^2-2d-a^2}$, $a+b=d,\;ab=d$. The issue is that some of the steps you've taken (i.e., squaring) introduce faux solutions.

Another way to see that you've introduced faux solutions via irreversible steps like squaring is by noticing that for any $d$, there must exist at most one $a,b$ that satisfy $a+b=d$, $ab=d$. However, with your equation, for any $d$, there are infinitely many pairs of $a,b$ that satisfy the given equation.