You have:
>y/x = m , if y = mx+p, 0<=p<x ----- (1) You want:
>y/x = m, if y = mx+p, p=0
> = (m+1) if y = mx+p, 0<p<x ----- (2)
You substitute:
>f(x) = (y+x-1)/x
>Can i have a mathematical proof that this always produces
>the desired result (2), from first principles? That is,
>without merely substituting, y with (mx+p)?
It looks like you have a built-in function that produces result (1) and you want to trick it into producing the desired result (2) by substituting a modified value y' = y+x-1. We need to check that this gives the desired result in all cases.
Applying the built-in function to y' gives
y'/x = m' if y' = m'x+p', 0<=p'<x
Now substitute the value of y' into the middle equation:
y'/x = m' if y+x-1 = m'x+p', 0<=p'<x
Rearrange the equation in the middle:
y'/x = m' if y = (m'-1)x+p'+1, 0<=p'<x
This is just a division with quotient m'-1 and remainder p'+1, except in the case where p'=x-1. In that case, p'+1 = x, so (m'-1)x + p'+1 = (m'-1)x + x = m'x, and the remainder is really p'=0. Therefore, the formula should be written as:
y'/x = m' if y = m'x + 0, p'=x-1
y'/x = m' if y = (m'-1)x+p'+1, 0<=p'<x-1
Let's clean these up by defining p" = p'+1 for 0<'p'<x-1 and p" = 0 for p' = x-1. Then the formulas become:
y'/x = m' if y = m'x + p", p"=0
y'/x = m' if y = (m'-1)x+p", 1<=p"<x
Now compare this to what you would get by plugging the original number y into the built-in function, which is your equation (1):
In the case 1<=p"<x, you know y=mx+p and also y=(m'-1)x+p", therefore m=m'-1 and p"=p, therefore m'=m+1, p=p", and in the case p"=0, you know y=mx+p and y=m'x+p", so m'=m and p=p". Substituting these relationships into the two formulas gives
y'/x = m if y=mx+p, p=0
y'/x = m+1 if y=mx+p, 1<p<x-1
This is exactly the output you desired from the function, so plugging y' = y+x-1 into the built-in function will produce the ceiling in every case.
Note that you still had to plug y=mx+p into the proof somewhere along the line, becasue the original function is your basis for comparison, and you would have no way to interpret what m' and p" were if you did not do this.
Hope this is what you wanted!
--Stuart Anderson