For problem 3 on Exam Review 2, we are given the integral $$\int_{-1}^1 \cos(x^2) dx$$

Which we are to approximate using a trapezoidal sum within $10^{-6}$ of the actual value.

From our notes in previous classes, I have that a trapezoidal approximation to an integral would be $$\int_a^b f(x)dx \approx T_n = \sum_{i=1}^n \frac{f(x_i)+f(x_{i-1})}{2}\Delta x.$$

To approximate the error, I have that the difference between the actual integral value and our trapezoidal sum is:

$$|I-T_n|\leq \frac{D}{12}\frac{(b-a)^3}{n^2},$$

where $D$ is a bound on $f''$ over our the bounds of the integral. From examining the graph in the Exam Review 2, we can see that there is an upper bound around 2 for $f''(x)$, but we'll set our bound to 3 just to be safe.

This leaves us with the following:

$$|I-T_n|\leq \frac{3}{12}\frac{(1- -1)^3}{n^2}=\frac{1}{4}\frac{8}{n^2}=\frac{2}{n^2}$$

So to keep our error less than $10^{-6}$, we would want $n$ such that

$$\frac{2}{n^2}=10^{-6},$$

which we can solve for $n^2=2*10^6$, or $n=\sqrt{2}*1000$. From here, we can loosely overestimate 1.5 for $\sqrt{2}$ and know that with 1500 terms, we'll be well within our acceptable error tolerance.

For part b, we would simply want to find a way to linearly map each term $i$ to a separate, evenly spread point along out range of -1 to 1; from what Mark covered in class today, it seemed fairly effective to simply add $\frac{i}{n}$ to the lower bound as shown below:

$$\int_{-1}^1 \cos(x^2)dx \approx T_n = \sum_{i=1}^{1500} \frac{1}{2}\left(\cos((\frac{i-1}{1500}-1)^2)+\cos((\frac{i}{1500}-1)^2)\right)\Delta x.$$