2
$\begingroup$

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?

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

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

$\endgroup$
  • $\begingroup$ 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 :/ $\endgroup$ – Gaurang Tandon Nov 14 '18 at 7:50
  • $\begingroup$ 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$ $\endgroup$ – user35508 Nov 14 '18 at 8:16
1
$\begingroup$

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

$\endgroup$
  • $\begingroup$ You mean $x^3-dx+d=0$ $\endgroup$ – Hagen von Eitzen Nov 12 '18 at 16:46
  • $\begingroup$ 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$. $\endgroup$ – Samvel Safaryan Nov 12 '18 at 16:51
  • 1
    $\begingroup$ A bit typo: $+d$ not $+d^2$. $\endgroup$ – xbh Nov 12 '18 at 16:55
  • 2
    $\begingroup$ 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. $\endgroup$ – Gaurang Tandon Nov 12 '18 at 17:22
1
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – NoChance Nov 12 '18 at 17:02
  • 1
    $\begingroup$ @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. $\endgroup$ – Don Thousand Nov 12 '18 at 17:08
  • $\begingroup$ 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? $\endgroup$ – Gaurang Tandon Nov 12 '18 at 17:29
  • $\begingroup$ @RushabhMehta, thank you. $\endgroup$ – NoChance Nov 12 '18 at 18:05
  • $\begingroup$ @GaurangTandon No, step 1 did generate faux solutions, you just didn't notice them till step 4. $\endgroup$ – Don Thousand Nov 12 '18 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.