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 in big-O notation can be written as: $$I_i=\frac{\Delta x_i}{2} \left( f(x_i)+f(x_i+\Delta x_i)\right) + O(\Delta x_i^3)$$ (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=0}^{x=2} e^{x^2}$$ with the number of integration steps $N$ set to 50. The C code should start as follows:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>

double f(double x){
double ret;
ret=exp(x*x);
return(ret);
}

int main(void){
 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_{x=0}^{x=2} e^{x^2}$$ in the interval $1<x<2$ with the number of integration steps $N$ set to 50. The C code should start as follows:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>

double f(double x){
double ret;
ret=exp(x*x);
return(ret);
}

int main(void){
Note: the C code should work 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_0^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$