# Solve algebraic equation with floor functions

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?

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.

• Now note that $n$ and $2n+1$ are coprime, so we need $2n+1$ to divide evenly into $45-n$. – Ross Millikan Jul 7 '18 at 4:48
• If $2n+1$ divides $45-n$, it also divides $2\cdot(45-n)+(2n+1)=91$ (and - as it is odd - also vice versa). Hence $2n+1\in\{\pm1,\pm7,\pm13,\pm91\}$ and so $x\in\{-46,-7,-4,-10,3,6,45\}$ – Hagen von Eitzen Jul 7 '18 at 7:40

$$\frac{-x^2+45x}{2x+1}-\left\lfloor \frac{-x^2 +45x}{2x+1} \right\rfloor + x - \lfloor x \rfloor = 0$$

The solution comes from $$\frac{-x^2 +45x}{2x+1}=-x+n$$ Where n is an integer.

Cross multiplication gives us

$$-x^2 +45x=(2x+1)(-x+n)$$ or $$x^2+(46-2n)x+n=0$$

This equation has real solution for $$(46-2n)^2-4n\ge 0$$

• I don't think this is right. It looks like you've translated the equation into "both terms have the same fractional part, so they differ by an integer". This would work if the $(x-\lfloor{x}\rfloor)$ was on the other side of the equation, but it's not and I don't see how to save this approach here. – JonathanZ supports MonicaC Jul 7 '18 at 4:47