Chap 36 Exercises

\[ \newcommand{\dnorm}{\text{dnorm}} \newcommand{\pnorm}{\text{pnorm}} \newcommand{\recip}{\text{recip}} \]

Activities

Exercise 1 Here is a square-wave function:

sq_wave <- makeFun(ifelse(abs(t) <= 0.5, 1, 0) ~ t)
slice_plot(sq_wave(t) ~ t, bounds(t=-1:1))

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

A <- Integrate(g(t)*f(t) ~ t, bounds(t=-1:1)) / 
  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)\)
  1. Plot out each of the functions on the domain. How many complete cycles does each function complete as \(t\) goes from 0 to 1?

  2. What is the length of each function?

  3. 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.

s1 <- makeFun(sin(2*pi*t/10) ~ t)
s2 <- makeFun(sin(4*pi*t/10) ~ t)
# and so on
c2 <- makeFun(cos(4*pi*t/10) ~ t)
c3 <- makeFun(cos(6*pi*t/10) ~ t)
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\ ,\]

  1. Calculate the “length” of each of the functions \(s_1(t), \ldots, c_3(t)\).
  2. Calculate the angle between each pair of functions.

To simplify your calculations, you might want to make use of these “helper” functions:

fdot <- function(tilde1, tilde2, domain) {
  f <- makeFun(tilde1)
  g <- makeFun(tilde2)
  Integrate(f(t)*g(t) ~ t, domain)
}
fangle <- function(tilde1, tilde2, domain) {
  fdot(tilde1, tilde2, domain) /
    sqrt(fdot(tilde1, tilde1, domain) * 
         fdot(tilde2, tilde2, domain))
}
  1. 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?
No answers yet collected