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