Tutorial Week 5

Numerical Integration

Sometimes, a function just isn’t integrable. In those cases, to approximate an integral, we can use Riemann sums to find a good estimate of the integral.

If we have \(x_k = a + k\Delta x\), then we can define the following Riemann sums:

Left: \(x_k^\star = x_{k-1}\)

Right: \(x_k^\star = x_k\)

Midpoint: \(x_k^\star = \frac{x_{k - 1} + x_k}{2}\)

We can also use the trapezoid sum to approximate integrals, defined as:

\(T_n = \Sigma^n_{k=1} \frac{\Delta x}{2} (f(x_{k-1}) + f(x_k))\)

There’s also Simpson’s rule, defined as:

\(S_n = \frac{\Delta x}{3} (f(x_0) + 4f(x_1) + 2f(x_2) + 4 f(x_3) + 2f(x_4) + \dots + 2f(x_{n-1}) + 4f(x_{n-1}) + f(x_n)\)

Q2: Approximate \(\int_{-\pi}^{\pi} \frac{sin(x)}{x}dx\) using Simpson’s Rule with \(n=4\).

../../_images/55.jpeg

Improper Integrals

Up to now, we’ve only dealt with integrals on the continuous intervals of functions, but what if the function wasn’t continuous at some point or interval was infinite? For improper integrals, we have two cases:

  • The function is discontinuous at some point in the interval of integration

  • One of the endpoints is \(\pm \infty\)

In these cases, we simply use limits against the “illegal”

Q3: Evaluate \(\int_{-1}^1 \frac{1}{x^{\frac{2}{3}}} \; dx\).

../../_images/218.jpeg

Sometimes, we’re only interested in whether an integral converges or diverges, and not the specific value it converges to.

In these cases, we can use the comparison test to simplify our calculations.

The comparison test states:

  • If \(f(x) \ge g(x) \ge 0\) for all \(x \ge a\) and \(\int_a^\infty f(x) dx \)int_a^infty g(x) dx` converges.

  • If \(f(x) \ge g(x) \ge 0\) for all \(x \ge a\) and \(\int_a^\infty g(x) dx \)int_a^infty f(x) dx` diverges.

Q4: Does \(\int_{-\infty}^{-1} \frac{\sin\left(x\right)^{2}\cos\left(x\right)^{2}}{x^{2}} \; dx\) converge or diverge?

../../_images/413.jpeg