Lab 8 (20/09/2017)
Numerical Integration
First, implement the following methods for
Numerical Integration. Later use these methods and other
code that you have written so far this semester to solve
the two problem sets given below.
- Midpoint Rule
$$\int\limits_a^b f(x)\,{\rm d}x = (b-a)
f(\frac{a+b}{2})$$
- Trapezoidal Rule
$$\int\limits_a^b f(x)\,{\rm d}x = \frac{(b-a)}{2}
(f(a) + f(b))$$
- Simpson's Rule
$$\int\limits_a^b f(x)\,{\rm d}x = \frac{(b-a)}{6}
\left[f(a) + 4f(\frac{a+b}{2}) + f(b)\right]$$
- Composite Trapezoidal Rule
$$\int\limits_a^b f(x)\,{\rm d}x = \frac{b-a}{2n}
[f(a) + 2f(x_1) + 2f(x_2) + \cdots + 2f(x_{n-1}) +
f(b)]$$
- Composite Simpson's Rule
$$\int\limits_a^b f(x)\,{\rm d}x = \frac{b-a}{3n}
[f(a) + 4f(x_1) + 2f(x_2) + 4f(x_3) + 2f(x_4) +
\cdots + 4f(x_{n-1}) + f(b)]$$
Problem Set 1
- Find $$\int\limits_1^2\sqrt{1+x^2}\,{\rm d}x$$ using
the first three methods above and compute the errors if
the true integral is
$$\frac{x\sqrt{1+x^2}+{\rm asinh}(x)}{2}$$ The true
value should come out to 1.81
- Find $$\int\limits_1^2\sqrt{1+x^3}\,{\rm d}x $$using
the two composite methods by dividing the range into 6
equal intervals. The true value is 2.12986
- Find $$\int\limits_0^6\frac{1}{2\sqrt{2\pi}}
\exp(-\frac{x^2}{8})\,{\rm d}x$$ using any of the
methods above. If the true value of the integral is
0.5, how does your result compare with the true value?
Problem Set 2
- The daily rainfall amounts (in mm) at Atumba weather
station over a one-week period (Mon - Sun) are given
below. The data for Thursday is missing. What is your
estimate for the total weekly rainfall for that week?
148.7 (Mon), 276.4 (Tue), 90.8 (Wed), 112.4
(Fri), 32.5 (Sat), 1.4 (Sun)
- Find at least two roots of $$1.3x^4 - 8.6x^2 + 1.2 =
0$$Can you find all the roots?
- Find at least two roots of $$1.3x^4 - 8.6x + 1.2 =
0$$Can you find all the roots?