Home » Posts tagged 'Math Art'
Tag Archives: Math Art
Swirl,Matlab Code
clc; clear all; close all; x = -20:0.1:20; sz = size(x); ind = 0; b = 6 for n = 1:15 % for i = 1:sz(2) for j = 1:sz(2) sw(i,j) = sin(b*cos(sqrt(x(i)^2+x(j)^2))-n*atan2(x(i),x(j))); end end ind = ind +1; fig = figure('Position',[0 0 800 800]); hold on; imagesc(sw); colormap bone; axis off; set(fig, 'color', [0 0 0]); set(gcf, 'InvertHardCopy', 'off'); hold off; %print(fig,['Sw',num2str(ind)],'-djpeg ','-r300'); close all; end
Ulam spiral,Prime factors spiral
Ulam spiral,prime spiral
clc; clear all; close all; sz = 201; mat = spiral(sz); pm = ~isprime(mat); figure('Position',[0 0 800 800]); imagesc(pm); colormap bone; caxis([0, 1]);axis off;
Prime factor colormap
Black dots are prime numbers. As lighter is the dot as higher is the number of prime factors of that number in the Ulam spiral.
sz = 201; mat = spiral(sz); matf = zeros(sz); for i = 1:sz for j = 1:sz fac = factor(mat(i,j)); fm = size(fac); matf(i,j) = fm(2); end end figure('Position',[0 0 800 800]); imagesc(matf); colormap hot; caxis([1, max(matf(:))]);axis off;
Ulam spiral of prime number of prime factors
Black dots corespondend to the numbers in Ulam spiral which has a prime number of prime factors.
sz = 201; mat = spiral(sz); matf = zeros(sz); for i = 1:sz for j = 1:sz fac = factor(mat(i,j)); fm = size(fac); matf(i,j) = fm(2); end end figure('Position',[0 0 800 800]); pm = ~isprime(matf); %sum(pm(:)); imagesc(pm); colormap bone; caxis([0, 1]);axis off;
Dragon Fractal
clc; clear all; close all;
a = ones(1); for i = 1:12 sz = size(a); b = a; ind = ceil(sz(2)/2); b(ind) = ~(b(ind)); sz = size(a); a = [a,1,b]; end st = 1; % Step len = size(a); x0 = 0; y0 = 0; %Initial Lv = 0; % Looking along positive x axis for i = 1:len(2) x1 = x0 - sin(Lv)*st; y1 = y0 + cos(Lv)*st; if a(i) == 1 Lv = Lv + pi/2; else Lv = Lv - pi/2; end xv(i) = x1; yv(i) = y1; x0 = x1; y0 = y1; end
fig = figure('Position',[0 0 800 800]); set(fig, 'color', [0 0 0]); plot(xv,yv,'clipping','off') axis off;
Box Fractals
clc; clear all; close all;
a = 1; figure('Position',[0 0 800 800]) for i = 1 :5 [n m] = size(a); Z = zeros(n,m); a = [a,Z,a; a,a,a; a,Z,a ]; end imagesc(a); colormap bone;axis off; caxis([0, 1]);
clc; clear all; a = 1; figure('Position',[0 0 800 800]) for i = 1 :5 [n m] = size(a); Z= zeros(n,m); a = [Z,a,Z; a,a,a; Z,a,Z ]; end imagesc(a); colormap bone;axis off; caxis([0, 1]);
clc; clear all; a = 1; figure('Position',[0 0 800 800]) for i = 1 :5 [n m] = size(a); Z= zeros(n,m); a = [a,a,a; a,Z,a; a,a,a ]; end imagesc(a); colormap bone;axis off; caxis([0, 1]);
clc; clear all; a = 1; figure('Position',[0 0 800 800]) for i = 1 :5 [n m] = size(a); Z= zeros(n,m); a = [a,Z,a; Z,a,Z; a,Z,a ]; end imagesc(a); colormap bone;axis off; caxis([0, 1]);
clc; clear all; a = 1; figure('Position',[0 0 800 800]) for i = 1 :5 [n m] = size(a); Z= zeros(n,m); if mod(i,2) == 0 a = [Z,a,a; a,a,a; a,a,a ]; else a = [a,a,a; a,Z,a; a,a,a ]; end end imagesc(a); colormap bone;axis off; caxis([0, 1]);