Nlimit); hold on; otherwise disp('Not implemented'); end end axis tight; axis equal text(- 25, - 15, ['u = ' num2str(u)]); text(- 25, - 18, ['N = ' num2str(N) ' iterations']); end % Plot the last n points of the curve - to see end point or limit cycle function plot_limit(X, n) plot(X(end - n:end, 1), X(end - n:end, 2), 'ko'); end % Plot the whole trajectory function plot_ikeda_trajectory(X) plot(X(:, 1), X(:, 2), 'k'); % hold on; plot(X(1,1),X(1,2),'bo','markerfacecolor','g'); hold off end % u is the ikeda parameter % x,y is the starting point % N is the number of iterations function [X] = compute_ikeda_trajectory(u, x, y, N) X = zeros(N, 2); X(1, :) = [x y]; for n = 2:N t = 0.4 - 6 / (1 + x ^ 2 + y ^ 2); x1 = 1 + u * (x * cos(t) - y * sin(t)); y1 = u * (x * sin(t) + y * cos(t)); x = x1; y = y1; X(n, :) = [x y]; end end Python code for point trajectories import math import matplotlib.pyplot as plt import numpy as np def main(u, points=200, iterations=1000, nlim=20, limit=False, title=True): """ Params u:float ikeda parameter points:int number of starting points iterations:int number of iterations nlim:int plot these many last points for 'limit' option. Will plot all points if set to zero limit:bool plot the last few iterations of random starting points if True. Else Plot trajectories. title:[str, NoneType] display the name of the plot if the value is affirmative """ x = 10 * np.random.randn(points, 1) y = 10 * np.random.randn(points, 1) for n in range(points): X = compute_ikeda_trajectory(u, x[n][0], y[n][0], iterations) if limit: plot_limit(X, nlim) tx, ty = 2.5, -1.8 else: plot_ikeda_trajectory(X) tx, ty = -30, -26 plt.title(f"Ikeda Map ({u=:.2g}, {iterations=})") if title else None return plt def compute_ikeda_trajectory(u, x, y, N): """ Calculate a full trajectory Params u:float is the ikeda parameter x,y float: coordinates of the starting point N:int the number of iterations """ X = np.zeros((N, 2)) for n in range(N): X[n] = np.array((x, y)) t = 0.4 - 6 / (1 + x ** 2 + y ** 2) x1 = 1 + u * (x * math.cos(t) - y * math.sin(t)) y1 = u * (x * math.sin(t) + y * math.cos(t)) x = x1 y = y1 return X def plot_limit(X, n): """ Plot the last n points of the