Numerical Analysis Assignment 7 — Numerical Integration
 Question #1
Using a previously-derived expression for the mid-point rule: $$I_i=\Delta x_i f(x_m) + \frac{\Delta x_i^3}{24} f^" (x_m) + \frac{\Delta x_i^5}{1920} f^{""}(x_m)+ ...$$ Do the following:
 (a) Show that the trapezoidal rule can be written as: $$I_i=\frac{\Delta x_i}{2} \left( f(x_i)+f(x_i+\Delta x_i)\right) -\frac{\Delta x_i^3}{12} f^{\prime\prime}(x_m) -\frac{\Delta x_i^5}{480} f^{\prime\prime\prime\prime}(x_m) + ...$$ (b) Show that the global error associated with the trapezoidal rule is $O(\Delta x^2)$
 09.28.16
 Question #2
Using the trapezoidal rule: $$I_i=\frac{\Delta x_i}{2} \left( f(x_i)+f(x_i+\Delta x_i)\right) + O(\Delta x_i^3)$$ Write a C code that finds the numerical solution of the integral $$\int_{x=1}^{x=2} e^{x^2} dx$$ with the number of integration steps $N$ set to 50. The C code should start as follows:
 Question #3
Making use of the Simpson rule: $$I_i=\textrm{odd}(i) \frac{(\Delta x_i+\Delta x_{i+1})}{6} \left( f(x_i) + 4 f(x_{i+1}) +f(x_{i+2}) \right) + O(\Delta x_i^5)$$ Write a C code that finds the numerical solution of the integral $$\int e^{x^2} dx$$ in the interval $1\le x \le 2$ with the number of integration steps $N$ set to 50. The C code should start as follows:
Note: the C code should give a high accuracy of the integral when $N$ is odd and when $N$ is even.
 Question #4
Using the two C codes you developed for Questions #2 and #3, show the difference in accuracy between the Simpson rule and the Trapezoidal rule when integrating $e^{x^2}$ in the interval $1\le x \le 2$. For this purpose, tabulate the results in a table such as the following:
 $N$ Method $\sum_i I_i$ $\left|\sum_i I_i-\int_1^2e^{x^2}dx\right|$ 3 Trapezoidal .. .. 7 Trapezoidal .. .. 15 Trapezoidal .. .. 31 Trapezoidal .. .. 3 Simpson .. .. 7 Simpson .. .. 15 Simpson .. .. 31 Simpson .. ..
Does the error (the last column) go down as expected? Discuss.
 $\pi$