FLINT3.7.0-dev

fmpq_simplest_between, _fmpq_simplest_between

Synopsis#include <flint/fmpq.h>
void fmpq_simplest_between(fmpq_t x, const fmpq_t l, const fmpq_t r)source
void _fmpq_simplest_between(fmpz_t x_num, fmpz_t x_den, const fmpz_t l_num, const fmpz_t l_den, const fmpz_t r_num, const fmpz_t r_den)source

Set x to the simplest fraction in the closed interval between l and r, where a_1/b_1 is simpler than a_2/b_2 if b_1 < b_2, or b_1 = b_2 and a_1 < a_2. The endpoints need not be canonical, but their denominators must be positive; the result is canonical.

fmpq_simplest_between accepts the endpoints in either order; the underscore version requires l \le r. The simplest fraction is read off the common prefix of the continued fraction expansions of the endpoints, computed by _fmpq_ball_get_cfrac; see Continued fractions of rational numbers.

Cite this page

The FLINT team, “fmpq_simplest_between, _fmpq_simplest_between (fmpq.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/fmpq/fmpq_simplest_between.html (generated 2026-10-20).