The following lines of text are the Maple commands I used to generate
the pictures asked for in quiz 4.
> f:=x->(1+x)*Heaviside(-x) -Heaviside(x);
f := x -> (1 + x) Heaviside(- x) - Heaviside(x)
> g:=proc(x)
> if x < -1 then -1 elif x < 0 then 1+x elif x < 1 then -1 elif x < 2 then 1+ (x-2) fi;
> end;
g := proc(x) if x < -1 then -1 elif x < 0 then 1+x elif x < 1 then -1 elif x < 2 then -1+x fi end
--------------------------------------------------------------------------------
> Int(f(x),x=-1..1);a[0]:=value(");
1
/
|
| (1 + x) Heaviside(- x) - Heaviside(x) dx
|
/
-1
a[0] := -1/2
--------------------------------------------------------------------------------
> i:='i':for i from 1 to 15 do
--------------------------------------------------------------------------------
> int(f(x)*cos(i*Pi*x),x=-1..1); a[i]:=evalf("):od:
--------------------------------------------------------------------------------
> i:='i':for i from 1 to 15 do
> int(f(x)*sin(i*Pi*x),x=-1..1); b[i]:=evalf("):od:
--------------------------------------------------------------------------------
> s15:=x->a[0]/2 + sum(a[j]*cos(j*Pi*x)+b[j]*sin(j*Pi*x),j=1..15);j:=`j`:
/ 15 \
|----- |
| \ |
s15 := x -> 1/2 a[0] + | ) (a[j] cos(j Pi x) + b[j] sin(j Pi x))|
| / |
|----- |
\j = 1 /
--------------------------------------------------------------------------------
> fplot:=plot(g,-1.5..1.5,style=point):fourierplot:=plot(s15(x),x=-1.5..1.5):
> with(plots):text:=textplot([1,3,`plot of f and s15`]):
--------------------------------------------------------------------------------
> display({fplot,fourierplot,text});
** Maple V Graphics **
--------------------------------------------------------------------------------
>
** Maple V Graphics **
--------------------------------------------------------------------------------