<- makeFun(ifelse(abs(t) <= 0.5, 1, 0) ~ t)
sq_wave slice_plot(sq_wave(t) ~ t, bounds(t=-1:1))
Chap 36 Exercises
\[ \newcommand{\dnorm}{\text{dnorm}} \newcommand{\pnorm}{\text{pnorm}} \newcommand{\recip}{\text{recip}} \]
Activities
Exercise 1 Here is a square-wave function:
Find the projection of the square wave onto each of these functions. Use the domain \(-1 \leq t \leq 1\).
- \(c_0 \equiv 1\)
- \(c_1 \equiv \cos(1 \pi t)\)
- \(c_2 \equiv \cos(2 \pi t)\)
- \(c_3 \equiv \cos(3 \pi t)\)
- \(c_4 \equiv \cos(4 \pi t)\)
- \(c_5 \equiv \cos(5 \pi t)\)
- \(c_6 \equiv \cos(6 \pi t)\)
- \(c_7 \equiv \cos(7 \pi t)\)
Hint: To find the scalar multiplier of projecting \(g(t)\) onto \(f(t)\), use \[\int_{-1}^1 g(t)\, f(t)\, dt {\LARGE /} \int_{-1}^1 f(t)\, f(t)\,dt\] or, in R/mosaic
<- Integrate(g(t)*f(t) ~ t, bounds(t=-1:1)) /
A Integrate(f(t)*f(t) ~ t, bounds(t=-1:1))
Then the projection of \(g()\) onto \(f()\) is \(A\, f(t)\).
Write down the scalar multiplier on each of the 8 functions above.
If you calculated things correctly, this is the linear combination of the 8 functions that best matches the square wave.
Loading required namespace: cubature
Exercise 2 Consider these functions/vectors on the domain \(0 \leq t \leq 1\):
- \(s_1(t) \equiv \sin(2\pi t)\)
- \(s_2(t) \equiv \sin(2 \pi 2 t)\) (that is, \(\omega = 2\))
- \(s_3(t) \equiv \sin(2 \pi 3 t)\) (that is, \(\omega = 3\))
- \(c_0(t) \equiv \cos(\pi t)\)
- \(c_1(t) \equiv \cos(2 \pi t)\)
- \(c_2(t) \equiv \cos(2 \pi 2 t)\)
Plot out each of the functions on the domain. How many complete cycles does each function complete as \(t\) goes from 0 to 1?
What is the length of each function?
All of the functions are mutually orthogonal except one. Which is the odd one out? (Hint: If the dot product is zero, the vectors are orthgonal.)
Exercise 3
Suppose we are interested in a domain \(0 \leq t \leq 10\) and a set of sinusoid functions:
\[s_1(t) \equiv \sin(2 \pi t/10)\\ s_2(t) \equiv \sin(4 \pi t/10)\\ s_3(t) \equiv \sin(6 \pi t/10)\\ c_1(t) \equiv \cos(2 \pi t/10)\\ c_2(t) \equiv \cos(4 \pi t/10)\\ c_3(t) \equiv \cos(6 \pi t/10) \]
Each of these functions goes through an integer number of cycles over \(0 \leq t \leq 10\), as you can confirm by graphing them, e.g.
<- makeFun(sin(2*pi*t/10) ~ t)
s1 <- makeFun(sin(4*pi*t/10) ~ t)
s2 # and so on
<- makeFun(cos(4*pi*t/10) ~ t)
c2 <- makeFun(cos(6*pi*t/10) ~ t)
c3 slice_plot(s1(t) ~ t, bounds(t=0:10)) %>%
slice_plot(c2(t) ~ t, color="blue")
Using the definition of the dot product between two functions as \[f(t) \bullet g(t) \equiv \int_0^{10} f(t)\, g(t) dt\ ,\]
- Calculate the “length” of each of the functions \(s_1(t), \ldots, c_3(t)\).
- Calculate the angle between each pair of functions.
To simplify your calculations, you might want to make use of these “helper” functions:
<- function(tilde1, tilde2, domain) {
fdot <- makeFun(tilde1)
f <- makeFun(tilde2)
g Integrate(f(t)*g(t) ~ t, domain)
}<- function(tilde1, tilde2, domain) {
fangle fdot(tilde1, tilde2, domain) /
sqrt(fdot(tilde1, tilde1, domain) *
fdot(tilde2, tilde2, domain))
}
- To judge from the set of angles you calculated, what about the functions \(s_1(t), \ldots, c_3(t)\) would make it easy to project a function \(h(t)\) onto the subspace spanned by the functions?