  We study resonant billiard trajectories within quadrics in the
$d$-dimensional Euclidean space. We relate them to the theory of approximation,
in particular the extremal rational functions on the systems of $d$ intervals
on the real line. This fruitful link enables us to prove fundamental properties
of the billiard dynamics and to provide a comprehensive study of a large class
of non-periodic trajectories of integrable billiards. A key ingredient is a
functional-polynomial relation of a generalized Pell type. Applying further
these ideas and techniques to $s$-weak billiard trajectories, we come to a
functional-polynomial relation of the same generalized Pell type.
