One: rationalize is kind of a mess, but that's a separate issue. I actually have a newer version that has more constraints on it as well. It also produces floating-point numerator and denominator rather than integer, so it's a bit different. Ultimately, it would be best to refactor things so that the Base rationalize function can be used here, but rather than try to solve that problem, I'm just temporarily duplicating a bit of code instead.