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

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?

• When $d=1000$ and $a=\sqrt{2}$, then $b=d/a=1000/1.414=707.21$ not $999.497$ – NoChance Nov 12 '18 at 20:50

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..

• Hey thanks for the answer! If I use both the last equations I get $d=\sqrt{2(d^2-2d-2)}$ which means $d^2-4d-4=0\implies (d-2)^2=8\implies d=2+2\sqrt2$ which is a constant but incorrect value for $d$ :( It seems to not depend on $b$ at all this time :/ – Gaurang Tandon Nov 14 '18 at 7:50
• I never said that you would get an answer which required $d$ to be an integer.. I was just answering your query regarding the system of questions...For your original question you would have to choose suitable value of $a$..The answer you get now satisfies the equations both the equations and doesn't produce any inconsistency like you get when you choose $d=1000$ – user35508 Nov 14 '18 at 8:16

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$$

• You mean $x^3-dx+d=0$ – Hagen von Eitzen Nov 12 '18 at 16:46
• Vieta's formulas $=>$ if $x_1, x_2$ the root for $x^2-px+q=0$ then $x_1+x_2=p$ and $x_1x_2=q$. – Samvel Safaryan Nov 12 '18 at 16:51
• A bit typo: $+d$ not $+d^2$. – xbh Nov 12 '18 at 16:55
• Sorry, I am not sure how this is helpful. I said I already know the solution (I even got it accepted on Codeforces during the contest). My question asks for a mistake in my second approach, I am not sure how this answer tells me that. – Gaurang Tandon Nov 12 '18 at 17:22

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.

• Are you implying that squaring is not a valid way of manipulating equations in general? Which cases is it valid in? I am finding this new to me and I want to understand it better. Thanks. – NoChance Nov 12 '18 at 17:02
• @NoChance It is valid, but its irreversible. What that means is that when you square the equation, then if the previous equation holds, the squared equation holds, but not vice versa. – Don Thousand Nov 12 '18 at 17:08
• Hey thanks for the answer. I am generally used to one or two false solutions when squaring equations. However, these infinitely many solutions are new for me. But, according to me, it seems that the faux pas solutions are being introduced at equation 3. Now, the only move I made from eq2 to eq3 was putting $ab=d$, not squaring. Then, why is it that you hold squaring to be the culprit, even though the steps until eq2 didn't generate any faux pas solutions? – Gaurang Tandon Nov 12 '18 at 17:29
• @RushabhMehta, thank you. – NoChance Nov 12 '18 at 18:05
• @GaurangTandon No, step 1 did generate faux solutions, you just didn't notice them till step 4. – Don Thousand Nov 12 '18 at 19:13