# > restart; > #In this worksheet we use maple to compute some Fourier transform and > graph the results. We can define a function as a integral. The > function defined in the next line is the Fourier transform of the > characteristic function of the interval [-1,1]: > c := x->int(exp(-I*x*y),y=-1..1); > #To numerically evaluate such a function use the "eval" command: > evalf(c(15)); > #Usually its better to just let maple do the integral for you and then > use the answer to explicitly define a function. > int(exp(-I*x*y),y=-1..1); > #In the next line we use the "piecewise" command to define a function > which is given by different formulae in different parts of the real > line. We also plot the answer. This is the twice the sinc-function. > g := x->piecewise(0 plot(g(x),x=-30..30, discont=true); > # Maple can be used to define a function in terms of an integral with > a parameter: > hh := x-> int(s*exp(-(1/(1-s^2)))*sin(x*s),s=0..0.98); > > #To obtain a numerical result use the "evalf" command. > evalf(hh(200)); > #Using the implicit form we can plot a function defined as above in > terms of an integral. Notice that no explicit variable name appears in > the next command. > plot(hh,0..10); > #Frequently its faster to just compute some equally spaced values. > for j from 0 to 100 do hhh[j] := hh(j/20) od: > > #Here we define the "noise" functions with the slowly decaying Fourier > transforms. > ff := (x,k)->evalf(sum(cos(x*n^k)/n^2,n=1..300)); > #We compute some values of this function for k=6. > for jj from 0 to 100 do fff[jj] := ff(jj/20,6) od: > #In the next line we create a list of points made out of the products > of the values of ff and hh. We plot the list in the following command. > ll := [seq([k/20,fff[k]*hhh[k]],k=0..100)]: > plot(ll,x=0..5); > #Now we do the same computations but with k=10. > for j3 from 0 to 100 do f2[j3] := ff(j3/20,10) od: > #We make the vector of points to plot: > l1 := [seq([k/20,hhh[k]*f2[k]],k=0..100)]: > #We plot this funtion. Note that the x-axis runs from 0 to 5: > plot(l1,x=0..5); > #We now examine this function at finer scales. First we magnify (in > the x-axis) by a factor of 10. > for jj from 0 to 100 do ffff[jj] := ff(jj/200,10) od: > for j from 0 to 100 do h2[j] := hh(j/200) od: > l2 := [seq([k/200,h2[k]*ffff[k]],k=0..100)]: > #We plot the scaled data. Observe that now the x-axis runs from 0 to > .5. > plot(l2,x=0..0.5); > #We see that this plots is quite similar to the first one. Scaling in > the x-variable does not seem to simplify this function at all! That's > because we are examining a continuous but NON-differentiable. We > finish by magnifying one more time, this time by a factor of 5. > for jj from 0 to 100 do f5[jj] := ff(jj/1000,10) od: > for j from 0 to 100 do h5[j] := hh(j/1000) od: > l3 := [seq([k/1000,h5[k]*f5[k]],k=0..100)]: > #In the last plot the x-axis runs from 0 to 0.1. > plot(l3,x=0..0.1); > #Even at this scale there is no noticable simplification. Try these > routines out with functions of your own design!