---
jupytext:
  formats: md:myst
  text_representation:
    extension: .md
    format_name: myst
    format_version: '0.8'
    jupytext_version: 1.4.1+dev
kernelspec:
  display_name: Python 3
  language: python
  name: python3
---

+++

(section:uge5L-extra)=
# Extra (optional) exercises -- Short Day

+++

These exercises are optional extra material for students who have finished the exercises of the day and have the time and interest for more.

+++

## Extra exercise 1: Area under a parabola

+++

Let $N$ be a positive real number and $n$ a natural number. We define $d=N/n$. As is most likely known from highschool, the area between the parabola and the first axis between $x=0$ and $x=N$ can be computed as a definite integral as follows:

$$\int_0^N x^2 dx =\frac13 N^3-\frac13 0^3=\frac13 N^3.$$

In this exercise we wish to investigate how well this area is approximated using the finite sum $\sum_{k=1}^n d\cdot(kd)^2$. The situation is illustrated in the following figure:

![](./uge6_6.png)

+++

### Question a

+++

Use the figure above to realise that 

$$\frac13 N^3 \le \sum_{k=1}^n d\cdot (kd)^2.$$

+++

### Question b

+++

The following distributive rule holds true for all natural numbers $n$ and all complex numbers $a,b_1,\dots,b_n$:

$$a \cdot (b_1+\cdots+b_n)=a\cdot b_1+\cdots + a \cdot b_n.$$

Use this fact to realise that

$$d^3\sum_{k=1}^n k^2=\sum_{k=1}^n d^3\cdot k^2=\sum_{k=1}^n d\cdot (kd)^2.$$

+++

### Question c

+++

Use induction on $n$ to realise that $\sum_{k=1}^n k^2=\frac13 n(n+1/2)(n+1)$ for all natural numbers $n$.

```{hint}
:class: dropdown
In the induction step you will most likely at some point get to the formula 

$$\frac13 (n-1)(n-1/2)n+n^2.$$

You could expand this expression by multiplying through and then check that it gives the correct result, but a lot of work can be saved by first factorizing $n$ outside of the brackets:

$$\frac13 (n-1)(n-1/2)n+n^2=n\left( \frac13 (n-1)(n-1/2)+n\right).$$

Now try to realise that the expressions in the parentheses equal $\frac13 (n+1/2)(n+1).$
```

```{admonition} Answer
:class: dropdown
For the base case, when $n=1$, the formula holds since $\sum_{k=1}^1 k^2=1^2=1$ agrees with $\frac13 1(1+1/2)(1+1)=\frac{3}{3}=1$.

For the induction step, when $n \ge 2$, if we assume the induction hypothesis which says that $\sum_{k=1}^{n-1} k^2=\frac13 (n-1)(n-1/2)n$, we get

$$\sum_{k=1}^{n} k^2 = \sum_{k=1}^{n-1} k^2 +n^2=\frac13 (n-1)(n-1/2)n+n^2.$$

For example, by following the above hint it should be possible to realise that $\frac13 (n-1)(n-1/2)n+n^2=\frac13 n(n+1/2)(n+1)$, which means that the induction step holds. The induction principle hence implies that the formula $\sum_{k=1}^n k^2=\frac13 n(n+1/2)(n+1)$ holds for all natural numbers $n$.
```

+++

### Question d

+++

Now show that $\sum_{k=1}^n d\cdot (kd)^2=\frac{1}{3}N(N+d/2)(N+d)$. 

```{admonition} Answer
:class: dropdown
From the previous question we have

$$\sum_{k=1}^n d\cdot (kd)^2=d^3\sum_{k=1}^n k^2=d^3\left(\frac13 n(n+1/2)(n+1)\right)=\frac{1}{3}N(N+d/2)(N+d).$$

For the last equal sign we used the fact that $N=dn$. 

Note that this equation implies that if $N$ is held fixed while $n$ goes towards infinity, then $d$ goes towards zero, and the sum hence goes towards $\frac13 N^3,$ which precisely is the area under the parabola.
```