Let's consider $n$ distinct non-zero real numbers $(r_1<r_2<...<r_n)$ such that $\forall (i,j) \; i\ne j:$ $ \frac{r_i}{r_j}\notin \mathbb{Q}$
Let $E$ be the subset of $ \mathbb{R}$ defined by: $E=\{v\;| v=\sum_{i=1}^{n} a_{i}r_{i}\: ;\: a_i\in\mathbb{Q}\}$
For a given real number $x:$
- What is the best algorithm to know if $x\in E$ or not
- For any real number $\varepsilon >0$, how to find $(a_1,a_2,...,a_n) \in \mathbb{Q}^n\ $ such that $|x-\sum_{i=1}^{n} a_{i}r_{i}|<\varepsilon$
What is the best algorithm to know if $x\in E$ or not?
As soon as $n \ge 2$, one of the $r_i$ will be irrational. Finding algorithms that works on irrational numbers will be difficult. How do you represent such a number?
For any real number $\varepsilon >0$, how to find $(a_1,a_2,...,a_n) \in \mathbb{Q}^n\ $ such that $|x-\sum_{i=1}^{n} a_{i}r_{i}|<\varepsilon$
You can notice that $G= \{a_1 r_1 + a_2 r_2 \mid (a_1,a_2) \in \mathbb Z^2\}$ is a subgroup of $(\mathbb R, +)$. A classical result concerning subgroups of $(\mathbb R,+)$ is that they are either discrete or dense. As $\frac{r_2}{r_1} \notin \mathbb Q$, $G$ is dense.
So in fact you can already find $y \in G$ such that $\vert x - y \vert < \epsilon$.
Practically, as $\mathbb Z^2$ is countable, just enumerates it until you find an appropriate element of $G$.