Skip to main content

Exercises 5.4 Homework

1.

(No programming involved.) Prove that the following inequality holds for every positive integer \(n\text{:}\)

\begin{equation*} |\sin(1) + \sin(2) + \cdots + \sin(n)| \le 2 \end{equation*}

How does this explain the observation in Example 5.3.1?

Hint

Multiply the sum of sines by \(\sin(1/2)\) and use the formula

\begin{equation*} \sin(x)\sin(y) =\frac12 (\cos(x-y) - \cos(x+y)) \end{equation*}

to make the sum “telescope”.

2.

Write an anonymous function f = @(x, y) ... which implements the mathematical function

\begin{equation*} f(x, y) = \frac{xy^2}{x^2 + y^4} \end{equation*}

in such a way that the input variables x, y are allowed to be vectors. Then plot the values of \(f\) along the parametric curve

\begin{align*} x \amp = t^2 \\ y \amp = \sin t \end{align*}

as follows.

t = linspace(-1, 1, 500); 
plot(t, f(t.^2, sin(t)))

As \(t\) approaches 0, what value does \(f\) appear to approach?

3.

Write a named function function y = cositer(x, n) that takes two arguments x and n and returns the n-th iteration of the mathematical function \(x\mapsto 2\cos x\text{.}\) For example, if n = 4, the result should be

\begin{equation*} 2\cos(2\cos (2\cos (2\cos x)))) \end{equation*}

Use this function to plot several of these iterates on the interval \([0, 2]\) as shown below.

x = linspace(0, 2, 2000);   
hold on
for n = [4 5 30 31]
    plot(x, cositer(x, n))
end
hold off

function y = cositer(x, n)
   (your function goes here)
end

Remark: the command hold on refers to displaying several functions on the same plot. Normally, Matlab replaces each plot with next one. With hold on, it keeps the previous plot and draws next one over it, using a different color (unless you specify a color). At the end, hold off is used to restore the normal behavior.