How to find the period of a periodic function?

I'm working on some numerical analysis problem, and I'm studying functions that "seem" to be periodic. Now what I would like to do, is to determine their period. Only, the methods I actually use are extremely childish (I visually find two points where the function intercepts the abscissa axis, get the coordinates and calculate the difference between them...).

In other words :

Given a function $\ f(t)\ |\ t\in\ [0,t_f]$

I would like to find $\{T,\ T>0\}$ so that $\forall\, t,\ f(t+T)=f(t)$

Does anyone have a solution?

-

The quick and dirty answer is to take a Fourier transform of your function and observe where, if any, there are spikes in the transform. The frequencies at which the transform has spikes represents the $2 \pi/p$, where $p$ is a period of the data.

In reality, you won't have spikes but a set of peaks. There is a thorough treatment in Numerical Recipes that treats the problem statistically by computing something called a Lomb Periodogram. (The reference is in Sec. 13.8 of NR.) In this case, the LP answers the question of how high a peak should be in order that it represents a true period of the function.

-

Your best bet is to use a Fourier Transform of the data, and looking for the fundamental frequency by looking for the lowest peak in the transform. The following public domain image shows what you get:

-

This type of questions is answered by the Autocorrelation (ACF).

-