FLINT3.7.0-dev

fmpq_next_minimal, _fmpq_next_minimal

Synopsis#include <flint/fmpq.h>
void fmpq_next_minimal(fmpq_t res, const fmpq_t x)source
void _fmpq_next_minimal(fmpz_t rnum, fmpz_t rden, const fmpz_t num, const fmpz_t den)source

Given a nonnegative canonical xx, set the result to the next element of the enumeration of the nonnegative rationals by increasing height max⁡(p,q)\max(p, q): for q=1,2,3,…q = 1, 2, 3, \ldots the fractions p/qp/q and q/pq/p for 1≤p<q1 \le p < q coprime to qq, in increasing order of pp. Starting from zero, every nonnegative rational is generated exactly once: 0,1,1/2,2,1/3,3,2/3,3/2,1/4,4,3/4,4/3,1/5,5,2/5,…0, 1, 1/2, 2, 1/3, 3, 2/3, 3/2, 1/4, 4, 3/4, 4/3, 1/5, 5, 2/5, \ldots

Finding the next pp coprime to qq needs GCDs, so this enumeration is somewhat slower than fmpq_next_calkin_wilf.

Cite this page

The FLINT team, “fmpq_next_minimal, _fmpq_next_minimal (fmpq.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/fmpq/fmpq_next_minimal.html (generated 2026-11-02).