| > |
lab5.mws --- Trigonometric Integrals
| > | restart; with( plots ): |
| > |
Auxiliary Plotting Commands -- execute, do not modify!
| > | FourierAnim := proc(f,n) local a, b, Fcos, Fsin, Pf, Psincos; a := (f,n) -> int( f*sin(n*x), x=-Pi..Pi )/Pi: b := (f,n) -> int( f*cos(n*x), x=-Pi..Pi )/Pi: Fsin := (f,n) -> add( a(f,m)*sin(m*x), m=1..n ): Fcos := (f,n) -> b(f,0)/2 + add( b(f,m)*cos(m*x), m=1..n ): Psincos := (f,n) -> plot( Fsin(f,n)+Fcos(f,n), x=-3*Pi..3*Pi, color=blue ): Pf := plot( f, x=-Pi..Pi ): return display( [seq( display( [Psincos(f,m),Pf], title=sprintf("n=%a",m) ), m=1..n )], insequence=true ): end proc: |
Lab Overview
This lab is intended to replace a need to lecture on Section 8.2.
Our first example will be to compute the definite integrals integrals
.
We will conclude the demonstration with the Fourier sine and cosine coefficients of a function. These computations will be illustrated with an example based on the "square wave function" defined to be -1 on (
, 0 ) and 1 on ( 0,
) and extended periodically with periodic
.
The questions at the end of this lab require you to apply the two examples to slightly different situations. In particular, Questions 4, and 5 refer to the "sawtooth function". This is the function that is defined to be the periodic extension of the linear function
on [
,
]. The topics in this lab are the basis for a later lab on Fourier Series.
| > |
Example 1 -
The functions
, where
= 1, 2, 3, ..., have the property that
. In this example we will verify this claim.
Step 1: Develop Intuition with Graphical Animations
We begin by looking at the graph of the products
for all combination of
= 1, 2, .., 6 and
= 1, 2, .., 6.
| > | sm := sin(m*x); sn := sin(n*x); |
| > | N := 6: for m from 1 to N do q := [seq( plot( sm*sn, x=-Pi..Pi, view=[-Pi..Pi,-1..1], title=sprintf("Plot of %a*%a", sm, sn) ), n=1..N )]: P||m := display( q, insequence=true ); end do: unassign( 'm', 'n' ); |
The above loop creates an animation,
Pn
, for each
= 1, 2, .., 6. Now, we display these animations. In each animation, try to determine if the "area" under the curve is positive, negative, or zero. Hint: Look for symmetries.
| > | P1; |
| > | P2; |
| > | P3; |
| > | P4; |
| > | P5; |
| > | P6; |
| > |
| > |
Step 2: Analytic Evaluation with Maple
Next, we attempt to evaluate these definite integrals. To get started we use
,
= 1, 2, 3 (please increase this to 10, and do not be concerned with the display of the 10x10 matrix). This time the results will be displayed in a matrix. To facilitate this, define a Maple function that accepts the values of
and
and returns the definite integral
.
| > | N := 3: F := unapply( Int( sm*sn, x=-Pi..Pi ), (m,n) ): M := Matrix( N, N, F, shape=symmetric ); |
Then ask Maple to evaluate the integrals
| > | M = map( value, M ); |
| > |
Step 3: Explicit Evaluation of the Definite Integrals
How did Maple do this? The answer involves using some trigonometric identities for products of sine functions.
| > | Smn := sm*sn: q1 := combine( Smn, trig ): Smn = q1; |
When each side of this equation is integrated with respect to
:
| > | q2 := Int( q1, x ): q3 := value( q2 ): Int( Smn, x ) = q2; ` ` = q3; |
Observe that this formula does not make sense when
(or
, but that is not an issue at this time). Because the sine function has value 0 for all integer multiples of
(and because
and
are integers when
and
are integers), it is pretty clear that the value of the antiderivative at
is 0 and the value at
is 0:
| > | eval( q3, x=Pi ) assuming integer; |
| > | eval( q3, x=-Pi ) assuming integer; |
Hence,
whenever
and
are integers with
.
To study the case when
note that the product of sine functions simplifies to a square:
| > | Smm := eval( Smn, n=m ); |
Here the appropriate trigonometric identity is
| > | q4 := combine( Smm, trig ): Smm = q4; |
Once again, this expression is easily integrated with respect to
:
| > | q5 := Int( q4, x ): q6 := value( q5 ): Int( Smm, x ) = q5; ` ` = q6 + C; |
When this antiderivative is evaluated at
and
, the results are
| > | q7 := eval( q6, x=Pi ) assuming integer: q7; |
and
| > | q8 := eval( q6, x=-Pi ) assuming integer: q8; |
respectively, Therefore,
| > | Int( Smm, x=-Pi..Pi ) = q7 - q8; |
This verifies the result obtained automatically by Maple in the previous section and the general result:
| > |
Example 2 - Fourier sine and cosine coefficients for the sign function
Let f be a function defined on the interval (
,
). The Fourier sine and cosine coefficients of f are defined to be
, for
= 1, 2, 3, ....
, for
= 0, 1, 2, ....
To illustrate this definition, let f be the ``sign function'':
.
In Maple, this function is implemented with the signum command.
| > | plot( signum(x), x=-Pi..Pi, discont=true, title="The sign function" ); |
| > |
The Fourier sine coefficients for this function are defined in terms of the definite integral
| > | q1 := Int( signum(x)*sin(n*x), x=-Pi..Pi )/Pi: a[n] = q1; |
| > |
Step 1: Develop Intuition with Graphical Animations
Sine Coefficients
First, we look at the graph of the products
for
= 1, 2, .., 10.
| > | sn := sin(n*x); |
| > | N := 10: q := [seq( plot( signum(x)*sn, x=-Pi..Pi, view=[-Pi..Pi,-1..1], title=sprintf("Plot of %a", signum(x)*sn) ), n=1..N )]: display( q, insequence=true ); |
| > |
Cosine Coefficients
Repeating this step for the cosine coefficients for
= 0, 1, 2, .., 10:
| > | cn := cos(n*x); |
| > | N := 10: q := [seq( plot( signum(x)*cn, x=-Pi..Pi, view=[-Pi..Pi,-1..1], discont=true, title=sprintf("Plot of %a", signum(x)*cn) ), n=0..N )]: display( q, insequence=true ); |
| > |
Step 2: Analytic Evaluation with Maple
Next, we attempt to evaluate the definite integrals for the sine and cosine coefficients.
Sine Coefficients
To get started we use
= 1, 2, .., 10. This time the results will be displayed in a column vector. To facilitate this, define a Maple function that accepts a value for
and returns the definite integral
| > | N := 10: A := unapply( Int( signum(x)*sn, x=-Pi..Pi )/Pi, n ): M := Matrix( N, 1, A ); |
To evaluate these integrals
| > | M = map( value, M ); |
| > |
Cosine Coefficients
Repeating these steps for the cosine coefficients:
| > | N := 10: B := unapply( Int( signum(x)*cn, x=-Pi..Pi )/Pi, n ): M := Matrix( N, 1, B ); |
To evaluate these integrals
| > | M = map( value, M ); |
Here the pattern is pretty obvious!
But, we still have to compute
. Replace the %? in the following command to create a valid Maple command to compute
. Then, execute both commands (in order) and find the value of
.
| > | B0 := %? ; |
| > | value( B0 ); |
| > |
To conclude, we have discovered that
, for all
= 1, 2, 3, ....
, for all
= 0, 1, 2, ....
| > |
Step 3: Explicit Evaluation of the Definite Integrals
To evaluate these integrals by hand, we would divide the interval (
,
) into two pieces (
, 0 ) and ( 0,
).
| > |
Sine Coefficients
| > | q2 := Int( signum(x)*sin(n*x), x=-Pi..Pi )/Pi: A(n) = q2; ` ` = value( q2 ); |
When we tell Maple that n (and any other variables in this expression) are integers:
| > | value( q2 ) assuming integer; |
To reduce this even further, look at the cases when n is odd and even separately:
| > | value( q2 ) assuming odd; |
| > | value( q2 ) assuming even; |
This is consistent with the results found in Steps 1 and 2.
| > |
Cosine Coefficients
| > | q3 := Int( signum(x)*cos(n*x), x=-Pi..Pi )/Pi: B(n) = q3; `` = value( q3 ); |
This, too, is consistent with the results found in Steps 1 and 2.
| > |
Discussion
Why do we care about Fourier sine and cosine coefficients. While this will be studied in greater detail in a later lab, here is a preview. Define the functions
for
= 1, 2, ....
Note that more and more coefficients are used in
as n increases. The following
FourierAnim
command creates a 12-frame animation in which each frame consists of the signum function on [
,
] and
on [
,
].
| > | FourierAnim( signum(x), 12 ); |
Notice how the graphs of
have period
for all
. Moreover, as
increases, the graphs of
provide better and better approximations to the signum function on [
,
].
| > |
Lab Questions
1. Consider
for integers
and
. What is the value of
?
2. Consider
for integers
and
. What is the value of
?
Hint: Lab Questions 1 and 2
| > | cm := cos(m*x); cn := cos(n*x); |
Copy the Example 1 section (or selected Steps) here twice - once for Question 1 and once for Question 2. Use cm and cn defined above to replace appropriate occurrence of sm and sn in Example 1 and execute the appropriate commands.
| > |
3. For the square wave,
. Why is
?
4. The ``sawtooth function'' is
, for
<=
<=
, and f is periodic with period
, i.e.,
for
<=
<=
and
an integer.
Find the Fourier sine coefficient for the sawtooth function. Report both the general formula and the first five Fourier sine coefficients.,
,
= 1, 2, .., 5.
Hint: Lab Question 4
To implement the sawtooth function in Maple, you may write either
f
(after executing the following command) or, since all integration will be done on (
,
), simply type
x
whenever you need to reference the function f.
| > | f := x; |
I recommend copying the Example 2 section (or selected Steps from Example 1) and pasting it following this hint. Make the changes in the copy of Example 2.
| > |
5. Use the
FourierAnim
command to create an animation showing that the graphs of
converge to the sawtooth function. What is the smallest value of
for which the graph of
has a maximum value larger than
? Write this function
.
Hint: Lab Question 5
Replace the
%?
with an integer and look at the individual frames to answer this question. Do not make
too small or too large.
| > | FourierAnim( x, %? ); |
| > |
6. [Essay Question] Let
=
. Explain why
=
.
Note that all integrals that arise in this problem have been evaluated earlier in this lab. You can use the fact that
without explanation.
| > |
| > |