Let a∈R, and let k(a) be the largest constant such that sup∣cos(na)−cos(nb)∣\textlessk(a) for b∈R implies that b∈±a+2πZ. We show that if a cosine sequence (C(n))_n∈Z with values in a Banach algebra A satisfies sup_n≥1∥C(n)−cos(na).1_A∥\textlessk(a), then C(n)=cos(na) for n∈Z. Since 25≤k(a)≤338 for every a∈R, this shows that if some cosine family (C(g))_g∈G over an abelian group G in a Banach algebra satisfies sup_g∈G∥C(g)−c(g)∥\textless25 for some scalar cosine family (c(g))_g∈G, then C(g)=c(g) for g∈G, and the constant 25 is optimal. We also describe the set of all real numbers a∈[0,π] satisfying k(a)≤23.