Given real numbers $ω_1, ω_2, γ ∈ ℝ$, I want to find integers $k_1,k_2∈ℤ$ such that $ω_1k_1 + ω_2k_2 ≈ γ$.
For all intends and purposes we may assume $ω_1, ω_2, γ$ are linearly independent over $ℚ$.
Idea. My current idea is to consider the best rational approximation $ω_1≈\tilde{ω}_1∈ℚ$, $ω_2≈\tilde{ω}_2∈ℚ$, $γ≈\tilde{γ}∈ℚ$ given a maximum denominator. However, what do I do if the resulting linear diophantine equation with integer coefficients (after multiplying with the lcm of the denominators), is unsolvable?
Edit. Dividing by $γ$ gives $\frac{ω_1}{γ}k_1 + \frac{ω_2}{γ}k_2 ≈ 1$. After rational approximation, we have $\frac{p_1}{q_1}k_1 + \frac{p_2}{q_2}k_2 ≈ 1 ⟺ p_1q_2k_1 + p_2q_1k_2 ≈ q_1q_2$, which is solvable if and only if $gcd(p_1q_2,p_2q_1) | q_1q_2$.
Context. Given two sine-waves $f_1(t)=\sin(φ_1+ω_1t)$, $f_2(t)=\sin(φ_2+ω_2t)$, I want to find a time $t^*$ when two crests/troughs approximately colocate. I am certain this is a well known problem, but I am not sure what the right keywords are.
Formalization. To make it a well-posed problem, one should add a size cosntraint, here are two versions:
- Given upper bound $K∈ℕ$, find $k_1,k_2∈ℤ$ with $|k_1|, |k_2| ≤ K$ such that $|ω_1k_1 + ω_2k_2 - γ|$ is minimal.
- Given absolute and relative tolerances $ε>0$, $δ≥0$,
find $k_1,k_2∈ℤ$ satisfying $|ω_1k_1 + ω_2k_2 - γ| < ε + δ|γ|$,
such that $‖(k_1, k_2)‖$ is minimal