restart; #Example. f(x) = 2*sin(3*x)+10*sin(5*x)+20*sin(11*x); # Display the signal graph, the magnitude graph, # and the phase graph. # Fourier transforms need the integral of |f(x)| to be finite. # Justify this detail below. Beware of trying to compute the value! u:=x->piecewise(x<0,0,1);f:=unapply((2*sin(3*x)+10*sin(5*x)+20*sin(11*x))*(u(x)-u(x-20)),x); cv:=1; #cv:=1/sqrt(2*Pi): Int(abs(f(x)),x=-infinity..infinity); #evalf(%); # Need a finite integral. F:=unapply(inttrans[fourier](cv*f(x),x,w),w); # Using Dirac approximation, if Dirac appears in F(w) # h:=0.8:ApproxDirac:=x->(1/(2*h))*(piecewise(x+h<0,0,1)-piecewise(x-h<0,0,1)); Mag:=unapply(abs(F(w)),w); Phase:=unapply(arctan(Im(F(w)),Re(F(w))),w); optx:=-1..21,scaling=unconstrained,thickness=3,discont=true: optw:=-1..21,scaling=unconstrained,thickness=2,color=blue: plot(f,optx);plot(Mag,optw);plot(Phase,optw); 110 10