# Derivative of remainder function wrt denominator

Given $f(x,y) = x \mathbin{\%} y = x - y \lfloor \frac{x}{y} \rfloor$, I want to find the partials ${{\partial f}\over{\partial y}}$ and ${{\partial f}\over{\partial x}}$ I understand there will be discontinuities in both.

Intuitively ${{\partial f}\over{\partial x}} = 1$ where $\frac{x}{y} \notin \mathbb{Z}$

However, ${{\partial f}\over{\partial y}}$ seems more tricky. If I try to use intuition and define it piecewise, it seems like it may be:

{{\partial f}\over{\partial y}} = \left\{\begin{aligned} &0 &&: 0 < x < y\\ &\text{undefined} &&: \frac{x}{y} \in \mathbb{Z} \\ &-1 &&: \text{otherwise} \end{aligned} \right.

Or something similar. However, if I derive it from the above definition:

\begin{aligned} {{\partial f}\over{\partial y}} &= -\frac{\partial}{\partial y} \operatorname{floor}\left(\frac{x}{y}\right)\\[6pt] &= \frac{\partial}{\partial y} \operatorname{floor} \left(\frac{x}{y}\right)\frac{x}{y^{2}}\\ \end{aligned}

But it's my understanding that $\frac{\partial}{\partial x}\operatorname{floor}(x) = 0, \forall x \notin \mathbb{Z}$ which implies $\frac{\partial f}{\partial y} = 0$.

This just feels like an incomplete picture and I hope I've made some error or poor assumption somewhere. Would really appreciate some insight into alternative definitions of modulo that I could use here.

• In your derivation, it looks like you forgot the product rule. You need $$\frac{\partial f}{\partial y} = - \frac\partial{\partial y} y \cdot \bigg\lfloor \frac xy \bigg\rfloor - y \cdot \frac\partial{\partial y}\bigg\lfloor \frac xy \bigg\rfloor.$$ – Greg Martin Jul 5 '16 at 2:40
• @GregMartin Ugh, thanks. Glad it was a simply oversight. – Aidan Gomez Jul 5 '16 at 3:32