Solve algebraic equation with floor functions

ceiling-and-floor-functionsroots

I am looking for a way to find all the solutions to this equation without guess and check:
$$\frac{-x^2+45x}{2x+1}-\left\lfloor \frac{-x^2 +45x}{2x+1} \right\rfloor + x – \lfloor x \rfloor = 0$$

I graphed it in desmos and found that the most obvious solutions are $x = -4, -1, 0, 3$. But it turns out that $x = 6$ is also a solution. I can't figure out how to get these solutions algebraically. If they can't be solved directly, does anyone know a numerical algorithm that can be used to at least estimate the solutions?

Also, are algebraic equations involving floor functions generally solvable with algebra, or is it only special cases?

Best Answer

The floor function is very discontinuous, so I wouldn't expect there to be good numerical methods for solving equations involving it. (Numerical methods assume you have an approximate answer that you can tweak to make closer to the actual answer, and you'll have trouble doing that if your function jumps around.) And I have never seen any general algebraic methods for solving them either, but I've never looked for any, so maybe someone else will turn up with a better answer.

Your particular equation has a very special form though, so I can at least get you started, but I don't yet see how to finish it.

Your equation has the form $$(f(x) - \lfloor{f(x)}\rfloor) + (x - \lfloor{ x}\rfloor) = 0 $$

Note that $a - \lfloor{a}\rfloor$ is always $\ge 0$, and it is only equal to zero when $a$ is an integer. So your sum can only equal zero if the two non-negative terms are both zero, which implies that $x \in \mathbb{N}$ and $f(x) \in \mathbb{N}$. That means it reduces to answering: for which $n\in \mathbb{N}$ is $$ \dfrac{n(45-n)}{2n+1}$$ also an integer. I can't think of anything cleverer than noticing that the denominator enumerates the odd integers and just start grinding through them, but maybe you can be find something better.

Edit: Incorporating @Ross Millikan's suggestion, Euclid's method tells us that $\gcd(n, 2n+1) = \gcd(n, 1) = 1$, so there will be no cancelling factors between them and $2n+1$ must divide $(45-n)$. As $n$ increases past $15$ we can see that $2n+1$ has gotten larger than $45-n$, so we don't need to check any $n$ larger than 15. And looking at negative numbers we can see that as $n$ goes below $-45$ we also get the denominator outgrowing the $(45-n)$ in the numerator and we can stopping checking for solutions below that.

So that gives about $61$ values to plug in and check. The second part is pretty hack-y, but we can be sure we haven't missed any solutions.

Related Question