---
title: Problem set 4
heading: "Problem set 4: integration rules and hard integrals"
eyebrow: A13 · Problem set 4
type: problems
---

::: hook
These problems use lessons 17 to 21: the trapezoid and Simpson rules with their error formulas, Gaussian quadrature, adaptive and Romberg integration, singular, infinite and oscillatory integrals, and the lab's code. Give each answer to the precision the rule actually achieves; that's often the point of the question.
:::

::: pool
pick: 12

::: check
kind: parts
given: n = 2 | 4; b = 1 | 2

## Integrate $x^2$ from 0 to {b} with {n} equal intervals.

::: part
answer: (b/n)*((b/n)^2*(n - 1)*n*(2*n - 1)/6 + b^2/2)
tolerance: 0.5%

### What does the trapezoid rule give?

::: misses
- [b^3/3] That's the exact value; the trapezoid rule overestimates a convex function.
- [any] $h\left(\frac{f_0 + f_n}{2} + \sum_{i=1}^{n-1}f_i\right)$.
:::
:::

::: part
answer: b^3/(6*n^2)
tolerance: 0.5%

### By how much does it exceed the exact value?

::: misses
- [any] $\frac{h^2}{12}(f'(b) - f'(0)) = \frac{h^2}{12} \cdot 2b$, exact for a quadratic.
:::
:::
:::

::: check
kind: parts
given: n = 4 | 8; c = 2 | 3

## Integrate $e^{\given{c}x}$ from 0 to 1 with {n} intervals.

::: part
answer: (1/n)^2/12*c*(exp(c) - 1)
tolerance: 1%

### Estimate the trapezoid rule's error from $\frac{h^2}{12}(f'(1) - f'(0))$.

::: misses
- [(1/n)^2/12*(exp(c) - 1)] $f' = ce^{cx}$.
- [any] $\frac{h^2}{12}c(e^c - 1)$.
:::
:::

::: part
answer: (1/n)^4/180*c^3*(exp(c) - 1)
tolerance: 1%

### And Simpson's, from $\frac{h^4}{180}(f'''(1) - f'''(0))$?

::: misses
- [any] $f''' = c^3e^{cx}$.
:::
:::
:::

::: check
kind: parts
given: a = 0 | 1; b = 2 | 3

## Integrate $x^3$ from {a} to {b}.

::: part
answer: (b - a)/6*(a^3 + 4*((a + b)/2)^3 + b^3)
tolerance: 0.1%

### What does Simpson's rule with one panel give?

::: misses
- [any] $\frac{b - a}{6}\left(f(a) + 4f\left(\frac{a + b}{2}\right) + f(b)\right)$.
:::
:::

::: part
answer: (b^4 - a^4)/4
tolerance: 0.1%

### What is the exact value? (Compare: Simpson's rule is exact for cubics.)

::: misses
- [any] $\frac{b^4 - a^4}{4}$.
:::
:::
:::

::: check
kind: parts
given: c = 0.5 | 1 | 2

## Apply the 2-point Gauss rule (nodes $\pm\frac{1}{\sqrt3}$, weights 1) to $\int_{-1}^1e^{\given{c}x}\,dx$.

::: part
answer: 2*cosh(c/sqrt(3))
tolerance: 0.1%

### What does it give?

::: misses
- [any] $e^{c/\sqrt3} + e^{-c/\sqrt3}$.
:::
:::

::: part
answer: 2*sinh(c)/c - 2*cosh(c/sqrt(3))
tolerance: 1%

### What is its error (exact minus rule)?

::: misses
- [any] The exact value is $\frac{2\sinh c}{c}$.
:::
:::
:::

::: check
kind: parts
given: d = 7 | 12 | 15

## A polynomial of degree {d} must be integrated exactly.

::: part
answer: ceil((d + 1)/2)
tolerance: 0

### How many Gauss–Legendre points are needed?

::: misses
- [d + 1] Gauss rules need only half as many points as fixed-node rules.
- [any] $2n - 1 \ge d$.
:::
:::
:::

::: check
kind: parts
given: t1 = 2.000 | 3.000; t2 = 1.800 | 2.700; t4 = 1.760 | 2.640

## Trapezoid values with 1, 2 and 4 intervals are {t1}, {t2} and {t4}.

::: part
answer: (4*t4 - t2)/3
tolerance: 0.01%

### What is the extrapolated value from the last two?

::: misses
- [any] $\frac{4T_4 - T_2}{3}$.
:::
:::

::: part
answer: (16*(4*t4 - t2)/3 - (4*t2 - t1)/3)/15
tolerance: 0.01%

### What is the next Romberg entry?

::: misses
- [any] $\frac{16R_{2,1} - R_{1,1}}{15}$.
:::
:::
:::

::: check
kind: parts
given: s1 = 0.6667 | 1.2; s2 = 0.6602 | 1.18

## Simpson's rule gives {s1} on an interval and {s2} from its two halves.

::: part
answer: s2 + (s2 - s1)/15
tolerance: 0.01%

### What is the extrapolated value?

::: misses
- [s2] Add the correction $\frac{S_2 - S_1}{15}$.
- [any] $S_2 + \frac{S_2 - S_1}{15}$.
:::
:::

::: part
answer: abs(s2 - s1)/15
tolerance: 1%

### About how large is the error of $S_2$?

::: misses
- [any] $\frac{\lvert S_2 - S_1\rvert}{15}$.
:::
:::
:::

::: check
kind: parts
given: a = 0.3 | 0.6 | 0.7

## $\int_0^1x^{-\given{a}}g(x)\,dx$ has an integrable singularity.

::: part
answer: 1/(1 - a)
tolerance: 0.5%

### What is $\int_0^1x^{-a}\,dx$?

::: misses
- [1/a] Integrate $x^{-a}$ to $\frac{x^{1-a}}{1 - a}$.
- [any] $\frac{1}{1 - a}$.
:::
:::

::: part
answer: 1/(1 - a)
tolerance: 0.5%

### With $x = t^k$, the factor $x^{-a}dx$ becomes $kt^{k(1 - a) - 1}dt$. What k makes the exponent 0?

::: misses
- [any] Solve $k(1 - a) - 1 = 0$.
:::
:::
:::

::: check
kind: parts
given: L = 1.5 | 2 | 2.5 | 3 | 3.5 | 4

## Truncate $\int_0^\infty e^{-x^2}dx$ at L = {L}.

::: part
answer: exp(-L^2)/(2*L)
tolerance: 15%

### About how large is the missing tail?

::: misses
- [exp(-L^2)] Divide by 2L.
- [any] $\frac{e^{-L^2}}{2L}$.
:::
:::
:::

::: check
kind: parts
given: n = 3 | 4 | 6

## Map $\int_0^\infty\frac{dx}{(1 + x)^{\given{n}}}$ with $x = \frac{t}{1 - t}$.

::: part
answer: 1/(n - 1)
tolerance: 0.5%

### What is the integral?

::: misses
- [any] The new integrand is $(1 - t)^{n-2}$.
:::
:::
:::

::: check
kind: parts
given: k = 4 | 9 | 20

## Lobe k of $\int\frac{\sin x}{x}dx$ runs from $k\pi$ to $(k + 1)\pi$.

::: part
answer: 2/((k + 0.5)*pi)
tolerance: 1%

### About how large is lobe {k}?

::: misses
- [any] Area 2 times $\frac{1}{(k + \frac12)\pi}$.
:::
:::

::: part
answer: (2/((k + 0.5)*pi))/2
tolerance: 2%

### Stopping after lobe k − 1, the error of a partial sum is about half the next lobe. About how large?

::: misses
- [any] Half of lobe k's size.
:::
:::
:::

::: check
kind: parts
given: L = 2 | 3; M = 4 | 10; n = 10 | 100

## The trapezoid rule with {n} intervals on an interval of length {L}, with $\lvert f''\rvert \le$ {M}.

::: part
answer: L*(L/n)^2*M/12
tolerance: 0.5%

### What bound does the error formula give?

::: misses
- [(L/n)^2*M/12] Multiply by the length: $\frac{(b - a)h^2}{12}\max\lvert f''\rvert$.
- [any] $\frac{(b - a)h^2M}{12}$.
:::
:::
:::

::: check
kind: parts
given: e = 0.001 | 0.002 | 0.005 | 0.01 | 0.02 | 0.05

## An adaptive Simpson routine has tolerance {e} on [0, 1] and splits an interval in half.

::: part
answer: e/2
tolerance: 0.5%

### What tolerance does each half get?

::: misses
- [e] The halves' errors add, so each gets half.
- [any] Split the tolerance with the interval.
:::
:::

::: part
answer: 15*e/2
tolerance: 0.5%

### Below what $\lvert S_2 - S_1\rvert$ on a half is it accepted?

::: misses
- [any] The error of $S_2$ is about $\frac{\lvert S_2 - S_1\rvert}{15}$.
:::
:::
:::

::: check
kind: parts
given: N = 4 | 8 | 12 | 16 | 32 | 64

## Chebyshev coefficients are computed from N = {N} samples by the midpoint rule in θ.

::: part
answer: 2*N - 1
tolerance: 0

### The computed $c_1$ also picks up a higher coefficient. What is the lowest such index?

::: misses
- [N + 1] On a midpoint grid of N points, $\cos k\theta$ aliases with $\cos(2N \pm k)\theta$.
- [any] $2N - k$ with k = 1.
:::
:::
:::

::: check
kind: parts
given: x = 0.01 | 0.04 | 0.09 | 0.25 | 0.5 | 1

## Integrate $\frac{\cos x}{\sqrt x}$ from 0 to {x} by subtracting the singularity.

::: part
answer: 2*sqrt(x)
tolerance: 0.5%

### What is the exact integral of the subtracted part, $\int_0^x\frac{dx}{\sqrt x}$?

::: misses
- [sqrt(x)/2] $\int x^{-1/2}dx = 2x^{1/2}$.
- [any] $2\sqrt x$.
:::
:::
:::
:::
