// bn's t = -%pi:0.05:%pi; [n, m] = size(t); function y = f(t) y = (%pi-t)/2; endfunction; n = 10; b=zeros(1,n); for i=1:n, b(i)=(1/%pi)*integrate('f(x)*sin(i*x)','x',0,2*%pi,0.0000001); end; for i=1:n, printf("1/b[%d] = %f\n", i, 1/b(i)); end; p=zeros(n,m); for j=1:m, p(1,j) = b(1)*sin(t(j)); end; for i=2:n, for j=1:m, p(i,j) = p(i-1,j)+b(i)*sin(i*t(j)); end; end; clf(); plot(t,p) g=zeros(t); for j = 1:m, if t(j) < 0 then g(j) = f(t(j)+2*%pi); else g(j) = f(t(j)); end; end; plot(t,g,"k-")