WolframAlpha's problems with equations involving the floor operation

596 Views Asked by At

The whole story began when I was developing an easy way to solve complex equations involving mix-up of absolute value, floor, ceiling, rounding, and other functions, as well as polynomials embedded in them.

When I was pretty much done, I started solving different equations like that. I came up with couple equations. One of them is:

$$|x^2 + 3x| + \lfloor2x^2\rfloor + x = 5$$

I ended up with eight numbers. I expected six of them to be extraneous, and two of them to work. However, it turned out, none of the eight numbers worked. So I concluded there are no solutions. Just to be sure, I opened up Wolfram Alpha and wanted to see if there is a solution: http://www.wolframalpha.com/input/?i=abs(x%5E2+%2B+3x)+%2B+floor(2x%5E2)+%2B+x+%3D+5

Wolfram Alpha spitted out $x=2\sqrt{2} - 2$.

I checked the solution that WA gave me, but to my surprise it didn't work! If I plugged it inside wolfram alpha for $x$, it worked, but when I did it on paper, it didn't!

Out of curiosity, I typed in this equation in Wolfram Alpha:

$$\lfloor2x^2\rfloor = x+2$$

And, now I was even more surprised. WA gave me solution $-1$, which IS total NONSENSE. It can be checked here: http://www.wolframalpha.com/input/?i=floor(2x%5E2)+%3D+x%2B2 . Obviously $-1$ doesn't work in that equation.

Most important problem: So, I know that Wolfram Alpha gave me the wrong answer for the second equation, however I am still not sure about the first one. Is the solution WA gave for the first equation correct, or am I right about that there is no solution?

ANSWER

I was indeed "hallucinating". One of the eight numbers I got was actually the solution Wolfram Alpha gave me, although I got it in a different form, and somehow it didn't work when I tested it.

Still, the bug present in the second equation needs to be fixed, I'll report it.

3

There are 3 best solutions below

6
On BEST ANSWER

What's happening (for the second one) is that, for example

$$ \lfloor 2(-0.99)^2 \rfloor - (-0.99) = \lfloor 1.9602 \rfloor + 0.99 = 1.99 \approx 2. $$

So what WolframAlpha does, when trying to solve numerically, is get $-0.9999\dots$ (to some chosen precision) which is very close as long as there are only a finite number of '9's. It then rounds (when printing) and gets $-1$ which is no longer a solution.


The first one is a solution:

\begin{align} &\qquad |(2\sqrt 2 - 2)^2 + 3(2\sqrt 2 - 2)| + \lfloor 2(2\sqrt 2 - 2)^2 \rfloor + (2\sqrt 2 - 2) \\ &= |6 - 2\sqrt 2| + \lfloor 1.37 \rfloor + (2\sqrt 2 - 2) \\ &= 5. \end{align}

0
On

The function is discontinuous, but if you specify the proper range (e.g., $x > -10$ or $x<20$, to avoid an infinite number of discontinuities), then Mathematica gives the unique solution directly:

Solve[Abs[x^2 + 3 x] + Floor[2 x^2] + x == 5 && x > -10, x]

(*

{{x -> -2 + 2 Sqrt[2]}}

*)

Interestingly, there is no solution for $x<0$:

Solve[Abs[x^2 + 3 x] + Floor[2 x^2] + x == 5 && x < 0, x]

(*

{}

*)

as can be seen by this graph of $|x^2 + 3 x| + \lfloor 2 x^2 \rfloor + x - 5$:

enter image description here

Also, when I enter the equation in free-form WolframAlpha form in Mathematica the unique answer is returned.

0
On

Let's solve the first equation, $$f(x) = |x^2+3x| + \lfloor 2x^2 \rfloor + x = 5.$$ We note that when $x \le -3$, the LHS exceeds $5$, since $x^2 + 3x = x(x+3) \ge 0$, and $$\lfloor 2x^2 \rfloor + x - 5 > 2x^2 + x - 6 = (x+2)(2x-3) > 0.$$ When $x \ge 1$, the LHS again exceeds $5$, since in this case $f$ is clearly increasing and we have $f(x) \ge f(1) = 1+3+2+1 = 7 > 5$. So now let us restrict our attention to the interval $x \in (-3, 1)$. On the interval $[0,1/\sqrt{2})$ we have $$f(x) = x^2 + 3x + 0 + x = x^2 + 4x,$$ thus $$f(x) - 5 = (x-1)(x+5)$$ and this admits no roots. On the interval $[1/\sqrt{2},1)$ we have $$f(x) - 5 = x^2 + 4x - 4$$ which admits the unique root in this interval $$\boxed{x = 2(\sqrt{2}-1)}.$$ The negative case is handled similarly, noting that $|x^2 + 3x| = -(x^2 + 3x)$ whenever $-3 < x < 0$, and since $$\lfloor 2x^2 \rfloor = k, \quad x \in \left(-\sqrt{(k+1)/2}, -\sqrt{k/2}\right],$$ we have $$f(x) - 5 = -x^2 - 2x + k-5 = -(x + 1 + \sqrt{k-4})(x + 1 - \sqrt{k-4}).$$ Thus we seek integers $4 \le k \le 8$ such that $-\sqrt{k+1} < -\sqrt{2}(1 \pm \sqrt{k-4}) \le -\sqrt{k}$, or equivalently, $$0 \le k \pm 4\sqrt{k-4} - 6 < 1.$$ Simple trial evaluations yield no such $k$; therefore, the boxed solution is unique.

In Mathematica, the single command

Reduce[Abs[x^2 + 3 x] + Floor[2 x^2] + x == 5, x, Reals]

yields the solution

x == -2 + 2 Sqrt[2].

Typing in

Reduce[Floor[2 x^2] == x + 2, x, Reals]

gives

False

as expected.