I'm not very good at Mathematica, but I think there are two "usual" ways of solving this problem.
One is to do a Fourier transform of your data, and find the peak. Unfortunately I couldn't get a result from Mathematica in a way that makes sense for this.
The other option is to use an autocorrelation plot, and take the best peak. I'm not sure how to do this for a function, but you can sample points along your function and then work with those points:
Let's input your data, and make a plot: (I won't include a plot here since you already have it in the question)
s = NDSolve[{y'[x] == y[x] Cos[x + y[x]], y[0] == 1}, y, {x, 0, 30}];
Plot[Evaluate[y[x] /. s], {x, 0, 30}, PlotRange -> All]
Sample the solution at 10.000 equally spaced points:
numPoints = 10000;
samplePoints = Range[0, 30, 30/numPoints];
samples = Evaluate[y[samplePoints] /. s][[1]];
ListPlot[samples]; (* You can plot the sampled points to be sure, but I disabled it *)
Calculate the autocorrelation:
autocorrelations = ListCorrelate[samples, samples , {1, 1}, 0];
Find peaks by looking for points where the differential changes sign:
peaks = 1 + Position[Differences[Sign[Differences[autocorrelations]]], -2];
bestPeriods = Extract[samplePoints, peaks];
Note that if you have Mathematica 9+, then the above code can be simplified to just MinDetect
. See https://mathematica.stackexchange.com/a/19838/578
Create a nice plot of the autocorrelation, and draw a red line at the most likely peak:
xyPoints = Transpose[{samplePoints, autocorrelations}];
ListLinePlot[xyPoints, PlotRange -> All, GridLines -> {{{First[bestPeriods], Red}}, {}}, PlotLabel -> "Autocorrelation plot - the most likely period is " <> ToString[First[bestPeriods]] <> ":"]
If you want to use the detected period for something, you can access it with First[bestPeriods]
.