0

Say I have $\lceil \frac{a}{b} \rceil$, where both a and b are integers, is it possible to rewrite this?

My intuition tells me that I can rewrite it as $\lfloor \frac{a}{b} \rfloor + (a\mod{b})$, but wolframalpha tells me no. However, wolframalpha does not know I'm using integers for a and b.

Preferably I would rewrite it to some form completely without ceilings and floors. Is something like this possible?

  • When you say "mod $b$" you are restricting the output to be in the interval $[0,b]$, which is overly restrictive for what you want. If $a$ is very large then $a/b$ can be much larger than $b$. – Michael May 09 '18 at 16:36
  • On the other hand, if $a/b$ is an integer then $\lceil a/b \rceil = a/b = \lfloor a/b \rfloor$. If $a/b$ is not an integer then the ceiling and floor of $a/b$ differ by exactly 1. – Michael May 09 '18 at 16:39
  • I'm not sure about your first statement. Can't the remainder of a/b only be in the range [0,b]? – Aart Stuurman May 09 '18 at 17:12
  • I don't see a connection between your last comment and my first comment. Perhaps there is a confusion about what the "mod b" refers to...you can clarify that by adding parentheses. – Michael May 09 '18 at 17:14
  • Ah I see. Give me second – Aart Stuurman May 09 '18 at 17:14
  • I edited OP to clearly reflect what I meant. – Aart Stuurman May 09 '18 at 17:15
  • 2
    Okay, with the added parentheses, the expression is different but still not the same as the ceiling of $a/b$. For example, if $b=23$ and $a=22$ then $a \mod b = 22$, in which case you are saying the ceiling and floor differ by 22 (but they can only differ by at most 1). On the other hand it is true that $$ a/b = \lfloor a/b \rfloor + \frac{(a \mod b)}{b}$$ – Michael May 09 '18 at 17:16
  • Oh I see now. I guess I made an error thinking this through. The correct answer would be I guess floor(a/b) + ceil((a mod b) / b). Which is sadly even worse that what I started with, haha – Aart Stuurman May 09 '18 at 17:23
  • Oh yes, that is exactly what you said – Aart Stuurman May 09 '18 at 17:23

1 Answers1

1

We have $\lceil \frac ab \rceil = \lfloor \frac ab \rfloor+1$ unless $b$ divides into $a$ evenly. In that case, do not add $1$.

Ross Millikan
  • 374,822