(*Adapted by Rafael Luís: rafaelluis@netmadeira.com
 2016-09-11: adapted for Mathematica v.10 by Ross Moore *)

Clear["Global`*"]

lyapunov=Compile[{a,{n,_Integer}},
With[{p=NestList[a # (1-#)&,0.2,n-1]},
Apply[Plus,Log[Abs[a (1-2 p)]]]/n]];

(*computed of the exponent for a specific value for the parameter*)

lyapunov[3,10000]

(*Plot of the exponent*)

Plot[lyapunov[a,10000],{a,3,4},PlotRange->{-1,1},AxesOrigin->{3,0},Ticks->{{3,3.5,4},{-2,-1,1}},PlotLabel->StyleForm["Lyapunov exponent for the logistic map"],PlotStyle->{Hue[0.595],Thickness[.002]},LabelStyle->{FontFamily->"Times",FontSize->12},ImageSize->{400,280},AxesLabel -> {"μ", "λ"}]