Untitled

mail@pastecode.io avatar
unknown
plain_text
5 months ago
1.6 kB
2
Indexable
%% s3
b = 0.3;
epsilon = 0.005;
a_eps = 0.001;
l = 2;
x = linspace(-l, l, floor(1/epsilon));
y = linspace(-l, l, floor(1/epsilon));
a = linspace(a_eps, 10, floor(1/a_eps));
p_3 = zeros(floor(1/a_eps), floor(1/epsilon), floor(1/epsilon));
for i=1:floor(1/a_eps)
    for j=1:floor(1/epsilon)
        for k=1:floor(1/epsilon)
            p_3(i, j, k) = check_3_period(a(i), b, x(j), y(k), 0.0001);
        end
    end
end
if isequaln(p_3, zeros(floor(1/a_eps), floor(1/epsilon), floor(1/epsilon)))
 disp(":(")
else
    non_zero = mod(find(p_3), floor(1/a_eps)).*10./floor(1/a_eps);
    non_zero = sort(non_zero);
    zero = find(~p_3);
    disp(non_zero)
end
%% s4
b = 0.3;
a = 6;
l = 10;
epsilon = 0.005;
x = linspace(-l, l, floor(1/epsilon));
y = linspace(-l, l, floor(1/epsilon));
p_3 = zeros(floor(1/epsilon), floor(1/epsilon));
for j=1:floor(1/epsilon)
    for k=1:floor(1/epsilon)
        p_3(j, k) = check_3_period(a, b, x(j), y(k), 0.0001);
    end
end

if isequaln(p_3, zeros(floor(1/epsilon), floor(1/epsilon)))
 disp(":(")
else
    non_zero = mod(find(p_3), floor(1/eps)).*4./floor(1/eps);
    non_zero = sort(non_zero);
    zero = find(~p_3);
    disp(non_zero)
end

%% functions
function t = T(a, b, x, y)
    t = [1-a.*x.^2.+y, b.*x];
end

function res = Tn(a, b, x, y, n)
    res = [x, y];
    for i=1:n
        res = T(a, b, res(1), res(2));
    end
end

function is_3_periodic = check_3_period(a, b, x, y, eps)
    T3 = Tn(a, b, x, y, 3);
    if (T3(1)-x).^2+(T3(2)-y).^2<eps
        is_3_periodic = 1;
    else
        is_3_periodic = 0;
    end

end
Leave a Comment