1
$\begingroup$

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) ?

$\endgroup$
1
  • $\begingroup$ What is r? it's never used... $\endgroup$
    – BlacKow
    Commented Oct 14, 2016 at 20:02

2 Answers 2

2
$\begingroup$

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

$\endgroup$
2
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ +1 Alternatively to be concise you can define your f[μ]:=μ # (1 - #) & $\endgroup$
    – BlacKow
    Commented Oct 14, 2016 at 21:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.