I am representing denominators in rational numbers with powers of their prime factors for easy multiplication and division in lowest terms (by adding and subtracting the prime powers). I would like to know how to find the best rational approximation of $\sqrt x$ (with $x$ square-free) with a denominator with prime powers less than $n$.
$$
\sqrt x \approx \frac p q
$$
If $n = 10$, the denominator $q$'s prime powers are limited to $2^a\times3^b\times5\times7$ where $a, b \in \mathbb Z \geq 0$ and $a \leq 3, b \leq 2$. Is there a known method to find the best rational approximation with this limitation? Continued fraction convergents do not admit a limit on the prime powers of the denominator, at least not how they are usually formulated.
2026-03-26 13:46:36.1774532796
Closest rational approximation of $\sqrt x$ with denominator having prime powers $\lt n$
679 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
1
Allowing fractions not in lowest terms, you can assume the denominator is $q = 2^3 \times 3^2 \times 5 \times 7$. Then you just want $p$ to be the closest integer to $q \sqrt{x}$.
EDIT: Note that this is assuming "best" means least $\left| \sqrt{x} - p/q \right|$. There are other notions of "best approximation", to which this would not apply.