I'm trying to use the Farey sequence to get the next lowest reduced fraction in a list. For example, for $n = 8$, we have $\dots, \frac13, \frac38, \frac25, \frac37, \frac12, \dots$
So let's take $\frac38$ and $\frac25$ and attempt to get $\frac37$.
$p = \left\lfloor\dfrac{n+b}{d}\right\rfloor c - a$
$q = \left\lfloor\dfrac{n+b}{d}\right\rfloor d - b$
$a=3, b=8, c=2, d=5, n=8$
$p = [\frac{8+8}{5}] \cdot 2 - 3$
$q = [\frac{8+8}{5}] \cdot 5 - 8$
$\frac{p}{q} = \frac{3.4}{8} \neq \frac37$
Am I using the equation wrong?
Well, according to your equations, you have to take the floor of $\frac{n+b}{d}$. In your example, it's $\left\lfloor\frac{8+8}{5} \right\rfloor = 3$. Your $p$ is then $(3 \cdot 2) - 3 = 3$, and your $q$ is $(3 \cdot 5) - 8 = 7$.