1

This is a classical way to calculate Lyapunov exponent

\[Lambda][r_] := Module[{f, l},
f[x_] := μ x (1 - x);
l[x_] := Log[Abs[μ (1 - 2 x)]];
Mean[l[NestList[f, 0.1, 1*^2]]]];
Plot[λ[μ], {μ, 0, 4}, PlotStyle -> Thickness[.0001], 
AxesLabel -> {"μ", "λ(μ)"}]

No problem it works nicely. There are two problems

1) I have earlier in my code defined $f[x\_, \mu\_]$ and I would like not to redefine $f$. 2) In the code one pass the derivative by hand --- μ (1 - 2 x) ---. I have tried to add a function $g$ in the module which calculate the derivative but this doesn't work.

How could I do ? I think 1) is perhaps impossible with a module but 2) ?

cyrille.piatecki
  • 4,582
  • 13
  • 26

2 Answers2

2

Is this what you want? I assumed that it is $\lambda(\mu)$ and not $\lambda(r)$

λ[μ_, f_] := Module[{l},
   l[x_] := Evaluate@Log[Abs[D[f[x, μ], x]]];
   Mean[l[NestList[f[#, μ] &, 0.1, 1*^2]]]
 ];

f[x_, μ_] := μ x (1 - x);

Plot[λ[μ, f], {μ, 0, 4}, 
 AxesLabel -> {"μ", "λ(μ)"}, PlotRange -> Full]

enter image description here

BlacKow
  • 6,428
  • 18
  • 32
2

Assuming r is supposed to be mu, another way to accomplish the above is

\[CapitalLambda][f_] := Module[{
    df, l
    },
   df = Derivative[1][f];
   l = Log@*Abs@*df;
   Mean[l[NestList[f, 0.1, 1*^2]]]
   ];

f[\[Mu]_] := Function[x, \[Mu] x (1 - x)]

Plot[\[CapitalLambda][f[\[Mu]]], {\[Mu], 0, 4}, AxesLabel -> {"\[Mu]", "\[Lambda](\[Mu])"}]

which produces the same plot as BlacKow's answer.

evanb
  • 6,026
  • 18
  • 30