Intervals

Often it is useful to find all points that fall into a given interval $[a, b]$. For example, given the interval $[10, 20]$, all multiples of $\pi$ that fall in this interval are $4\pi$, $5\pi$, and $6\pi$.

Algorithm X.1:

Input: a rational number $q$ and an interval $[a, b]$.
Output: a list of possibly zero rational numbers.

Given a rational number $q$ and an interval $[a, b]$ with rational end-points, describe an algorithm that finds all points of the form $nq$, if any, that fall in the given interval.

You may assume the computer knows how to calculate both the floor and the ceiling of a real number.

Algorithm X.2:

Input: an interval $[a, b]$.
Output: a list of possibly zero numbers of the form $n \pi$ where $n$ is an integer.

Given the interval $[a, b]$, describe an algorithm that finds all points of the form $n \pi$, if any, that fall in the given interval.

Algorithm X.3:

Input: an interval $[a, b]$ and an angular frequence $\omega > 0$.
Output: a list of possibly zero numbers of the form $n \omega \pi$ where $n$ is an integer.

Given the interval $[a, b]$, describe an algorithm that finds all points of the form $n \omega \pi$ where $\omega > 0$.

Algorithm X.4:

Input: an interval $[a, b]$, an angular frequence $\omega > 0$, and a phase shift $\phi$.
Output: a list of possibly zero numbers of the form $n \omega \pi + \phi$ where $n$ is an integer.

Given the interval $[a, b]$, describe an algorithm that finds all points of the form $n \omega \pi + \phi$ where $\omega > 0$.