Comparing Two Codes for Plotting Maximal Lyapunov Exponent: Which One is Correct?
57 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ahmed Yousef
el 20 de Dic. de 2024 a las 16:29
Hello MATLAB community,
I have been working on calculating and plotting the Maximal Lyapunov Exponent for the Logistic map. I came across two different implementations, and I am unsure which one correctly computes the Lyapunov exponent.
Code 1:
% Parameters for the Logistic Map
r = 3.5; % Parameter 'r'
x0 = 0.1; % Initial condition
v0 = 1; % Initial tangent vector
N = 1000; % Number of iterations to compute the exponent
format long
% Initialize variables
x = x0;
v = v0;
lyapunov = 0;
% Iteration loop
for i = 1:N
% Logistic map equation
xn = r * x * (1 - x);
% Jacobian of the Logistic map
J = r * (1 - 2 * x);
% Update tangent vector
v = J * v;
% Compute norm of the tangent vector
norm_v = abs(v);
% Renormalize the tangent vector
v = v / norm_v;
% Accumulate Lyapunov sum
lyapunov = lyapunov + log(norm_v)
% Update state
x = xn;
end
% Compute the maximal Lyapunov exponent
lyapunov =lyapunov / N;
format long
% Display result
fprintf('Maximal Lyapunov Exponent: %.6f\n', lyapunov);
Code 2:
function LE = LEofLogisticMap( rStart, rEnd, rStep )
rValues = rStart:rStep:rEnd;
nPoints = length( rValues );
nIterations = 1000; % number of iterations
LE = zeros( 1, nPoints );
x = zeros( 1, nIterations + 1 );
x( 1 ) = 0.1;
for k = 1:nPoints
sum = 0;
for i = 1:nIterations
x( i + 1 ) = rValues( k )*x( i )*( 1 - x( i ) );
sum = sum + log( abs( rValues( k ) - 2*rValues( k )*x( i ) ) )
end
LE( k ) = sum / nIterations;
end
rStart = 3.5; % Start value of r
rEnd = 4.0; % End value of r
rStep = 0.01; % Step size
format long
LE = LEofLogisticMap(rStart, rEnd, rStep)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Question:
Both codes compute a Lyapunov exponent using similar steps . However:
- In the first code, the tangent vector is renormalized at each step. Is this approach correct?
- Do these codes correctly compute the maximal Lyapunov exponent for their respective map?
- Is there a universal approach or standard practice that I should follow for these types of calculations?
- Are there any potential pitfalls in the logic of either code that I should address?
Thank you for your guidance!
Respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!