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
For each of the C codes you developed for Questions #2 and #3, determine the error 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$$\sum_i I_i$$\left|\sum_i I_i-\int_1^2e^{x^2}dx\right|$
3....
7....
15....
31....
4....
8....
16....
32....
Does the error (the last column) go down as expected? Discuss. Do this for
(a)  The trapezoidal rule;
(b)  The Simpson rule.
Question #5
You wish to create a new numerical integration method. To do so, you come up with the idea of evaluating the integral $I_i$ by fitting a 2nd degree polynomial of the form $$ P_i(x)=a_i + b_i(x-x_i) + c_i (x-x_i)^2 $$ through 3 data points within the $i$th interval. For this purpose, do the following:
(a)  Express the polynomial coefficients $a_i$, $b_i$, and $c_i$ as a function of the data points $(x_i,~f_i)$, $(x_{i+1/2},~f_{i+1/2})$, $(x_{i+1},~f_{i+1})$.
(b)  Using the polynomial coefficients derived in (a), find an expression for $I_i$ over the interval $x_i\le x \le x_{i+1}$ and simplify as much as possible.
11.26.18
Answers
5.  $b_i=\frac{2}{\Delta x_i}\left( 2 f_{i+1/2}-\frac{3}{2}f_i - \frac{1}{2} f_{i+1} \right)$.
Due on Monday December 10th at 16:30. Do Problems #1, #3, #4b, and #5 only.
PDF 1✕1 2✕1 2✕2
$\pi$
cron