Solve an equation containing ceil function I have a pretty simple formula: $y=x+7\lceil\frac x {1113}\rceil$, but I don't know how to solve it for $x$.
For example, if $x$ is $5520$, $y$ would be $5520+7\lceil\frac {5520} {1113}\rceil=5555$. Giving $5555$, I would like to have a formula returning $5520$.
Ciao,
Claudio.
 A: Since the ceiling function is non-decreasing, and $x \mapsto x$ is strictly increasing, the function $f(x) = x+7\lceil\frac x {1113}\rceil$ is strictly increasing, hence it is injective.
However, it is not surjective, for example $f(0) = 0$, and for $x > 0$ we have$f(x) > 7$, hence $(0, 7]$ is not in the range of $f$.
In general, if $x = 1113n+\theta$, with $n \in \mathbb{Z}$, $\theta \in (0,1113]$, we have $f(x) = f(1113n+ \theta) = 1113n + \theta+ 7n +7 = 1120 n+7 +\theta$. Since $f(1113n) = 1120n$, we see that $\operatorname{image} f = \left( \cup_{ n \in \mathbb{Z}} (1120n, 1120n+7] \right)^c$.
If $y \in E$, the inverse can be computed by setting $y = f(x)=f(1113n+\theta)$, with $\theta \in (0,1113]$. This gives the equation 
$ y=1120n+7+\theta$. This gives $\frac{y-7}{1120} = n + \frac{\theta}{1120}$, which gives $n = \lceil \frac{y-7}{1120} \rceil -1$ and $\theta = 1120(\frac{y-7}{1120}-\lceil \frac{y-7}{1120} \rceil +1)$, from which we get $x= y- 7 \lceil \frac{y-7}{1120} \rceil$.
Note: Erick made the observation that since $y \in E$, $\lceil \frac{y-7}{1120} \rceil = \lceil \frac{y}{1120} \rceil$, so the formula can be simplified (and clearly agrees with Erick's answer) to $x= y- 7 \lceil \frac{y}{1120} \rceil$.
A: When the denominator is large, the thing inside the ceiling will be small.  You can solve it by iteration.  First, ignore the part inside the ceiling.  That gives you a first guess for $x$, here $5555$.  Then use that and compute $7\lceil \frac {5555}{1113} \rceil=35$.  Use that to update your estimate, which becomes $5520$.  Now check that the new estimate hasn't changed the ceiling function, which it hasn't.  You are done.  If your target were $5575$, that would be your first guess, which would give $7\lceil \frac {5575}{1113} \rceil=42$.  Now the second guess is $5533$, which when fed into the ceiling gives $$7\lceil \frac {5533}{1113} \rceil=35$ so you need to update your guess one more time to $5540$.  Bingo.
A: Since $159\cdot7 = 1113$, we have $\frac{160x}{159} \le y < \frac{160x}{159} + 7$, so $\frac{159(y-7)}{160} < x \le \frac{159y}{160}$.  We also know that $(y-x)/7$ is an integer, and rearranging the previous inequality gives
$$ \frac{y}{1120} \le \frac{y-x}{7} < \frac{y}{1120} + \frac{159}{160}.$$
Thus, if $y$ is actually in the range of the function we have $x = y - 7\lceil \frac{y}{1120}\rceil$.  However, as copper.hat points out, some values of $y$ are not in the range.  These are the ones where $\lceil \frac{y}{1120} \rceil - \frac{y}{1120}$ is larger than $\frac{159}{160}$, a.k.a when the remainder of $y$ mod $1120$ is between $1$ and $7$.
A: I don't have the math skills to calculate it but, going by attempts, this seems to work... If $y=x+7\lceil\frac x {1113}\rceil$, then $x=y-7\lceil\frac {y-7} {1113}\rceil$.
