Week 7: The Riemann Integral in 1D and 2D#

Key Terms#

  • The Riemann integral (the definite integral)

  • Subdivisions and mid-sums

  • The fundamental theorem of calculus

  • Anti-derivatives (the indefinite integral)

  • Partial integration and integration by substitution

  • Riemann integration of functions of two variables

  • Coordinate changes in 2D

  • Polar coordinates

Preparation and Syllabus#

  • Reading material: Sections 6.1 through 6.3


Exercises – Long Day#

1: Anti-Derivatives to learn by Heart#

For which of the following functions can you immediately provide an anti-derivative?

  1. \(x^n, \, n \in \mathbb{N}\)

  2. \(\frac{1}{x}\)

  3. \(\ln(x)\)

  4. \(\frac{1}{1+x^2}\)

  5. \(\cos(x)\)

  6. \(\sin(x)\)

  7. \(\exp(x)\)

For those where you had to give up, find an anti-derivative with SymPy’s integrate, and then please add them to your long-term memory.

2: Eight Anti-Derivatives you must master#

State an anti-derivative for each of the following function:

  1. \(x^n\,\) where \(n\) is an arbitrary constant in \(\mathbb Z\).

  2. \(x^k\) where \(k\) is an arbitrary constant in \(\mathbb Q\).

  3. \(\frac{1}{a\cdot x+b}\), where \(a\neq 0\) and \(b\) are arbitrary constants in \(\mathbb{R}\), and \(x\) belongs to a fitting interval.

  4. \(\cos(a x+b)\) where \(a\neq 0\) and \(b\) are arbitrary constants in \(\mathbb{R}\).

  5. \(f'(x)\) where \(f\) is differentiable.

  6. \(\sin(ax+b)\) where \(a\neq 0\) and \(b\) are arbitrary constants in \(\mathbb{R}\).

  7. \(\exp(a x+b)\) where \(a\neq 0\) and \(b\) are arbitrary constants in \(\mathbb{R}\).

  8. \(\exp(a x+b)\) where \(a\neq 0\) and \(b\) are arbitrary constants in \(\mathbb{C}\).

3: Computational Rules for Anti-Derivatives. By Hand#

Determine the indefinite integral \(\int \left( 5\cos(x+1)-\sin(5x)+\frac{2}{x-3}-7\right)\,\mathrm{d}x\) for \(x>3\) and explain the computational rules you used along the way.

4: The Fundamental Theorem. By Hand#

Question a#

Provide an anti-derivative for \(\frac{1}{1+x^2}\). Then compute the integral \(\int_0^1\,\frac{1}{1+x^2}\,\mathrm{d}x\).

Question b#

Compute the double integrals

\[\begin{equation*} \int_1^2\,\Big (\int_0^1\,\frac{\text{e}^{2x}}{y}\,\mathrm{d}x\Big)\mathrm{d}y \end{equation*}\]

and

\[\begin{equation*} \int_0^{\frac{\pi}{2}}\,\Big (\int_0^1\,y\cos(xy)\,\mathrm{d}x\Big)\mathrm{d}y. \end{equation*}\]

Question c#

Let \(f: [-5,5] \to \mathbb{R}\) be given by

\[\begin{equation*} f(x) = \begin{cases} 1 & \text{for } x \in [0,1] \\ 0 & \text{for } x \in [-5,5] \setminus [0,1]. \end{cases} \end{equation*}\]

Compute

\[\begin{equation*} F(x) = \int_{x_{0}}^{x} f(y) \,\mathrm{d} y \quad \text{for $x \in [-5,5]$}, \end{equation*}\]

where \(x_{0}\in [-5,5]\) is fixed but arbitrary. Choose e.g. \(x_0=0\). Is \(F\) continuous? Is \(F\) differentiable at all points? Does \(f\) have an anti-derivative?

5: Parametrizations in the Plane#

Consider the sets \(V, U \subset \mathbb{R}^2\) given by

\[\begin{equation*} V = \bigl\{ (x,y) \in \mathbb{R}^2 \,\big|\, x \ge 1 \wedge y \ge 0 \wedge x + y \le 3 \bigr\} \end{equation*}\]

and \(U = B((0,0),2) \setminus \overline{B((0,0),1)}\), where \(B((0,0),r)\) is the open circle disc (also referred to as an open ball) with a radius of \(r\) centered at \((0,0)\), and \(\overline{B((0,0),r)}\) is the corresponding closed circle disc (where the boundary is included).

Question a#

Provide a parametrization \(\pmb{r}_1: [0,1]^2 \to V\) of \(V\). The vector function \(\pmb{r}_1\) must be a function of two variables, for example \((u,v) \in [0,1]^2\), and the image of \(\pmb{r}_1\) must be \(V\).

Note

The function \(\pmb{r}_1\) ought to be injective on the open set \(]0,1[^2\), although it is not a requirement.

Question b#

Provide a parametrization \(\pmb{r}_2: ]1,2[ \times [0,2\pi[ \to U\) of \(U\). The vector function \(\pmb{r}_2\) must be a function of two variables, for example \((r,\theta) \in ]1,2[ \times [0,2\pi[\), and the image of \(\pmb{r}_2\) must be \(U\).

6: The Trapezoidal Rule and Riemann Sums#

Many integrals exist for which is it not possible to compute their “exact” values, often because their anti-derivatives cannot be expressed in terms of “known” functions. In this exercise we want to compute an approximated value of

\[\begin{equation*} \int_0^3\sin(x^2)\mathrm{exp}(3x)\,\mathrm dx. \end{equation*}\]

The SciPy package in Python can compute (approximations of) integrals using so-called numerical integration. We will here compare SciPy’s quad method to both the Riemann sum that we know from the book and to the so-called trapezoidal rule.

The trapezoidal rule refers to the approximation to an integral over a small interval \([x_{j-1},x_j]\) given by

\[\begin{equation*} \int_{x_{j-1}}^{x_{j}}f(x)\,\text{d}x=\frac{1}{2}(x_{j}-x_{j-1})(f(x_{j-1})+f(x_{j})), \end{equation*}\]

while we with mid-sums in the Riemann integral with the choice \(\xi_j:=\frac{x_j+x_{j-1}}{2}\) have

\[\begin{equation*} \int_{x_{j-1}}^{x_{j}} f(x)\,\text dx\approx f(\xi_j)(x_{j}-x_{j-1}). \end{equation*}\]

If one with the trapezoidal rule wants to approximate an integral over a larger interval \([a,b]\), one can subdivide it into several smaller intervals \(Q_j=[x_{j-1},x_j]\), \(j=1,\ldots,J\), and approximate on those individually, after which they can all be added together - precisely as for Riemann sums.

Question a#

Argue that \(\sin(x^2)\mathrm{exp}(3x)\) has an anti-derivative, and that the integral \(\int_0^3\sin(x^2)\mathrm{exp}(3x)\,\mathrm dx\) is well-defined. Try (in SymPy) to find the exact value of

\[\begin{equation*} \int_0^3\sin(x^2)\mathrm{exp}(3x)\,\mathrm dx. \end{equation*}\]

Use .evalf() to get an approximate value of the integral.

Question b#

Compute the integral with quad from scipy.integrate. You must import from scipy.integrate import quad and define

def f(x):
    return sin(x**2)*exp(3*x)

Question c#

We want to compare this with the Riemann integral that we have worked with previously. We use Riemann sums, where \([a,b]\) is subdivided into \(J\) equally large sub-intervals. Can you implement a function in Python that does this calculation for you? It must be of the form

def riemann(f,a,b,J):

where \(f\) is a continuous function, \(a\) and \(b\) are interval end-points, and \(J\) is the number of subdivisions of the integral. When you have written it you can test it on the same integral as above with \(J=20\).

Question d#

Using the trapezoidal rule we no longer approximate the area under a graph with a rectangle. Can you figure out how the shape looks based on the formula above?

Question e#

Now implement the trapezoidal rule:

def trapez_sum(f,a,b,J):

where \(f\) is a continuous function, \(a\) and \(b\) are the interval end-points, and \(J\) is the number of subdivisions of the integral. When you have written the program, you can test it on the same integral as above with \(J=20\).

Question f#

We do not seem to get the same value of the integral. Compare your results from Questions a, b, c, and e. Which method is better? Why? Also try with both more and fewer subdivisions of the interval.

7: An Indefinite Integral. By Hand#

Question a#

The following is not a Riemann integral: \(\int_0^1 \frac{1}{\sqrt{x}} \,\mathrm{d} x\). Why not?

Question b#

Compute \(\int_0^1 \frac{1}{\sqrt{x}} \,\mathrm{d} x\) as \(\lim_{a \to 0} \int_a^1 \frac{1}{\sqrt{x}} \,\mathrm{d} x\).

Question c#

Compute in a similar manner the integral \(\int_1^\infty \frac{1}{\sqrt{x}} \,\mathrm{d} x\) (if possible).

8: Variable Substitution for an Integral in 2D#

Compute the integral

\[\begin{equation*} \int_{0}^1\int_1^8\frac{y}{x+xy}\,\text{d} x\,\text{d}y \end{equation*}\]

by performing a variable substitution.

Exercises – Short Day#

1: Indefinite and Definite Integrals#

Question a#

Determine an anti-derivative for each of the functions

\[\begin{equation*} x^3, \quad \frac{1}{x^3}, \quad \text{and} \quad \sin(3x-\frac{\pi}{2}). \end{equation*}\]

Question b#

Compute the following Riemann integrals:

\[\begin{equation*} \int_0^{1}x^3\,\mathrm{d}x, \quad \int_1^{2}\frac{1}{x^3}\,\mathrm{d}x, \quad \text{and} \quad \int_{-\frac{\pi}{2}}^{0}\sin(3x-\frac{\pi}{2})\,\mathrm{d}x. \end{equation*}\]

2: Partial Integration. By Hand#

Question a#

We will first prove the formula for partial integration. Begin by differentiating the expression on the right-hand side of

\[\begin{equation*} \int f(x)g(x)\,\mathrm{d}x = F(x)g(x)- \int F(x)g^\prime(x) \,\mathrm{d} x. \end{equation*}\]

Now finish the proof.

Question b#

Determine an anti-derivative for the function \(x\cos(x)\), and check that it is correct.

Question c#

Find an anti-derivative for \(\ln(x)\) using partial integration.

3: Integration by Substitution#

For the questions in this exercise, use the substitution formula,

\[\begin{equation*} \int{f(g(x))g'(x)\,\mathrm{d}x}=\int{f(t)\,\mathrm{d}t}\quad \text{where } t=g(x). \end{equation*}\]

Question a#

Determine an anti-derivative for \(\displaystyle{x\mathrm{e}^{x^2}}\).

Question b#

Determine the indefinite integral \(\displaystyle{\int \frac{x}{x^2+1} \,\mathrm{d}x}\).

Question c#

Find an anti-derivative for \(\displaystyle{\frac{\sin (x)}{3 -\cos(x)}}\), and then compute \(\displaystyle{\int_0^{\pi} \frac{\sin (x)}{3 -\cos(x)} \,\mathrm{d}x}\).

4: Sequences#

In this and the following exercise we are presenting samples of an important cornerstone of integral calculus: Sequences and their possible convergence. From the Danish encyclopedia Den Store Danske (publisher Gyldendal), translated:

convergence, term of fundamental meaning in mathematical analysis, especially in the theory of infinite series. A sequence of real numbers \(x_1,x_2,\ldots\) is called convergent if a number \(x\) exists such that the number \(x_n\) is arbitrarily close to \(x\) if just \(n\) is sufficiently large \((\ldots)\). The number \(x\) is called the limit value of the sequence, which is said to converge towards \(x\). If the sequence is not convergent, it is called divergent.

More precisely, a sequence \(x_1,x_2,\ldots\) is said to be convergent if a number \(x\) exists with the following property:

\[\begin{equation*} \forall \epsilon >0 \exists N \in \mathbb{N}: n \ge N \Rightarrow |x_n -x| < \epsilon. \end{equation*}\]

Four sequences \((a_n)_{n=1}^\infty\), \((b_n)_{n=1}^\infty\), \((c_n)_{n=1}^\infty\), and \((d_n)_{n=1}^\infty\) are given by

\[\begin{equation*} a_n=\frac 1n, \: b_n=\frac{n-1}{2n}, \: c_n=\frac{n}{1000}, \:\text{and}\; d_n=\frac{4n^2+16}{8-3n^2} \end{equation*}\]

for \(n \in \mathbb{N}\). A sequence is in short form written as \((a_n)\) for \((a_1, a_2, \dots)\) and can be considered as an infinite ordered list.

Determine which of the four sequences that are convergent, and state the limit value for those that are.

Note

The term convergence is not only important in mathematical analysis. It is also the precise description of “engineering propositions” such as

Our algorithm/method/etc. converges if we just incorporate enough measurement points/data points/samples/etc.

5: Integrals via Left Sums#

We will compute the Riemann integral \(\displaystyle{\int_0^1 f(x) \,\mathrm{d}x}\) of the function

\[\begin{equation*} f(x)=x, \quad x\in \left[0,1\right] \end{equation*}\]

directly from the definition (so, do not find an anti-derivative such as \(F(x)=x^2/2\) and then compute \(F(1)-F(0)=1/2-0=1/2\)).

We subdivide the interval \([0,1]\) in \(n\) equally large pieces, meaning \(x_j=j/n\) for \(j=0,1,2,\dots, n\). The Riemann sum \(S_n\) is called a left sum \(V_n\), if we always evaluate \(f\) at the left end-point of each subinterval, so \(\xi_j = x_{j-1}\) for \(\xi_j \in [x_{j-1},x_j]\) for \(j=1,2,\dots, n\).

Using this, compute \(\displaystyle{\int_0^1 x\,\mathrm{d}x} = \lim_{n \to \infty} V_n\).