Homework Assignment 2#

Read the rules of homework assignments here: Homework Assignments. This assignment is intended to be done by hand without electronic aids unless specifically stated.

Remember to justify all answers.

Exercise 1: Calculating Cosine Values#

In Python, the value of e.g. \(\cos(\sqrt{17})\) is presented approximately when you do the call:

import math

print(math.cos(math.sqrt(17)))

But how does the computer know this value? A computer either uses a precomputed lookup table or approximating polynomials or a mix of the two. In this exercise we will have a look at how this can be done using Taylor polynomials.

Consider a function \(f:\mathbb{R} \rightarrow \mathbb{R}\) given by the expression:

\[\begin{equation*} f(x)=\cos (x). \end{equation*}\]

Question a#

Determine the approximating polynomial \(P_4 = P_{4,f,x_0}\) of degree (no higher than) four of the cosine function with expansion point \(x_0 = 0\).

Question b#

Use your found polynomial \(P_4\) to find an approximate value of \(\cos(1/2)\), and evaluate how far this value is from the exact value.

Question c#

Let \(I = [-\pi/2, \pi/2]\). Use Theorem 4.3.3 to show that

\[\begin{equation*} \lvert \cos(x) - P_4(x) \rvert \le \frac{(\pi/2)^5}{5!} < \frac{2^5}{5!} \end{equation*}\]

for all \(x \in [-\pi/2, \pi/2]\). Explain in your own words what the number

\[\begin{equation*} \max_{x \in [-\pi/2, \pi/2]} \lvert \cos(x) - P_4(x) \rvert \end{equation*}\]

describes.

Question d#

Show that the \(K\)’th-degree Taylor polynomial \(P_K\) of the cosine function with expansion point \(x_0 = 0\) fulfills

\[\begin{equation*} \lvert \cos(x) - P_K(x) \rvert < \frac{2^{K+1}}{(K+1)!} \end{equation*}\]

for all \(x \in [-\pi/2, \pi/2]\). Determine \(K\) such that the error is smaller than \(10^{-10}\). By “error” we mean the largest numerical deviation between \(P_K(x)\) and \(\cos(x)\) for \(x \in [-\pi/2, \pi/2]\).

Question e#

We can now with a rather good precision calculate \(\cos(x)\) for any \(x \in [-\pi/2, \pi/2]\) by use of the Taylor polynomial \(P_K\) with expansion point \(x_0 = 0\) (for a fixed but sufficiently large choice of \(K\)). But how do we effectively calculate an approximate value of \(\cos\) on the rest of the real line, meaning when \(x\) is located outside the interval \([-\pi/2, \pi/2]\)?

To answer this question we let \(x \in [-\pi/2, \pi/2]\) be given and assume that the value of \(\cos(x)\) is known (e.g., computed approximately as above). Explain how you for an arbitrarily given \(y \in \mathbb{R}\) can now find the value of \(\cos(y)\).

Exercise 2: L’Hôpital’s Rule and Taylor’s Limit Formula#

L’Hôpital’s Rule is used for determination of limits of the type \(\displaystyle\lim_{x \to a} \frac{f(x)}{g(x)}\), where \(f(a)=0\) and \(g(a)=0\). The limit is in this case said to be of the type \(\frac{0}{0}\). The rule says:

Theorem (L’Hôpital’s Rule)

Let \(I \subseteq \mathbb{R}\) be an open interval, let \(a \in I\), and let \(f\) and \(g\) be differentiable on \(I\setminus \{a\}\). Assume that:

  1. \(\displaystyle\lim_{x \to a} f(x) = \lim_{x \to a} g(x) = 0\),

  2. \(g'(x) \neq 0\) for \(x \in I \setminus \{a\}\), and

  3. the limit \(\displaystyle\lim_{x \to a} \frac{f'(x)}{g'(x)}\) exists.

Then it holds true that:

\[\begin{equation*} \lim_{x \to a} \frac{f(x)}{g(x)} = \lim_{x \to a} \frac{f'(x)}{g'(x)}. \end{equation*}\]

Consider the limit:

\[\begin{equation*} \lim_{x \to 0} \frac{\ln(1 + x)}{1 - \sqrt{1 + x}}. \end{equation*}\]

Question a#

Show that this limit is of the type \(\frac{0}{0}\).

Question b#

Check that \(g'(x) \neq 0\) for \(x\) close to \(0\), which would mean that we can use the rule.

Question c#

Apply L’Hôpital’s Rule to determine the limit value.

Question d#

Find the same limit by using Taylor’s limit formula for \(\ln(1 + x)\) and \(\sqrt{1 + x}\) up to a fitting order.

Question e#

Prove L’Hôpital’s Rule from Taylor’s limit formula for general functions \(f(x)\) and \(g(x)\) that fulfill the assumptions in L’Hôpital’s Rule.

Note

You may assume that \(g'(a) \neq 0\). This often applies (for instance in our application) and makes the proof simpler.

Exercise 3: Image Set of Continuous, Differentiable Function#

Let \(B\) be the set \(B=\left\{ (x_1 , x_2) \in \mathbb{R}^2 \mid x_1^2 + x_2^2 \leq 2 \wedge x_1 \leq 0 \right\}\).

A function \(f:B \rightarrow \mathbb{R}\) is given by:

\[\begin{equation*} f(x_1 ,x_2) = x_1^2​ + x_2^2 + x_1​ + 1. \end{equation*}\]

State the image set (the range) of \(f\).

Exercise 4: Local Extrema#

A function \(f:\mathbb{R}^2 \rightarrow \mathbb{R}\) is given by:

\[\begin{equation*} f(x_1 ,x_2 )=x_1^2 - 2x_1 +3x_2^5 - 5x_2^3. \end{equation*}\]

Question a#

Find all stationary points of \(f\).

Question b#

Characterize the stationary points as either local maximum, local minimum, or saddle point of the function.

Question c#

For each stationary point, plot in Python the function along with its approximating polynomial \(P_{2}\) of degree (no higher than) two expanded from the stationary point.