%%  竹镯糸篝揆轱 9/10/2015
%% variables
a = 2*(1-2^(-5));
disp(a);
disp(['a = ', num2str(a)]);
x = cos(pi/3);
disp(['x = ', num2str(x)]);
%% complex variables
z = complex(0);
z = z+1i;
disp(z);
disp(exp(z));
disp(exp(0.5*pi*z));
z1 = 1+1i;
z2 = 1-1i;
w=z1^2010+z2^2010;
disp(w);
%% flow control
z = 0;
n=0;
while abs(z)<10
    z = z^2-z+1i;
    n=n+1;
end
disp(n);
clear all
%% roots
z = roots([1 0 0 0 4]);  %z^4+4 = 0
disp(sum(z(1:2).^10));
disp(z(1)^4+4);
clear z;
z = roots([1 zeros(1,9) -1]); %z^10 = 1
disp(z);
w = 2./(1+z(2:10));
disp(w);
clear all
%% plot
t = linspace(0,10,1000);
disp(size(t));
figure; plot(t,exp(-t));
title('exponential function');
xlabel('t'); ylabel('x(t)');
clear all;
close all;
%% symbolic computation
syms t;
x2 = heaviside(t)-heaviside(t-5);  % u(t) - u(t-5)
figure; ezplot(t,x2,[0,10]);
figure; ezplot(t,x2*cos(10*pi*t),[0,10]);
x4 = exp(-t)*heaviside(5-t);  % e^(-t) u(5-t)
figure; ezplot(t,x4,[0,10]);