Watch these three (3) videos in order. The total video time is 12 min. Be sure to test your knowledge with the knowledge checks after each video.

Description: This video introduces numerical integration for dataset and equations.

Video Transcript Hide Video transcript

Hello, this is video NI|VL|01, and it'll be in an introduction to numerical integration.

First, a brief introduction. The mathematical representation of the integral I is the integral between a and b of f(x) dx. Here, a and b represent the bounds where a is a lower part of the bounds of the integral and b is the upper bound. This type of integral is known as the definite integral as well. Graphically, this would mean taking the area under the function f(x) between the bounds a and b.

Some functions are known and are easy to solve. For example, this equation here. For example, this can be the integral between 0 to 2 of x3 + 4. This can be solved to be x4/4+4x. We can then plug in the bounds of 0 and 2 to find the definite integral, which in this case would be equal to 12. However, in engineering, not all equations are that simple. Take for example this equation where h is the height of a fluidized bed reactor, which is related to the initial concentration of species A, CA0, and the superficial gas velocity u, as well as the integral of the function representing the conversion, X. Not all functions need to be as complicated, even simple ones such as e^(-x2) does not have an analytical solution. In some cases, you may not even have a function to integrate over and instead have raw data. Some methods discussed in this module will teach you how to integrate raw data.

This concludes the video. This project could not have been completed without the support of eCampusOntario and the University of Ottawa.

Description: This video discusses using the Newton-Cotes methods (Trapezoid rule, Simpson’s 1/3, and Simpson’s 3/8) to solve equally and unequally spaced data sets.

Video Transcript Hide Video transcript

Hello, this is video NI|VL|02 and it will be the theory of Newton-Coates methods for solving numerical integration problems.

First let’s discuss the general theory for these methods. These methods assume that the true integral, I, of some function f(x) or data can be approximated by a polynomial fn(x). The n here represents the order of the polynomial. For example, f1(x) would represent linear equation a0 + a1x, f2(x) would represent a quadratic equation, f3(x) would represent a cubic and so forth. Polynomial functions are easy to integrate and can be used to estimate the integral of complex functions or to find the area under a curve of data.

Let's start with the simplest method at the Trapezoid rule. The Trapezoid rule uses the function f1(x), which is a linear equation. To find the equation of a line, you need two points. In this case, we're using x0 and x1. We can now integrate f1(x) between x0 and x1. And this will represent the estimate of the integral by the trapezoid rule called ITRAP. When this is completed, ITRAP will be equal to h[f(x0) +f(x1)]/2. Here, h represents the distance between the points x1 and x0. Let's look at the graphical representation of the trapezoid rule. First, let's assume we have some sort of function that we need to integrate. We will take two points, that will be at x0 and x1. With these two points, we can find f(x0) and f(x1) and draw a line between the two of them. This linear function has a shape of a trapezoid, hence the name Trapezoid Rule. The area of a trapezoid is the base times the average of the two heights, which is the same equation. h, here is between x1 and x2 and that is your base and you're taking the average between f(x0) and f(x1). Next, we will look at Simpson's 1/3 rule. Simpson's 1/3 rule uses f2(x), which is a quadratic equation. It has points x0, x1, and x2. And its quadratic equation goes through each of these points. f2(x) can be easily integrated between x0 and x2. This gives Simpson's 1/3 rule as the estimate of integral I as (h/3)(f(x0) +4f(x1) + f(x2)). It is called the 1/3 because h is divided by three. For Simpson's 1/3 rule to apply, points x0, x1 and x2 have to be equally spaced. That is, h = x1 - x0 or x2 - x1. Let's look at the graphical representation of Simpson's 1/3 rule. With our function, we will have three equidistance points, x0, x1, and x2. With three points, we can fit a quadratic equation through it. And with Simpson's 1/3 rule, we can find the area underneath that quadratic equation. What you'll notice in the figure is that the area under the green curve is not equal to the area under the red curve, but it is closer than the trapezoid rule. As a reminder, the distance between the points is h.

We will now discuss Simpson's 3/8 rule. As you may have guessed, Simpsons 3/8 rule uses a cubic equation to go through points x0, x1, x2, and x3. Integrating that cubic equation over x0 to x3 gives you (3h/8)*(f(x0)+3f(x1) +3f(x2) +f(x3)). The name of Simpson's rule comes because you are multiplying it by 3/8. Like Simpson's 1/3, Simpson's 3/8 needs to have the points equally distanced, which means that h is equal to x1 - x0, or x2 - x1, or x3 - x2. Let's look at Simpson's 3/8 rule graphically now, we will start with four points, x0, x1, x2, and x3. And with these four points, we will fit a cubic equation to them and then we will use Simpson’s 3/8 rule to find the area under this cubic equation. As a reminder of the points are equidistance between each other, which is equivalent to h. What you'll notice is that Simpson's 3/8 rule in this case gives a pretty good estimation of the area underneath this curve.

Next, we'll look at applying these methods over a series of data points. With multiple data points, we can simply apply one of the three Newton-Cotes methods, the trapezoid rule, Simpson's 1/3 or Simpson’s 3/8 rules to a series of data points. For example, with the data shown here, we can apply a series of trapezoid rules. Since they're evenly spaced, we can use a condensed version of the trapezoid rule for multiple data points, which is the trapezoid rule is equal to (h/2) times f(x0) plus 2 times all summation of all the interior points at f(xi), plus f(xn). Trapezoid Rule as it was shown, it's not necessarily the best method for evenly spaced data. In fact, Simpson's 1/3 and 3/8 rules would be a bit better. Generally speaking, Simpson's 1/3, and 3/8 rules have a similar performance of estimate the integral over the same area. Therefore, if you have an odd number of points, you can use Simpson's 1/3 rule to integrate over the entire range of data points, like the trapezoid rule for equally spaced data points. You can also group Simpson's 1/3 rules together to make one single equation. For an even number of data points, you can use Simpson's 3/8 rule for the first four points and then continue on with Simpson's 1 third rule. This can also be grouped into a single, yet complex equation. If you have unequally space data are shown here, what you can do is you use combination of Trapezoid, Simpson's 1/3 and 3/8 rules to give the best possible estimate of the answer. Anytime that you would have 3 points that are equally spaced, then you could use Simpson's 1/3. If there's 4 points that are equally space and you can use Simpson’s 3/8. And then every other case then you'd use Trapezoid Rule.

Finally, let's look at integrating functions with the Newton-Cotes methods. Since you have the function, you can actually generate your own data. You can keep taking more data points until the estimate of the integral converges to some value. As you can see that the function here, Trapezoid rule is used multiple times and the area underneath all these Trapezoid rules is getting closer to the area of the function. Instead of using the Trapezoid rule, you can also use Simpson's 1/3, and 3/8 rules provided that the points are equally spaced. You should be able to get a more accurate answer with the Simpson's rules with less data points.

This concludes the video. This project could not have been completed without the support of eCampusOntario and the University of Ottawa.

Description: This video implements the theory of all the Newton-Cotes methods in a practice problem in a step-by-step approach.

Video Transcript Hide Video transcript

Hello, this is video NI|VL|03, and it will be a step-by-step example of using Newton-Coates methods for solving numerical integration problems.

Let's first look at the problem. The problem is: Use appropriate Newton-Coates methods to integrate the following data. There are 16 data points, and you'll notice that this data is not evenly spaced; therefore, you'll be using a combination of the Trapezoid rule and Simpson's 1/3 and 3/8 rules. Let's look at the solution to this problem. First, we look at the layout, the top left-hand corner, you'll have a graphical representation of the data. On the right-hand side is the data table that will have the calculations and the raw data. On the bottom left will be the three equations that we can use to solve this problem. Let's look at those equations. First, we have the Trapezoid rule, which will be used for 2 consecutive points. Next we have Simpson's 1/3, which will be used for 3 consecutive points. Finally, we have Simpson’s 3/8 rule that can be used for 4 consecutive points.

Let's plot the data. From the graph you can see that the data is not equally spaced, and it fluctuates up and down. Our next step is to determine the distance between all the x points, which can be labeled as h. And so you can take the difference between the second and the first and then the third and the second and so forth. To produce this table, what you'll notice there is some distance between the points or even until we can use potentially Simpson's 1/3 rule or Simpson's 3/8 rule to solve it. And if it's not, then we will use the Trapezoid rule. Let's determine which Newton-Coates methods we should use and then find the integral for that value, i.e., the first four data points, 0,0.1, 0.2, 0.3 are all evenly spaced by 0.1 and therefore Simpson's 3/8 can be used. We can now apply the equation for Simpsons 3/8 rule using our data and our f(x) values. In this case here, f(x0) = 2.6, f(x1) = 3.18,  f(x2) = 3.55 and f(x3) = 3.55 as well. The integral for that region is approximately 0.989. We can now look at our next set of data points. In the next three points are spaced out by 0.05, which means that we can use Simpson's 1/3 rule to solve this one. The h here will be 0.05, since that's the spacing between these sets of data points. The estimate of the integral here is approximately 0.340. The next set of points do not have an evenly spaced data, and therefore we will take the next two points and use the Trapezoid rule. This gives an estimate of integral between these two points as approximately 0.0627. And now we continue working down the data and deciding which methods to use between the Trapezoid, Simpson's 1/3 and 3/8 rules until we've found all of the areas under each section. Once we have all the areas and we can sum them up to get the area under the total integral between 0 and 1 in this case. In this case the answer is 2.60182. And we're now done this problem.

This concludes the video. This project could not have been completed without the support of eCampusOntario and the University of Ottawa.